namespace CDSAE3_Lian_Lian_Kan.Forms
{
    public partial class MenuForm : Form, IMenuForm
    {
        public MenuForm()
        {
            InitializeComponent();
            Etcs.gameMenuForm = this;
        }
        Color menuThemeColor, playThemeColor;
        bool IsOutPicture = false;
        bool AnimationUseImage = false;
        Image? playPanelImage;
        public void SetTheme()
        {
            Etcs.ThemeInfo theme = Etcs.currentThemeInfo;
            AnimationUseImage = theme.AnimationUseImage;
            IsOutPicture = theme.IsOutPicture;
            if (IsOutPicture)
                BackgroundImage = new Bitmap(theme.PictureName!);
            else
                BackgroundImage = (Image)Etcs.res_Manager.GetObject(theme.PictureName!, Etcs.res_Culture)!;
            if (theme.PlayPanelUsePicture)
                if (theme.PlayPanelPictureIsOutPicture)
                    playPanelImage = new Bitmap(theme.PlayPanelPictureName!);
                else
                    playPanelImage = (Image)Etcs.res_Manager.GetObject(theme.PlayPanelPictureName!, Etcs.res_Culture)!;
            start_Game.Location = new Point(theme.StartGamePos![0], theme.StartGamePos[1]);
            to_Challenge_mode.Location = new Point(theme.ChallengeModePos![0], theme.ChallengeModePos[1]);
            to_table_of_scores.Location = new Point(theme.ScoreBoardPos![0], theme.ScoreBoardPos[1]);
            to_settings.Location = new Point(theme.SettingsPos![0], theme.SettingsPos[1]);
            menuThemeColor = Color.FromArgb(theme.ThemeColor![0], theme.ThemeColor[1], theme.ThemeColor[2]);
            Color buttonColor = theme.ButtonColor!.Count == 3 ? Color.FromArgb(theme.ButtonColor![0], theme.ButtonColor![1], theme.ButtonColor![2]) :
                Color.FromArgb(theme.ButtonColor![0], theme.ButtonColor![1], theme.ButtonColor![2], theme.ButtonColor![3]);
            playThemeColor = Color.FromArgb(theme.PlayAreaThemeColor![0], theme.PlayAreaThemeColor[1], theme.PlayAreaThemeColor[2]);
            start_Game.BackColor = buttonColor;
            to_Challenge_mode.BackColor = buttonColor;
            to_table_of_scores.BackColor = buttonColor;
            to_settings.BackColor = buttonColor;
            start_Game.Size = new Size(theme.ButtonSize![0], theme.ButtonSize[1]);
            to_Challenge_mode.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
            to_table_of_scores.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
            to_settings.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
            mainLabel.Font = new Font(theme.Font!, float.Parse(theme.FontSize!));
            mainLabel.BackColor = buttonColor;
            mainLabel.ForeColor = Color.FromArgb(theme.FontColor![0], theme.FontColor[1], theme.FontColor[2]);
            mainLabel.Location = new Point(theme.FontBlockPos![0], theme.FontBlockPos[1]);
            mainLabel.Size = new Size(theme.FontBlockSize![0], theme.FontBlockSize[1]);
            Etcs.song_Audio_Processer.set_albums(Etcs.curAlbum);
            Etcs.song_Audio_Processer.set_song(Etcs.song_Audio_Processer.get_next_song());
        }
        public void playFormToMenu()
        {
            Etcs.form?.change_form(this, true, playThemeColor, menuThemeColor);
        }

        private void start_Game_Click(object sender, EventArgs e)
        {
            Etcs.form?.change_form(new Leisure_Mode(), true, menuThemeColor, playThemeColor);
        }

        private void to_settings_Click(object sender, EventArgs e) 
        {
            Etcs.form?.change_form(Etcs.setting, false, null, null);
        }

        private void to_table_of_scores_Click(object sender, EventArgs e)
        {
            Etcs.form?.change_form(Etcs.charts, false, null, null);
        }

        private void to_Challenge_mode_Click(object sender, EventArgs e)
        {
            //Etcs.form?.change_form(new Challenge_Mode(), true, menuThemeColor, playThemeColor, AnimationUseImage, this.BackgroundImage);
            Etcs.form?.change_form(new Challenge_Mode(), true, menuThemeColor, Color.Black);

        }
    }
}