private async void SaveAsync() { bool res = false; editingOn = false; SaveButton.Text = "Solving"; SaveButton.Enabled = false; gridIm.SolvingAllowed = true; await Task.Run(() => { res = gridIm.Solve(); }); if (gridIm.SolvingAllowed) { if (!res) { MessageBox.Show(russian ? "Данную сетку невозможно решить" : "This grid is unsolvable", "Circular Route"); editingOn = true; SaveButton.Text = "Save"; SaveButton.Enabled = true; return; } GridPanel.BringToFront(); UpdateGridPanel(); using (SaveFileDialog sf = new SaveFileDialog()) { sf.FileName = "grid"; sf.Filter = "Grid direction file (*.crdir)|*.crdir"; if (sf.ShowDialog() == DialogResult.OK) { gridIm.SaveDirections(sf.FileName); MessageBox.Show(russian ? "Сохранено!" : "Saved", "Circular Route"); editingOn = false; SetSideButtonsEnabled(true); SaveButton.Hide(); CancelCreatingButton.Hide(); ResetPicDir(); } else { DirPanel.BringToFront(); editingOn = true; } SaveButton.Text = "Save"; SaveButton.Enabled = true; } } }
private void BeginSolving() { gridIm.ResetPos(); gridIm.Grid[0, 0] = 41; editingOn = true; SetSideButtonsEnabled(false); UpdateGridPanel(); CancelSolvingButton.Show(); GiveUpButton.Show(); GridPanel.BringToFront(); SetArrowButtonsEnabled(true); GridPanel.Focus(); TimerCounter.Enabled = true; }