Newer
Older
using PuzzlePlayer_Namespace.Resources;
Application.Run(new ShopMenu());//new MainForm());
List<PuzzleForm> puzzleForms = new List<PuzzleForm>();
public MainForm()
{
SetUpPuzzleForms();
SetUpUI();
}
private void SetUpPuzzleForms()
{
this.BackColor = UserDataManager.Theme.primaryColor;
this.Text = "PuzzlePlayer";
MenuStrip menuStrip = new MenuStrip
{
BackColor = UserDataManager.Theme.secondaryColor,
ForeColor = UserDataManager.Theme.secondaryColor,
Name = "Main menu",
Text = "Main Menu",
Dock = DockStyle.Top,
Font = UserDataManager.MainFont,
};
ToolStripMenuItem menuSettings = new ToolStripMenuItem
{
BackColor = Color.FromArgb(54, 57, 62),
ForeColor = Color.Black,
Text = "Settings",
TextAlign = ContentAlignment.BottomRight,
Font = UserDataManager.MainFont,
};
menuSettings.Click += (object o, EventArgs e) =>
{
this.Hide();
SettingForm settingForm = new SettingForm();
settingForm.FormClosed += (object s, FormClosedEventArgs args) =>
{
this.BackColor = UserDataManager.Theme.primaryColor;
this.ForeColor = UserDataManager.Theme.tertiaryColor;
foreach (Control control in this.Controls)
{
}
this.Show();
};
settingForm.Show();
};
// Create a flow layout panel that automatically sorts the buttons when the window is resized
FlowLayoutPanel buttonsPanel = new FlowLayoutPanel
{
Location = new Point(0, menuStrip.Height),
Size = new Size(ClientSize.Width, ClientSize.Height - menuStrip.Height),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
FlowDirection = FlowDirection.LeftToRight,
// Add another row if there are more buttons than that fit in the window horizontally
WrapContents = true,
// Add a scroll bar in case the buttons don't fit on the window vertically
AutoScroll = true,
};
// Add a button for each puzzle type
for (int i = 0; i < puzzleForms.Count; i++)
{
Image normalImage = SettingForm.GetEmbeddedImage(image + ".jpg");
Image grayImage = SettingForm.GetEmbeddedImage(image + "Gray.jpg");
// Set the name of the button
RoundedButton button = new RoundedButton
{
Text = puzzleForms[i].puzzleType,
Margin = new Padding(10),
Height = 345,
Width = 345,
Font = new Font(UserDataManager.MainFont.Name, UserDataManager.MainFont.Size * 2,FontStyle.Bold),
};
button.MouseEnter += (object o, EventArgs e) =>
{
};
button.MouseLeave += (object o, EventArgs e) =>
{
button.MouseClick += (object o, MouseEventArgs e) =>
{
this.Hide();
RoundedButton rb = (RoundedButton) o;
PuzzleForm puzzleForm = puzzleForms[int.Parse(rb.Name)];
puzzleForm.FormClosed += (object o, FormClosedEventArgs fcea) =>
{
this.BackColor = UserDataManager.Theme.primaryColor;
this.ForeColor = UserDataManager.Theme.tertiaryColor;
foreach (Control control in this.Controls)
{
}
this.Show();
};
puzzleForm.Show();
buttonsPanel.Controls.Add(button);
// -- buttons.Add(button);
if (i == 0)
{
this.MinimumSize = new Size(button.Width + 56, button.Height + 83);
}
}
// add BlackJackbutton
buttonsPanel.Controls.Add(SetUpBlackJackButton());
this.Controls.Add(menuStrip);
this.Controls.Add(buttonsPanel);
menuStrip.Items.Add(menuSettings);
menuStrip.BringToFront();
RoundedButton SetUpBlackJackButton()
{
Image normalImage = SettingForm.GetEmbeddedImage("blackjackImg.jpg");
Image grayImage = SettingForm.GetEmbeddedImage("blackjackImgGray.jpg");
RoundedButton blackJackButton = new RoundedButton();
bj = new BlackJack();
blackJackButton.Text = "BlackJack";
blackJackButton.Margin = new Padding(10);
blackJackButton.Height = 345;
blackJackButton.Width = 345;
blackJackButton.FlatStyle = FlatStyle.Flat;
blackJackButton.Font = new Font(UserDataManager.MainFont.Name, UserDataManager.MainFont.Size * 2,FontStyle.Bold);
blackJackButton.Click += (object o, EventArgs e) => {
this.Hide();
bj.FormClosed += (object o, FormClosedEventArgs fcea) =>
{
this.BackColor = UserDataManager.Theme.primaryColor;
this.ForeColor = UserDataManager.Theme.tertiaryColor;
foreach (Control control in this.Controls)
{
}
this.Show();
bj = new BlackJack(); //cheeky dw
};
bj.Show();
};
blackJackButton.MouseEnter += (object o, EventArgs e) =>
{
blackJackButton.Image = grayImage;
};
blackJackButton.MouseLeave += (object o, EventArgs e) =>
{
blackJackButton.Image = normalImage;
};