using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PuzzlePlayer_Namespace.Resources
{
    internal class ShopMenu : Form
    {

        public ShopMenu()
        {
            ClientSize = new Size(1115, 755);
            Text = "Thme Shop";

            Theme currentTheme = UserDataManager.Theme;
            BackColor = currentTheme.primaryColor;
            SetupUI();
        }

        void SetupUI()
        {
            Label moneyLabel = new Label();
            moneyLabel.Text = $"Money: {UserDataManager.Money}$";
            Font mlFont = new Font(UserDataManager.MainFont.FontFamily, UserDataManager.FONTSIZE * 2);
            moneyLabel.Font = mlFont;
            moneyLabel.Size *= 2;
            Controls.Add(moneyLabel);

            FlowLayoutPanel buyableThemes = new FlowLayoutPanel();
            buyableThemes.Size = this.Size;
            buyableThemes.Location =  new Point(0, 100);

            List<Theme> allThemes = UserDataManager.GetThemes();
            foreach (Theme theme in allThemes)
            {
                if(theme.unlocked)
                {
                    Bitmap bm = new Bitmap(Width / 4, Width / 4);
                    Graphics graphics = Graphics.FromImage(bm);

                    graphics.FillRectangle(new SolidBrush(theme.primaryColor),0,0,bm.Width,bm.Height/3);
                    graphics.FillRectangle(new SolidBrush(theme.secondaryColor),0,bm.Height/3,bm.Width,bm.Height/3);
                    graphics.FillRectangle(new SolidBrush(theme.tertiaryColor),0, bm.Height / 3*2, bm.Width,bm.Height/3);

                    Button button = new Button();
                    button.Text = theme.name;
                    button.Size = bm.Size;
                    button.Image = bm;

                    buyableThemes.Controls.Add(button);
                }
            }


            Controls.Add(buyableThemes);
            
        }
    }
}