private void CancelCreatingButton_Click(object sender, EventArgs e) { gridIm.SolvingAllowed = false; editingOn = false; SetSideButtonsEnabled(true); SaveButton.Hide(); CancelCreatingButton.Hide(); SaveButton.Text = "Save"; SaveButton.Enabled = true; ResetPicDir(); }
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; } } }
/// <summary> /// Initializes the form /// </summary> /// <param name="side">The side of the grid</param> /// <param name="russian">True if the text should be in russian</param> public void Initialize(int side, bool russian) { CenterToScreen(); gameActive = false; editingOn = false; SetSideButtonsEnabled(true); this.russian = russian; this.side = side; ResetTimer(); if (side == 6) { Size = new Size(816 + 10, 489 + 10); } else { Size = new Size(926 + 10, 579 + 10); } UpdateName(); if (russian) { CreateGridButton.Text = "Создать свое поле"; LoadGridButton.Text = "Загрузить"; RandomButton.Text = "Случайное поле"; ChangeNameButton.Text = "Поменять имя"; LeaderboardsButton.Text = "Рекорды"; CloseButton.Text = "Закрыть"; ControlTipLabel.Text = "Подсказка управления:\nВы можете использовать кнопки направления на вашей клавиатуре или кнопки снизу чтобы выстраивать ваш маршрут."; GiveUpButton.Text = "Сдаться"; CancelSolvingButton.Text = "Отмена"; } else { CreateGridButton.Text = "Create your grid"; LoadGridButton.Text = "Load"; RandomButton.Text = "Solve random"; ChangeNameButton.Text = "Change Name"; LeaderboardsButton.Text = "Leaderoards"; CloseButton.Text = "Close"; ControlTipLabel.Text = "Control tip:\nYou can use the arrow keys on your keyboard or the arrow buttons down below to navigate your route."; GiveUpButton.Text = "Give up"; CancelSolvingButton.Text = "Cancel"; } try { leaders6 = PlayerInfo.Load(leaderboards6Path); } catch (IOException) { leaders6 = new List <PlayerInfo> { new PlayerInfo("Bob", 6, 300) }; PlayerInfo.Save(leaders6, leaderboards6Path); } try { leaders8 = PlayerInfo.Load(leaderboards8Path); } catch (IOException) { leaders8 = new List <PlayerInfo> { new PlayerInfo("Bob", 8, 600) }; PlayerInfo.Save(leaders8, leaderboards8Path); } SetArrowButtonsEnabled(false); SaveButton.Hide(); CancelCreatingButton.Hide(); CancelSolvingButton.Hide(); GiveUpButton.Hide(); FillPanel(); ShowDialog(); }