Esempio n. 1
0
        private void beginGameBtn_Click(object sender, EventArgs e)
        {
            List<Cell> cells = new List<Cell>();
            foreach (Control control in gridPanel.Controls) {
                if (control.GetType() == typeof(Cell)) {
                    break;
                }
                Cell cell = new Cell(control.BackColor);
                cells.Add(cell);
            }
            if (cells.Count > 0) {
                gridPanel.Controls.Clear();
                gridPanel.Controls.AddRange(cells.ToArray());
            }
            List<TextBox> commandNameTextBoxes = new List<TextBox>();
            commandNameTextBoxes.Add(command1Name);
            commandNameTextBoxes.Add(command2Name);
            commandNameTextBoxes.Add(command3Name);
            commandNameTextBoxes.Add(command4Name);

            ValidationUtils.validatateCommandNames(this, commandNameTextBoxes, colors);
            if (options.commandNames.Count == 0) {
                return;
            }

            mainTab.SelectedIndex = 1;
            beginGame();
        }
Esempio n. 2
0
 private void openFileDialog_FileOk(object sender, CancelEventArgs e)
 {
     var path = openFileDialog.FileName;
     CellsDTO cellsDTO = FileUtils.readFromFile(path);
     if (cellsDTO == null) {
         MessageBox.Show(this, "Не удалось прочитать файл", "Ошибка", MessageBoxButtons.OK);
         return;
     }
     gridPanel.Controls.Clear();
     foreach (CellDTO cellDTO in cellsDTO.cells) {
         Cell cell = new Cell(Color.FromArgb(cellDTO.color));
         gridPanel.Controls.Add(cell);
     }
     mainTab.SelectedIndex = 2;
 }