aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2022-12-25 07:36:47 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2022-12-25 07:36:47 +0100
commit887a4dc38da11fbe3f90666084ad59a2321e3202 (patch)
tree60a7884231eb21d886c52225e83f30ab0a03f485 /src
parentb31d80d50c53a1c612dcc6405509b1c999b5f592 (diff)
Diffstat (limited to 'src')
-rw-r--r--src/VkChess.cs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/VkChess.cs b/src/VkChess.cs
index 3c8cb11..d2af859 100644
--- a/src/VkChess.cs
+++ b/src/VkChess.cs
@@ -38,7 +38,7 @@ namespace vkChess
}
public CommandGroup Commands, IconBar;
- public Command CMDUndo, CMDOptions, CMDViewBoard, CMDViewMoves, CMDLoadSelectedFile;
+ public Command CMDUndo, CMDOptions, CMDViewBoard, CMDViewMoves, CMDLoadSelectedFile, CMDDeleteSelectedFile;
public ToggleCommand CMDToggleHint;
void initCommands () {
CMDUndo = new ActionCommand ("Undo", () => undo(), "#icons.undo.svg");
@@ -46,6 +46,7 @@ namespace vkChess
CMDViewMoves = new ActionCommand ("Moves", () => loadWindow ("#ui.winMoves.crow", this), "#icons.moves.svg");
CMDViewBoard = new ActionCommand ("Mini Board", () => loadWindow ("#ui.winBoard.crow", this), "#icons.board.svg");
CMDLoadSelectedFile = new ActionCommand ("Load", () => loadGameFromFile (selectedSavedGame), "#icons.load.svg");
+ CMDDeleteSelectedFile = new ActionCommand ("Delete", () => deleteSavedGame (selectedSavedGame), "#icons.warning.svg");
CMDToggleHint = new ToggleCommand (this, "Hint", new Binding<bool> ("EnableHint"), "#icons.hint.svg", null, true);
IconBar = new CommandGroup (CMDOptions, CMDViewBoard, CMDViewMoves, CMDUndo, CMDToggleHint);
@@ -53,7 +54,7 @@ namespace vkChess
Commands = new CommandGroup (
new CommandGroup ("Menu",
new ActionCommand ("New Game", () => loadWindow ("#ui.winNewGame.crow", this), "#icons.flag.svg"),
- new ActionCommand ("Save", () => loadWindow ("#ui.save.crow", this), "#icons.save.svg"),
+ new ActionCommand ("Save", () => saveGame(), "#icons.save.svg"),
new ActionCommand ("Load", () => loadWindow ("#ui.winLoad.crow", this), "#icons.load.svg"),
CMDOptions,
CMDViewBoard,
@@ -1071,15 +1072,27 @@ namespace vkChess
using (Stream stream = new FileStream (filePath, FileMode.Create))
using (StreamWriter sw = new StreamWriter (stream))
sw.WriteLine (stockfishPositionCommand);
+ loadWindow("#ui.winMessage.crow", (object)$"Game saved as: {fileName}");
+ new System.Threading.Thread(()=> {
+ System.Threading.Thread.Sleep(4000);
+ closeWindow("#ui.winMessage.crow");
+ }).Start();
}
void loadGameFromFile (string fullPath) {
- closeWindow ("#ui.winBoard.crow");
- if (string.IsNullOrEmpty (fullPath) && !File.Exists (fullPath))
+ closeWindow ("#ui.winLoad.crow");
+ if (!File.Exists (fullPath))
return;
using (Stream stream = new FileStream (fullPath, FileMode.Open))
using (StreamReader sw = new StreamReader (stream))
loadGameFromPositionString (sw.ReadLine ());
}
+ void deleteSavedGame (string fullPath) {
+ if (!File.Exists (fullPath))
+ return;
+ File.Delete(fullPath);
+ NotifyValueChanged("SavedGames",SavedGames);
+ }
+
void saveOpenedWindowConfig () {
StringBuilder sb = new StringBuilder(100);
foreach (Window win in iFace.GraphicTree.OfType<Window>())