Exemplo n.º 1
0
 public static bool checkField(Form form, Panel gridPanel)
 {
     int redCount = 0;
     int greenCount = 0;
     int yellowCount = 0;
     int blueCount = 0;
     int bonusCount = 0;
     List<CellDTO> cells = new List<CellDTO>(gridPanel.Controls.Count);
     foreach (Control control in gridPanel.Controls) {
         Cell cell = control as Cell;
         CellDTO dto = new CellDTO(cell.BackColor.ToArgb());
         cells.Add(dto);
         switch (cell.BackColor.Name) {
             case "Red": redCount++;
                 break;
             case "Green": greenCount++;
                 break;
             case "Yellow": yellowCount++;
                 break;
             case "Blue": blueCount++;
                 break;
             default:
                 if (cell.BackgroundImage != null && cell.BackgroundImage == Properties.Resources.bonusImg) {
                     bonusCount++;
                 }
                 break;
         }
     }
     if (redCount != 12 || yellowCount != 12 || greenCount != 12 || blueCount != 12 || bonusCount != 1) {
         MessageBox.Show(form, "Неправильно заданы фигуры", "Ошибка", MessageBoxButtons.OK);
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 private void saveFileDialog_FileOk(object sender, CancelEventArgs e)
 {
     var path = saveFileDialog.FileName;
     List<CellDTO> cells = new List<CellDTO>(gridPanel.Controls.Count);
     foreach (Control control in gridPanel.Controls) {
         Cell cell = control as Cell;
         CellDTO dto = new CellDTO(cell.BackColor.ToArgb());
         cells.Add(dto);
     }
     FileUtils.saveToFile(path, cells);
 }