private void сброситьРешениеToolStripMenuItem_Click(object sender, EventArgs e) { if (!checkStart) { count = 0; checkStart = true; checkSolve = true; timerButton.Checked = false; автоматическийОбходДоскиToolStripMenuItem.Checked = false; timer.Stop(); solve = new WarnsdorfsRule(row, column); chessBoard = new ChessBoard(row, column); coordinates = chessBoard.GetCoordinates; cellColor = chessBoard.GetColors; size = chessBoard.GetCellSize; solve = new WarnsdorfsRule(row, column); pictureBox_Paint(sender, new PaintEventArgs(pictureBox.CreateGraphics(), new Rectangle(pictureBox.Location, pictureBox.Size))); horsePictureBox.Visible = false; moveToolStripStatusLabel.Text = "Ход: " + count.ToString(); } else { MessageBox.Show("Решения, которое можно сбросить, нет!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// сброс решения private void RemoveSolve() { cells = new int[N, N]; game = new WarnsdorfsRule(N, N); count = 0; RemoveKnight(); ReturnColor(); RemoveButtons(); }
List <Button> cellsList; // массив кнопок формы public GameForm() { InitializeComponent(); cells = new int[N, N]; game = new WarnsdorfsRule(N, N); knightImage = new Bitmap(KnightsTour.Properties.Resources.knight); cellsList = new List <Button>(); Add(); ReturnColor(); }
public MainForm() { InitializeComponent(); row = 8; column = 8; startX = 0; startY = 0; chessBoard = new ChessBoard(row, column); coordinates = chessBoard.GetCoordinates; cellColor = chessBoard.GetColors; size = chessBoard.GetCellSize; solve = new WarnsdorfsRule(row, column); horsePictureBox.Visible = false; }
Color[,] cellColor; // массив цветов клеток private void настройкиToolStripMenuItem_Click(object sender, EventArgs e) { stopTimerBitton_Click(sender, e); SettingsForm setting = new SettingsForm(row, column, timer.Interval); setting.ShowDialog(); checkSolve = true; if (setting.CheckChange && count == row * column - 1) { DialogResult result = MessageBox.Show("Алгоритм завершен! Сбросить решение и применить настройки?", "Информация", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { сброситьРешениеToolStripMenuItem_Click(sender, e); } } else if ((row != setting.X || column != setting.Y) && setting.CheckChange && count != row * column - 1 && !checkStart) { DialogResult result = MessageBox.Show("Алгоритм не завершен! Сбросить решение и применить настройки?", "Информация", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { сброситьРешениеToolStripMenuItem_Click(sender, e); } } if (setting.CheckChange && checkStart) { row = setting.X; column = setting.Y; timer.Interval = setting.Intervl; chessBoard = new ChessBoard(row, column); coordinates = chessBoard.GetCoordinates; cellColor = chessBoard.GetColors; size = chessBoard.GetCellSize; solve = new WarnsdorfsRule(row, column); count = 0; checkStart = true; pictureBox_Paint(sender, new PaintEventArgs(pictureBox.CreateGraphics(), new Rectangle(pictureBox.Location, pictureBox.Size))); horsePictureBox.Visible = false; widthToolStripStatusLabel.Text = "Высота: " + row.ToString(); heightToolStripStatusLabel.Text = "Ширина: " + column.ToString(); } else if (row == setting.X && column == setting.Y && !checkStart) { timer.Interval = setting.Intervl; } }