public GameMenu(string subtitle = "", params string[] buttonTexts) { InitializeComponent(); this.BackColor = Resources.Colors.Background; Label title = new Label(); title.Text = "Game Over"; title.Location = new Point(border, border); title.Font = new Font("Arial", 25, FontStyle.Bold); title.ForeColor = Resources.Colors.PrimaryText; this.Controls.Add(title); title.AutoSize = true; Label subtitleLabel = new Label(); if (subtitle != "" && subtitle != null) { subtitleLabel.Text = subtitle; subtitleLabel.Location = new Point(border, 2 * border + title.Height); subtitleLabel.Font = new Font("Arial", 14); subtitleLabel.ForeColor = Resources.Colors.PrimaryText; subtitleLabel.TextAlign = ContentAlignment.MiddleCenter; this.Controls.Add(subtitleLabel); subtitleLabel.AutoSize = true; Size size = new Size(title.Size.Width, subtitleLabel.Size.Height); subtitleLabel.AutoSize = false; subtitleLabel.Size = size; } else { subtitleLabel.Size = new Size(0, 0); } buttonSize.Width = title.Width; int y = border + title.Size.Height + subtitleLabel.Size.Height + (subtitleLabel.Size.Height == 0?0:2 * border); foreach (string text in buttonTexts) { Button button = new Resources.CustomButton(); button.Text = text; button.Font = new Font("Arial", 12, FontStyle.Bold); button.Location = new Point(border, border + y); button.Size = buttonSize; button.Click += OnButtonClick; y += buttonSize.Height + border; buttons.Add(button); this.Controls.Add(button); } this.TopLevel = false; this.FormBorderStyle = FormBorderStyle.None; ContentSize = new Size(title.Width + 2 * border, title.Size.Height + subtitleLabel.Height + (subtitleLabel.Size.Height == 0 ? 0 : 2 * border) + ((2 + buttons.Count) * border) + (buttonTexts.Length * buttonSize.Height)); }
private void CreateButton(Panel panel, string text, EventHandler onClick) { Resources.CustomButton button = new Resources.CustomButton(); button.Text = text; button.Font = new Font("Arial", 12, FontStyle.Bold); button.BackColor = Resources.Colors.ContainterBackground; button.ForeColor = Resources.Colors.PrimaryText; button.FlatStyle = new FlatStyle(); button.FlatAppearance.BorderSize = 0; button.Click += onClick; button.Size = buttonSize; panel.Controls.Add(button); button.Location = new Point(0, panel.Height); panel.Height += buttonSize.Height + padding; }
public Statistics() : base() { InitializeComponent(); this.DoubleBuffered = true; this.BackColor = Resources.Colors.Background; Button backButton = new Resources.CustomButton(); backButton.Location = new Point(0, 0); backButton.Size = new Size(headerHeight, headerHeight); backButton.Text = "❮"; backButton.Font = new Font("Arial", 20, FontStyle.Bold); backButton.Click += backButtonClick; this.Controls.Add(backButton); Font titleFont = new Font("Arial", 20, FontStyle.Bold); Font font = new Font("Arial", 12); texts = new List <String>(); try { //2048 texts.Add(new String("2048", titleFont, Resources.Colors.PrimaryText, 10)); texts.Add(new String($"Rekord: {Database.GameClients.Game2048Client.Highscore}", font, Resources.Colors.PrimaryText, 5)); texts.Add(new String($"Megnyert játékok: {Database.GameClients.Game2048Client.GamesWon}", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játékidő: {Database.GameClients.Game2048Client.Playtime / 60} perc", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játszott játékok: {Database.GameClients.Game2048Client.GamesPlayed}", font, Resources.Colors.PrimaryText)); //Tetris texts.Add(new String("Tetris", titleFont, Resources.Colors.PrimaryText, 30)); texts.Add(new String($"Rekord: {Database.GameClients.TetrisClient.Highscore}", font, Resources.Colors.PrimaryText, 5)); texts.Add(new String($"Törölt sorok: {Database.GameClients.TetrisClient.LinesCleared}", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játékidő: {Database.GameClients.TetrisClient.Playtime / 60} perc", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játszott játékok: {Database.GameClients.TetrisClient.GamesPlayed}", font, Resources.Colors.PrimaryText)); //Minesweeper texts.Add(new String("Aknakereső", titleFont, Resources.Colors.PrimaryText, 30)); texts.Add(new String($"Legjobb idő: {Database.GameClients.MinesweeperClient.Highscore}", font, Resources.Colors.PrimaryText, 5)); texts.Add(new String($"Megnyert játékok: {Database.GameClients.MinesweeperClient.GamesWon}", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Felfedezett mezők: {Database.GameClients.MinesweeperClient.SquaresDiscovered}", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Lerakott zászlók: {Database.GameClients.MinesweeperClient.FlagsPlaced}", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játékidő: {Database.GameClients.MinesweeperClient.Playtime / 60} perc", font, Resources.Colors.PrimaryText)); texts.Add(new String($"Játszott játékok: {Database.GameClients.MinesweeperClient.GamesPlayed}", font, Resources.Colors.PrimaryText)); } catch { texts.Clear(); texts.Add(new String("Hiba történt az adatok lekérdezése közben", titleFont, Resources.Colors.PrimaryText, 20)); } }