aboutsummaryrefslogtreecommitdiffstatsci
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
parentb31d80d50c53a1c612dcc6405509b1c999b5f592 (diff)
-rw-r--r--src/VkChess.cs21
-rw-r--r--ui/winLoad.crow7
-rw-r--r--ui/winMessage.crow11
3 files changed, 33 insertions, 6 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>())
diff --git a/ui/winLoad.crow b/ui/winLoad.crow
index b3e4ebf..e4512c7 100644
--- a/ui/winLoad.crow
+++ b/ui/winLoad.crow
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<Window Caption="Saved Games" Width="80%" Height="80%" Icon="#icons.load.svg" >
- <VerticalStack>
+ <VerticalStack Margin="5">
<ListBox Data="{SavedGames}" SelectedItem="{²SelectedSavedGame}">
<Template>
<Wrapper Name="ItemsContainer"/>
@@ -13,7 +13,10 @@
</ListItem>
</ItemTemplate>
</ListBox>
- <Button Command="{CMDLoadSelectedFile}"/>
+ <HorizontalStack Spacing="0" Width="50%" HorizontalAlignment="Right" Background="Jet">
+ <Button Command="{CMDLoadSelectedFile}" Width="50%"/>
+ <Button Command="{CMDDeleteSelectedFile}" Width="50%"/>
+ </HorizontalStack>
</VerticalStack>
</Window>
diff --git a/ui/winMessage.crow b/ui/winMessage.crow
new file mode 100644
index 0000000..a72a007
--- /dev/null
+++ b/ui/winMessage.crow
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Container Fit="true">
+ <Border CornerRadius="15" Background="${WindowBackground}">
+ <Label Text="{}" Margin="40"
+ Foreground="White"
+ Font="serif bold, 28"
+ Width="Stretched"
+ TextAlignment="Center"/>
+ </Border>
+</Container>
+