public CubesPanel() { this.Dock = DockStyle.Fill; this.ColumnStyles.Insert(0, new ColumnStyle(SizeType.Percent, 30)); this.ColumnStyles.Insert(1, new ColumnStyle(SizeType.Percent, 40)); this.ColumnStyles.Insert(2, new ColumnStyle(SizeType.Percent, 30)); for (int i = 0; i < cubes.Length; i++) { cubes[i] = new PictureBox() { BackgroundImage = Image.FromFile(@"1.jpg"), Dock = DockStyle.Fill, BackgroundImageLayout = ImageLayout.Zoom }; } this.RowCount = 1; this.ColumnCount = 3; this.Controls.Add(cubes[0], 0, 0); this.Controls.Add(cubes[1], 2, 0); AppButton button = new AppButton() { Text = "Бросить кубики", Font = new Font("PF Beausans Pro Light", 15F) }; button.Click += new EventHandler(button_Click); this.Controls.Add(button, 1, 0); this.AutoSize = true; }
public ChanceForm(int currentPlayer, string type) { InitializeComponent(); currentPlayerChip = new Chip() { BackgroundImage = Image.FromFile("chips/" + currentPlayer.ToString() + ".png") }; if (type == CHANCE) { mainFilePath = CHANCE_TASK_FILE_PATH; readAllTasks(CHANCE_TASK_FILE_PATH); double qur = Math.Round(Math.Sqrt((double)tasksButtons.Length), 0, MidpointRounding.AwayFromZero); int sideTableCount = (int)qur; mainTableLayoutPanel.ColumnCount = sideTableCount; mainTableLayoutPanel.RowCount = sideTableCount; for (int i = 0; i < sideTableCount; i++) { mainTableLayoutPanel.ColumnStyles.Insert(i, new ColumnStyle(SizeType.Percent, PERCENT_100 / sideTableCount)); mainTableLayoutPanel.RowStyles.Insert(i, new RowStyle(SizeType.Percent, PERCENT_100 / sideTableCount)); } } else { if (type == LEADER) { mainFilePath = LEADER_TASK_FILE_PATH; readAllTasks(LEADER_TASK_FILE_PATH); } if (type == INFORMATION) { mainFilePath = INFORMATION_TASK_FILE_PATH; readAllTasks(INFORMATION_TASK_FILE_PATH); } if (type == LAW) { mainFilePath = LAW_TASK_FILE_PATH; readAllTasks(LAW_TASK_FILE_PATH); } if (type == DIALOGUE_CULTURES) { mainFilePath = DIALOGUE_CULTURES_TASK_FILE_PATH; readAllTasks(DIALOGUE_CULTURES_TASK_FILE_PATH); } if (type == GOOD) { mainFilePath = GOOD_TASK_FILE_PATH; readAllTasks(GOOD_TASK_FILE_PATH); } if (type == IT) { mainFilePath = IT_TASK_FILE_PATH; readAllTasks(IT_TASK_FILE_PATH); } if (type == CORPORATE) { mainFilePath = CORPORATE_TASK_FILE_PATH; readAllTasks(CORPORATE_TASK_FILE_PATH); } mainTableLayoutPanel.ColumnCount = 1; mainTableLayoutPanel.RowCount = tasksButtons.Length + 1; for (int i = 0; i < mainTableLayoutPanel.RowCount; i++) { mainTableLayoutPanel.RowStyles.Insert(i, new RowStyle(SizeType.Percent, PERCENT_100 / mainTableLayoutPanel.RowCount)); } initializeAnswerPanel(); } for (int i = 0; i < tasksButtons.Length; i++) { tasksButtons[i] = new AppButton() { Font = new Font("PF Beausans Pro Light", 12F), Text = type + " " + (i + 1).ToString(), Size = new Size(50, 50), Dock = DockStyle.Fill, Index = i }; tasksButtons[i].Click += new EventHandler(ChanceForm_Click); } foreach (AppButton b in tasksButtons) { mainTableLayoutPanel.Controls.Add(b); } if (type != CHANCE) { mainTableLayoutPanel.Controls.Add(answerTableLayuotPanel); } mainTableLayoutPanel.Controls.Add(currentPlayerChip); this.Show(); this.FormClosing += ChanceForm_FormClosing; }
private void initializeAnswerPanel() { answerTableLayuotPanel = new TableLayoutPanel() { RowCount = 1, ColumnCount = 2, Dock = DockStyle.Fill, Enabled = false }; for (int i = 0; i < answerTableLayuotPanel.ColumnCount; i++) { answerTableLayuotPanel.ColumnStyles.Insert(i, new ColumnStyle(SizeType.Percent, PERCENT_100 / answerTableLayuotPanel.ColumnCount)); } right = initButtons("Верно!"); wrong = initButtons("Неверно!"); right.Click += right_Click; wrong.Click += wrong_Click; answerTableLayuotPanel.Controls.Add(right); answerTableLayuotPanel.Controls.Add(wrong); }
private AppButton initButtons(string text) { AppButton app = new AppButton() { Text = text }; return app; }
private void createDicesPanel() { dices = new Dice[2]; int[] pair = new int[2]; cubesPanel.Dock = DockStyle.Fill; cubesPanel.ColumnStyles.Insert(0, new ColumnStyle(SizeType.Percent, 30)); cubesPanel.ColumnStyles.Insert(1, new ColumnStyle(SizeType.Percent, 40)); cubesPanel.ColumnStyles.Insert(2, new ColumnStyle(SizeType.Percent, 30)); for (int i = 0; i < dices.Length; i++) { dices[i] = new Dice() { BackgroundImage = Image.FromFile(@"1.jpg"), Dock = DockStyle.Fill, BackgroundImageLayout = ImageLayout.Zoom }; } cubesPanel.RowCount = 1; cubesPanel.ColumnCount = 3; cubesPanel.Controls.Add(dices[0], 0, 0); cubesPanel.Controls.Add(dices[1], 2, 0); AppButton rollDicesButton = new AppButton() { Text = "Бросить кубики", Font = new Font("PF Beausans Pro Light", 10F) }; rollDicesButton.Click += new EventHandler(rollDicesButton_Click); cubesPanel.Controls.Add(rollDicesButton, 1, 0); cubesPanel.AutoSize = true; }