Преглед изворни кода

Refactor: migrate window-related commands to `WindowViewModel`. Update bindings across views, remove redundant commands from `MainViewModel` and `ToolsViewModel`, and streamline command organization.

Ruben пре 3 месеци
родитељ
комит
0a20010d0a

+ 17 - 17
src/PicView.Avalonia.MacOS/Views/MacMainWindow.axaml

@@ -25,12 +25,12 @@
             <NativeMenuItem Header="{CompiledBinding Translation.File.Value}">
             <NativeMenuItem Header="{CompiledBinding Translation.File.Value}">
                 <NativeMenu>
                 <NativeMenu>
                     <NativeMenuItem Command="{CompiledBinding Tools.OpenFileCommand}" Header="{CompiledBinding Translation.Open.Value, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding Tools.OpenFileCommand}" Header="{CompiledBinding Translation.Open.Value, Mode=OneWay}" />
-                    <!--  <NativeMenuItem  -->
-                    <!--  Command="{CompiledBinding OpenWithCommand}"  -->
-                    <!--  CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,  -->
-                    <!--  FallbackValue=''}"  -->
-                    <!--  Header="{CompiledBinding Translation.OpenWith,  -->
-                    <!--  Mode=OneWay}" />  -->
+                    <NativeMenuItem
+                        Command="{CompiledBinding Tools.OpenWithCommand}"
+                        CommandParameter="{CompiledBinding PicViewer.FileInfo.Value.FullName,
+                                                           FallbackValue=''}"
+                        Header="{CompiledBinding Translation.OpenWith,
+                                                 Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding Tools.SaveFileCommand}" Header="{CompiledBinding Translation.Save.Value, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding Tools.SaveFileCommand}" Header="{CompiledBinding Translation.Save.Value, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding Tools.SaveFileAsCommand}" Header="{CompiledBinding Translation.SaveAs.Value, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding Tools.SaveFileAsCommand}" Header="{CompiledBinding Translation.SaveAs.Value, Mode=OneWay}" />
                     <NativeMenuItem
                     <NativeMenuItem
@@ -67,7 +67,7 @@
                                                  Mode=OneWay}"
                                                  Mode=OneWay}"
                         IsEnabled="{CompiledBinding PicViewer.ImageSource.Value,
                         IsEnabled="{CompiledBinding PicViewer.ImageSource.Value,
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
-                    <NativeMenuItem Command="{CompiledBinding NewWindowCommand}" Header="{CompiledBinding Translation.NewWindow.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.NewWindow}" Header="{CompiledBinding Translation.NewWindow.Value, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
                     <NativeMenuItem
                     <NativeMenuItem
                         Command="{CompiledBinding Tools.RenameCommand}"
                         Command="{CompiledBinding Tools.RenameCommand}"
@@ -155,7 +155,7 @@
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowExifWindowCommand}" Header="{CompiledBinding Translation.ImageInfo.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowExifWindow}" Header="{CompiledBinding Translation.ImageInfo.Value, Mode=OneWay}" />
                     <NativeMenuItem
                     <NativeMenuItem
                         Command="{CompiledBinding Tools.FilePropertiesCommand}"
                         Command="{CompiledBinding Tools.FilePropertiesCommand}"
                         CommandParameter="{CompiledBinding PicViewer.FileInfo.Value.FullName,
                         CommandParameter="{CompiledBinding PicViewer.FileInfo.Value.FullName,
@@ -165,8 +165,8 @@
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowSingleImageResizeWindowCommand}" Header="{CompiledBinding Translation.ResizeImage.Value, Mode=OneWay}" />
-                    <NativeMenuItem Command="{CompiledBinding ShowBatchResizeWindowCommand}" Header="{CompiledBinding Translation.BatchResize.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowSingleImageResizeWindow}" Header="{CompiledBinding Translation.ResizeImage.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowBatchResizeWindow}" Header="{CompiledBinding Translation.BatchResize.Value, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
                     <NativeMenuItem
                     <NativeMenuItem
                         Command="{CompiledBinding OptimizeImageCommand}"
                         Command="{CompiledBinding OptimizeImageCommand}"
@@ -177,7 +177,7 @@
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                         IsEnabled="{CompiledBinding PicViewer.FileInfo.Value,
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                                                     Converter={x:Static ObjectConverters.IsNotNull}}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowEffectsWindowCommand}" Header="{CompiledBinding Translation.Effects.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowEffectsWindow}" Header="{CompiledBinding Translation.Effects.Value, Mode=OneWay}" />
                 </NativeMenu>
                 </NativeMenu>
             </NativeMenuItem>
             </NativeMenuItem>
 
 
@@ -206,7 +206,7 @@
             <!--  Interface configuration  -->
             <!--  Interface configuration  -->
             <NativeMenuItem Header="{CompiledBinding Translation.InterfaceConfiguration.Value, Mode=OneWay}">
             <NativeMenuItem Header="{CompiledBinding Translation.InterfaceConfiguration.Value, Mode=OneWay}">
                 <NativeMenu>
                 <NativeMenu>
-                    <NativeMenuItem Command="{CompiledBinding ToggleFullscreenCommand}" Header="{CompiledBinding Translation.ToggleFullscreen.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding MainWindow.ToggleFullscreenCommand}" Header="{CompiledBinding Translation.ToggleFullscreen.Value, Mode=OneWay}" />
                     <NativeMenuItem
                     <NativeMenuItem
                         Command="{CompiledBinding ChangeAutoFitCommand}"
                         Command="{CompiledBinding ChangeAutoFitCommand}"
                         Header="{CompiledBinding Translation.AutoFitWindow.Value,
                         Header="{CompiledBinding Translation.AutoFitWindow.Value,
@@ -311,21 +311,21 @@
                         IsChecked="{CompiledBinding GlobalSettings.IsIncludingSubdirectories.Value}"
                         IsChecked="{CompiledBinding GlobalSettings.IsIncludingSubdirectories.Value}"
                         ToggleType="CheckBox" />
                         ToggleType="CheckBox" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowKeybindingsWindowCommand}" Header="{CompiledBinding Translation.ApplicationShortcuts.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowKeybindingsWindow}" Header="{CompiledBinding Translation.ApplicationShortcuts.Value, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowAboutWindowCommand}" Header="{CompiledBinding Translation.About.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowAboutWindow}" Header="{CompiledBinding Translation.About.Value, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding ShowSettingsWindowCommand}" Header="{CompiledBinding Translation.ShowAllSettingsWindow.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.ShowSettingsWindow}" Header="{CompiledBinding Translation.ShowAllSettingsWindow.Value, Mode=OneWay}" />
                 </NativeMenu>
                 </NativeMenu>
             </NativeMenuItem>
             </NativeMenuItem>
 
 
             <!--  Window  -->
             <!--  Window  -->
             <NativeMenuItem Header="{CompiledBinding Translation.Window.Value, Mode=OneWay}">
             <NativeMenuItem Header="{CompiledBinding Translation.Window.Value, Mode=OneWay}">
                 <NativeMenu>
                 <NativeMenu>
-                    <NativeMenuItem Command="{CompiledBinding NewWindowCommand}" Header="{CompiledBinding Translation.NewWindow.Value, Mode=OneWay, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding Window.NewWindow}" Header="{CompiledBinding Translation.NewWindow.Value, Mode=OneWay, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <NativeMenuItemSeparator />
                     <NativeMenuItem Command="{CompiledBinding MainWindow.MaximizeCommand}" Header="{CompiledBinding Translation.Maximize.Value, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding MainWindow.MaximizeCommand}" Header="{CompiledBinding Translation.Maximize.Value, Mode=OneWay}" />
-                    <NativeMenuItem Command="{CompiledBinding ToggleFullscreenCommand}" Header="{CompiledBinding Translation.Fullscreen.Value, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding MainWindow.ToggleFullscreenCommand}" Header="{CompiledBinding Translation.Fullscreen.Value, Mode=OneWay}" />
                 </NativeMenu>
                 </NativeMenu>
             </NativeMenuItem>
             </NativeMenuItem>
 
 

+ 2 - 2
src/PicView.Avalonia.Win32/Views/WinTitleBar.axaml

@@ -162,7 +162,7 @@
                 BorderThickness="0,0,1,0"
                 BorderThickness="0,0,1,0"
                 Classes="hover"
                 Classes="hover"
                 ClickMode="Release"
                 ClickMode="Release"
-                Command="{CompiledBinding ToggleFullscreenCommand}"
+                Command="{CompiledBinding MainWindow.ToggleFullscreenCommand}"
                 Data="{StaticResource FullscreenGeometry}"
                 Data="{StaticResource FullscreenGeometry}"
                 DockPanel.Dock="Right"
                 DockPanel.Dock="Right"
                 Foreground="{DynamicResource MainTextColor}"
                 Foreground="{DynamicResource MainTextColor}"
@@ -179,7 +179,7 @@
                 BorderBrush="{DynamicResource MainBorderColor}"
                 BorderBrush="{DynamicResource MainBorderColor}"
                 BorderThickness="0,0,1,0"
                 BorderThickness="0,0,1,0"
                 Classes="hover"
                 Classes="hover"
-                Command="{CompiledBinding RestoreCommand}"
+                Command="{CompiledBinding MainWindow.RestoreCommand}"
                 Data="{StaticResource RestoreGeometry}"
                 Data="{StaticResource RestoreGeometry}"
                 DockPanel.Dock="Right"
                 DockPanel.Dock="Right"
                 Foreground="{DynamicResource MainTextColor}"
                 Foreground="{DynamicResource MainTextColor}"

+ 1 - 36
src/PicView.Avalonia/ViewModels/MainViewModel.cs

@@ -5,7 +5,6 @@ using PicView.Avalonia.Functions;
 using PicView.Avalonia.ImageTransformations.Rotation;
 using PicView.Avalonia.ImageTransformations.Rotation;
 using PicView.Avalonia.Interfaces;
 using PicView.Avalonia.Interfaces;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.UI;
-using PicView.Core.ProcessHandling;
 using PicView.Core.ViewModels;
 using PicView.Core.ViewModels;
 using ReactiveUI;
 using ReactiveUI;
 using ImageViewer = PicView.Avalonia.Views.ImageViewer;
 using ImageViewer = PicView.Avalonia.Views.ImageViewer;
@@ -19,6 +18,7 @@ public class MainViewModel : ReactiveObject
     
     
     public TranslationViewModel Translation { get; } = new();
     public TranslationViewModel Translation { get; } = new();
     public MainWindowViewModel MainWindow { get; } = new();
     public MainWindowViewModel MainWindow { get; } = new();
+    public WindowViewModel Window { get; } = new();
     public GlobalSettingsViewModel GlobalSettings { get; } = new();
     public GlobalSettingsViewModel GlobalSettings { get; } = new();
     public SettingsViewModel? SettingsViewModel { get; set; }
     public SettingsViewModel? SettingsViewModel { get; set; }
     public ImageCropperViewModel? Crop { get; set; }
     public ImageCropperViewModel? Crop { get; set; }
@@ -36,23 +36,6 @@ public class MainViewModel : ReactiveObject
         PlatformService = platformSpecificService;
         PlatformService = platformSpecificService;
         PlatformWindowService = platformWindowService;
         PlatformWindowService = platformWindowService;
 
 
-        #region Window commands
-
-        RestoreCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Restore);
-        ToggleFullscreenCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleFullscreen);
-        NewWindowCommand = FunctionsHelper.CreateReactiveCommand(ProcessHelper.StartNewProcess);
-
-        ShowExifWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowExifWindow);
-        ShowSettingsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowSettingsWindow);
-        ShowKeybindingsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowKeybindingsWindow);
-        ShowAboutWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowAboutWindow);
-        ShowBatchResizeWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowBatchResizeWindow);
-        ShowSingleImageResizeWindowCommand =
-            FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowSingleImageResizeWindow);
-        ShowEffectsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowEffectsWindow);
-
-        #endregion Window commands
-
 
 
 
 
         #region Image commands
         #region Image commands
@@ -129,10 +112,6 @@ public class MainViewModel : ReactiveObject
         RestartCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Restart);
         RestartCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Restart);
         
         
         ToggleOpeningInSameWindowCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleOpeningInSameWindow);
         ToggleOpeningInSameWindowCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleOpeningInSameWindow);
-        
-        ShowSettingsFileCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ShowSettingsFile);
-        
-        ShowKeybindingsFileCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ShowKeybindingsFile);
 
 
         #endregion Settings commands
         #endregion Settings commands
     }
     }
@@ -143,9 +122,6 @@ public class MainViewModel : ReactiveObject
     }
     }
 
 
     #region Commands
     #region Commands
-    public ReactiveCommand<Unit, Unit>? RestoreCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ToggleFullscreenCommand { get; }
-    public ReactiveCommand<Unit, Unit>? NewWindowCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleLoopingCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleLoopingCommand { get; }
     public ReactiveCommand<Unit, Unit>? RotateLeftCommand { get; }
     public ReactiveCommand<Unit, Unit>? RotateLeftCommand { get; }
     public ReactiveCommand<Unit, Unit>? RotateLeftButtonCommand { get; }
     public ReactiveCommand<Unit, Unit>? RotateLeftButtonCommand { get; }
@@ -166,13 +142,6 @@ public class MainViewModel : ReactiveObject
 
 
     public ReactiveCommand<Unit, Unit>? ToggleFadeInButtonsOnHoverCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleFadeInButtonsOnHoverCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleTaskbarProgressCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleTaskbarProgressCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowExifWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowAboutWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowSettingsWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowKeybindingsWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowBatchResizeWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowSingleImageResizeWindowCommand { get; }
-    public ReactiveCommand<Unit, Unit>? ShowEffectsWindowCommand { get; }
 
 
     public ReactiveCommand<Unit, Unit>? OptimizeImageCommand { get; }
     public ReactiveCommand<Unit, Unit>? OptimizeImageCommand { get; }
 
 
@@ -186,10 +155,6 @@ public class MainViewModel : ReactiveObject
 
 
     public ReactiveCommand<Unit, Unit>? RestartCommand { get; }
     public ReactiveCommand<Unit, Unit>? RestartCommand { get; }
     
     
-    public ReactiveCommand<Unit, Unit>? ShowSettingsFileCommand { get; }
-    
-    public ReactiveCommand<Unit, Unit>? ShowKeybindingsFileCommand { get; }
-    
     public ReactiveCommand<Unit, Unit>? ToggleConstrainBackgroundColorCommand { get; }
     public ReactiveCommand<Unit, Unit>? ToggleConstrainBackgroundColorCommand { get; }
 
 
     #endregion Commands
     #endregion Commands

+ 10 - 0
src/PicView.Avalonia/ViewModels/MainWindowViewModel.cs

@@ -104,6 +104,16 @@ public class MainWindowViewModel : IDisposable
         await WindowFunctions.Minimize();
         await WindowFunctions.Minimize();
     });
     });
     
     
+    public ReactiveCommand RestoreCommand { get; } = new(async (_, _) =>
+    {
+        await FunctionsMapper.Restore();
+    });
+    
+    public ReactiveCommand ToggleFullscreenCommand { get; } = new(async (_, _) =>
+    {
+        await FunctionsMapper.ToggleFullscreen();
+    });
+    
 
 
     private void SetButtonValues()
     private void SetButtonValues()
     {
     {

+ 9 - 8
src/PicView.Avalonia/ViewModels/ToolsViewModel.cs

@@ -12,6 +12,15 @@ namespace PicView.Avalonia.ViewModels;
 
 
 public class ToolsViewModel : IDisposable
 public class ToolsViewModel : IDisposable
 {
 {
+    public ReactiveCommand ShowSettingsFileCommand { get; } = new(async (_, _) =>
+    {
+        await FunctionsMapper.ShowSettingsFile();
+    });
+        
+    public ReactiveCommand ShowKeybindingsFileCommand { get; } = new(async (_, _) =>
+    {
+        await FunctionsMapper.ShowSettingsFile();
+    });
     
     
     // Open related
     // Open related
     public ReactiveCommand OpenFileCommand { get; } = new(async (_, _) =>
     public ReactiveCommand OpenFileCommand { get; } = new(async (_, _) =>
@@ -121,14 +130,6 @@ public class ToolsViewModel : IDisposable
         await ClipboardTextOperations.CopyTextToClipboard(path).ConfigureAwait(false);
         await ClipboardTextOperations.CopyTextToClipboard(path).ConfigureAwait(false);
     });
     });
     
     
-    public ReactiveCommand<string> CutCommand { get; } = new(async (path, _) =>
-    {
-        if (UIHelper.GetMainView.DataContext is MainViewModel vm)
-        {
-            await ClipboardFileOperations.CutFile(path, vm).ConfigureAwait(false);
-        }
-    });
-    
     public ReactiveCommand<string> CopyBase64Command { get; } = new(async (path, _) =>
     public ReactiveCommand<string> CopyBase64Command { get; } = new(async (path, _) =>
     {
     {
         if (UIHelper.GetMainView.DataContext is MainViewModel vm)
         if (UIHelper.GetMainView.DataContext is MainViewModel vm)

+ 65 - 0
src/PicView.Avalonia/ViewModels/WindowViewModel.cs

@@ -0,0 +1,65 @@
+using PicView.Avalonia.UI;
+using PicView.Core.ProcessHandling;
+
+namespace PicView.Avalonia.ViewModels;
+
+public class WindowViewModel
+{
+    public void NewWindow() => ProcessHelper.StartNewProcess();
+    
+    public void ShowExifWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowExifWindow();
+        }
+    }
+
+    public void ShowSettingsWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowSettingsWindow();
+        }
+    }
+
+    public void ShowKeybindingsWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowKeybindingsWindow();
+        }
+    }
+
+    public void ShowAboutWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowAboutWindow();
+        }
+    }
+
+    public void ShowBatchResizeWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowBatchResizeWindow();
+        }
+    }
+
+    public void ShowSingleImageResizeWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowSingleImageResizeWindow();
+        }
+    }
+
+    public void ShowEffectsWindow()
+    {
+        if (UIHelper.TryGetMainViewModel(out var vm))
+        {
+            vm.PlatformWindowService.ShowEffectsWindow();
+        }
+    }
+}

+ 6 - 6
src/PicView.Avalonia/Views/MainView.axaml

@@ -495,7 +495,7 @@
                 <Separator />
                 <Separator />
 
 
                 <!--  Show Settings window  -->
                 <!--  Show Settings window  -->
-                <MenuItem Command="{CompiledBinding ShowSettingsWindowCommand}" Header="{CompiledBinding Translation.ShowAllSettingsWindow.Value, Mode=OneWay}">
+                <MenuItem Command="{CompiledBinding Window.ShowSettingsWindow}" Header="{CompiledBinding Translation.ShowAllSettingsWindow.Value, Mode=OneWay}">
                     <MenuItem.Icon>
                     <MenuItem.Icon>
                         <Path
                         <Path
                             Data="M262.29 192.31a64 64 0 1057.4 57.4 64.13 64.13 0 00-57.4-57.4zM416.39 256a154.34 154.34 0 01-1.53 20.79l45.21 35.46a10.81 10.81 0 012.45 13.75l-42.77 74a10.81 10.81 0 01-13.14 4.59l-44.9-18.08a16.11 16.11 0 00-15.17 1.75A164.48 164.48 0 01325 400.8a15.94 15.94 0 00-8.82 12.14l-6.73 47.89a11.08 11.08 0 01-10.68 9.17h-85.54a11.11 11.11 0 01-10.69-8.87l-6.72-47.82a16.07 16.07 0 00-9-12.22 155.3 155.3 0 01-21.46-12.57 16 16 0 00-15.11-1.71l-44.89 18.07a10.81 10.81 0 01-13.14-4.58l-42.77-74a10.8 10.8 0 012.45-13.75l38.21-30a16.05 16.05 0 006-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 00-6.07-13.94l-38.19-30A10.81 10.81 0 0149.48 186l42.77-74a10.81 10.81 0 0113.14-4.59l44.9 18.08a16.11 16.11 0 0015.17-1.75A164.48 164.48 0 01187 111.2a15.94 15.94 0 008.82-12.14l6.73-47.89A11.08 11.08 0 01213.23 42h85.54a11.11 11.11 0 0110.69 8.87l6.72 47.82a16.07 16.07 0 009 12.22 155.3 155.3 0 0121.46 12.57 16 16 0 0015.11 1.71l44.89-18.07a10.81 10.81 0 0113.14 4.58l42.77 74a10.8 10.8 0 01-2.45 13.75l-38.21 30a16.05 16.05 0 00-6.05 14.08c.33 4.14.55 8.3.55 12.47z"
                             Data="M262.29 192.31a64 64 0 1057.4 57.4 64.13 64.13 0 00-57.4-57.4zM416.39 256a154.34 154.34 0 01-1.53 20.79l45.21 35.46a10.81 10.81 0 012.45 13.75l-42.77 74a10.81 10.81 0 01-13.14 4.59l-44.9-18.08a16.11 16.11 0 00-15.17 1.75A164.48 164.48 0 01325 400.8a15.94 15.94 0 00-8.82 12.14l-6.73 47.89a11.08 11.08 0 01-10.68 9.17h-85.54a11.11 11.11 0 01-10.69-8.87l-6.72-47.82a16.07 16.07 0 00-9-12.22 155.3 155.3 0 01-21.46-12.57 16 16 0 00-15.11-1.71l-44.89 18.07a10.81 10.81 0 01-13.14-4.58l-42.77-74a10.8 10.8 0 012.45-13.75l38.21-30a16.05 16.05 0 006-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 00-6.07-13.94l-38.19-30A10.81 10.81 0 0149.48 186l42.77-74a10.81 10.81 0 0113.14-4.59l44.9 18.08a16.11 16.11 0 0015.17-1.75A164.48 164.48 0 01187 111.2a15.94 15.94 0 008.82-12.14l6.73-47.89A11.08 11.08 0 01213.23 42h85.54a11.11 11.11 0 0110.69 8.87l6.72 47.82a16.07 16.07 0 009 12.22 155.3 155.3 0 0121.46 12.57 16 16 0 0015.11 1.71l44.89-18.07a10.81 10.81 0 0113.14 4.58l42.77 74a10.8 10.8 0 01-2.45 13.75l-38.21 30a16.05 16.05 0 00-6.05 14.08c.33 4.14.55 8.3.55 12.47z"
@@ -714,7 +714,7 @@
                 </MenuItem.Icon>
                 </MenuItem.Icon>
 
 
                 <!--  Exif window  -->
                 <!--  Exif window  -->
-                <MenuItem Command="{CompiledBinding ShowExifWindowCommand}" Header="{CompiledBinding Translation.ImageInfo.Value, Mode=OneWay}">
+                <MenuItem Command="{CompiledBinding Window.ShowExifWindow}" Header="{CompiledBinding Translation.ImageInfo.Value, Mode=OneWay}">
                     <MenuItem.Icon>
                     <MenuItem.Icon>
                         <Path
                         <Path
                             Data="{StaticResource ImageInfoGeometry}"
                             Data="{StaticResource ImageInfoGeometry}"
@@ -745,7 +745,7 @@
                 </MenuItem>
                 </MenuItem>
 
 
                 <!--  Single image resize  -->
                 <!--  Single image resize  -->
-                <MenuItem Command="{CompiledBinding ShowSingleImageResizeWindowCommand}" Header="{CompiledBinding Translation.ResizeImage.Value, Mode=OneWay}">
+                <MenuItem Command="{CompiledBinding Window.ShowSingleImageResizeWindow}" Header="{CompiledBinding Translation.ResizeImage.Value, Mode=OneWay}">
                     <MenuItem.Icon>
                     <MenuItem.Icon>
                         <Image
                         <Image
                             Height="12"
                             Height="12"
@@ -755,7 +755,7 @@
                 </MenuItem>
                 </MenuItem>
 
 
                 <!--  Batch resize  -->
                 <!--  Batch resize  -->
-                <MenuItem Command="{CompiledBinding ShowBatchResizeWindowCommand}" Header="{CompiledBinding Translation.BatchResize.Value, Mode=OneWay}">
+                <MenuItem Command="{CompiledBinding Window.ShowBatchResizeWindow}" Header="{CompiledBinding Translation.BatchResize.Value, Mode=OneWay}">
                     <MenuItem.Icon>
                     <MenuItem.Icon>
                         <Image
                         <Image
                             Height="12"
                             Height="12"
@@ -1017,7 +1017,7 @@
 
 
             <!--  Fullscreen  -->
             <!--  Fullscreen  -->
             <MenuItem
             <MenuItem
-                Command="{CompiledBinding ToggleFullscreenCommand}"
+                Command="{CompiledBinding MainWindow.ToggleFullscreenCommand}"
                 Header="{CompiledBinding Translation.Fullscreen.Value,
                 Header="{CompiledBinding Translation.Fullscreen.Value,
                                          Mode=OneWay}"
                                          Mode=OneWay}"
                 IsVisible="{CompiledBinding !MainWindow.IsFullscreen.Value,
                 IsVisible="{CompiledBinding !MainWindow.IsFullscreen.Value,
@@ -1051,7 +1051,7 @@
 
 
             <!--  Restore  -->
             <!--  Restore  -->
             <MenuItem
             <MenuItem
-                Command="{CompiledBinding RestoreCommand}"
+                Command="{CompiledBinding MainWindow.RestoreCommand}"
                 Header="{CompiledBinding Translation.RestoreDown.Value,
                 Header="{CompiledBinding Translation.RestoreDown.Value,
                                          Mode=OneWay}"
                                          Mode=OneWay}"
                 IsVisible="{CompiledBinding MainWindow.ShouldRestore.Value,
                 IsVisible="{CompiledBinding MainWindow.ShouldRestore.Value,

+ 3 - 3
src/PicView.Avalonia/Views/SettingsView.axaml

@@ -699,7 +699,7 @@
     <UserControl.ContextMenu>
     <UserControl.ContextMenu>
         <ContextMenu x:Name="ContextMenu">
         <ContextMenu x:Name="ContextMenu">
             <MenuItem
             <MenuItem
-                Command="{CompiledBinding ShowSettingsFileCommand}"
+                Command="{CompiledBinding Tools.ShowSettingsFileCommand}"
                 Foreground="{DynamicResource MainTextColor}"
                 Foreground="{DynamicResource MainTextColor}"
                 Header="UserSettings.json"
                 Header="UserSettings.json"
                 x:Name="UserSettingsItem">
                 x:Name="UserSettingsItem">
@@ -711,7 +711,7 @@
                 </MenuItem.Icon>
                 </MenuItem.Icon>
             </MenuItem>
             </MenuItem>
             <MenuItem
             <MenuItem
-                Command="{CompiledBinding ShowKeybindingsFileCommand}"
+                Command="{CompiledBinding Tools.ShowKeybindingsFileCommand}"
                 Foreground="{DynamicResource MainTextColor}"
                 Foreground="{DynamicResource MainTextColor}"
                 Header="keybindings.json"
                 Header="keybindings.json"
                 x:Name="KeybindingsItem">
                 x:Name="KeybindingsItem">
@@ -989,7 +989,7 @@
                     Background="{DynamicResource AltBackgroundHoverColor}"
                     Background="{DynamicResource AltBackgroundHoverColor}"
                     BorderBrush="{DynamicResource SecondaryBorderColor}"
                     BorderBrush="{DynamicResource SecondaryBorderColor}"
                     Classes="ButtonBorder hover"
                     Classes="ButtonBorder hover"
-                    Command="{CompiledBinding ShowKeybindingsWindowCommand}"
+                    Command="{CompiledBinding Window.ShowKeybindingsWindow}"
                     HorizontalAlignment="Left"
                     HorizontalAlignment="Left"
                     Margin="65,50,0,20"
                     Margin="65,50,0,20"
                     Padding="0,0,7,0"
                     Padding="0,0,7,0"

+ 1 - 1
src/PicView.Avalonia/Views/UC/Buttons/AltRestore.axaml

@@ -16,7 +16,7 @@
         BorderThickness="1,0,0,1"
         BorderThickness="1,0,0,1"
         Classes="ButtonBorder hover"
         Classes="ButtonBorder hover"
         ClickMode="Release"
         ClickMode="Release"
-        Command="{CompiledBinding ToggleFullscreenCommand}"
+        Command="{CompiledBinding MainWindow.ToggleFullscreenCommand}"
         CornerRadius="0,0,0,0"
         CornerRadius="0,0,0,0"
         DockPanel.Dock="Right"
         DockPanel.Dock="Right"
         Height="30"
         Height="30"

+ 2 - 2
src/PicView.Avalonia/Views/UC/Buttons/SettingsMenuButton.axaml

@@ -27,7 +27,7 @@
         <customControls:IconButton.Flyout>
         <customControls:IconButton.Flyout>
             <MenuFlyout FlyoutPresenterClasses="noCornerRadius" Placement="Bottom">
             <MenuFlyout FlyoutPresenterClasses="noCornerRadius" Placement="Bottom">
                 <MenuItem
                 <MenuItem
-                    Command="{CompiledBinding ShowSettingsFileCommand}"
+                    Command="{CompiledBinding Tools.ShowSettingsFileCommand}"
                     Foreground="{DynamicResource MainTextColor}"
                     Foreground="{DynamicResource MainTextColor}"
                     Header="UserSettings.json"
                     Header="UserSettings.json"
                     x:Name="UserSettingsItem">
                     x:Name="UserSettingsItem">
@@ -39,7 +39,7 @@
                     </MenuItem.Icon>
                     </MenuItem.Icon>
                 </MenuItem>
                 </MenuItem>
                 <MenuItem
                 <MenuItem
-                    Command="{CompiledBinding ShowKeybindingsFileCommand}"
+                    Command="{CompiledBinding Tools.ShowKeybindingsFileCommand}"
                     Foreground="{DynamicResource MainTextColor}"
                     Foreground="{DynamicResource MainTextColor}"
                     Header="keybindings.json"
                     Header="keybindings.json"
                     x:Name="KeybindingsItem">
                     x:Name="KeybindingsItem">

+ 1 - 1
src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml

@@ -264,7 +264,7 @@
                     Canvas.Left="160"
                     Canvas.Left="160"
                     Canvas.Top="155"
                     Canvas.Top="155"
                     Classes="ButtonBorder altHover"
                     Classes="ButtonBorder altHover"
-                    Command="{CompiledBinding NewWindowCommand}"
+                    Command="{CompiledBinding Window.NewWindow}"
                     Height="46"
                     Height="46"
                     ToolTip.Tip="{Binding Translation.NewWindow.Value, Mode=OneWay}">
                     ToolTip.Tip="{Binding Translation.NewWindow.Value, Mode=OneWay}">
                     <StackPanel Orientation="Horizontal">
                     <StackPanel Orientation="Horizontal">

+ 1 - 1
src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml

@@ -191,7 +191,7 @@
                     Canvas.Left="7"
                     Canvas.Left="7"
                     Canvas.Top="53"
                     Canvas.Top="53"
                     Classes="ButtonBorder altHover"
                     Classes="ButtonBorder altHover"
-                    Command="{CompiledBinding ShowSingleImageResizeWindowCommand}"
+                    Command="{CompiledBinding Window.ShowSingleImageResizeWindow}"
                     Height="46"
                     Height="46"
                     IsEnabled="{CompiledBinding PicViewer.FileInfo,
                     IsEnabled="{CompiledBinding PicViewer.FileInfo,
                                                 Converter={x:Static ObjectConverters.IsNotNull}}"
                                                 Converter={x:Static ObjectConverters.IsNotNull}}"

+ 2 - 2
src/PicView.Avalonia/Views/UC/Menus/SettingsMenu.axaml

@@ -45,7 +45,7 @@
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderThickness="0,0,1,0"
                     BorderThickness="0,0,1,0"
                     Classes="noBorderHover"
                     Classes="noBorderHover"
-                    Command="{CompiledBinding ShowAboutWindowCommand}"
+                    Command="{CompiledBinding Window.ShowAboutWindow}"
                     CornerRadius="8,0,0,0"
                     CornerRadius="8,0,0,0"
                     Height="46"
                     Height="46"
                     ToolTip.Tip="{CompiledBinding Translation.AboutWindow.Value,
                     ToolTip.Tip="{CompiledBinding Translation.AboutWindow.Value,
@@ -76,7 +76,7 @@
                     BorderThickness="0,0,1,0"
                     BorderThickness="0,0,1,0"
                     Canvas.Left="178"
                     Canvas.Left="178"
                     Classes="noBorderHover"
                     Classes="noBorderHover"
-                    Command="{Binding ShowSettingsWindowCommand}"
+                    Command="{Binding Window.ShowSettingsWindow}"
                     Height="46"
                     Height="46"
                     ToolTip.Tip="{CompiledBinding Translation.ShowAllSettingsWindow.Value,
                     ToolTip.Tip="{CompiledBinding Translation.ShowAllSettingsWindow.Value,
                                                   Mode=OneWay}"
                                                   Mode=OneWay}"

+ 4 - 4
src/PicView.Avalonia/Views/UC/Menus/ToolsMenu.axaml

@@ -45,7 +45,7 @@
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderThickness="0,0,1,0"
                     BorderThickness="0,0,1,0"
                     Classes="noBorderHover"
                     Classes="noBorderHover"
-                    Command="{CompiledBinding ShowBatchResizeWindowCommand}"
+                    Command="{CompiledBinding Window.ShowBatchResizeWindow}"
                     CornerRadius="8,0,0,0"
                     CornerRadius="8,0,0,0"
                     Height="45"
                     Height="45"
                     ToolTip.Tip="{CompiledBinding Translation.BatchResize.Value,
                     ToolTip.Tip="{CompiledBinding Translation.BatchResize.Value,
@@ -76,7 +76,7 @@
                     BorderThickness="0,0,1,0"
                     BorderThickness="0,0,1,0"
                     Canvas.Left="179"
                     Canvas.Left="179"
                     Classes="noBorderHover"
                     Classes="noBorderHover"
-                    Command="{CompiledBinding ShowEffectsWindowCommand}"
+                    Command="{CompiledBinding Window.ShowEffectsWindow}"
                     Height="45"
                     Height="45"
                     ToolTip.Tip="{CompiledBinding Translation.EffectsTooltip.Value,
                     ToolTip.Tip="{CompiledBinding Translation.EffectsTooltip.Value,
                                                   Mode=OneWay}"
                                                   Mode=OneWay}"
@@ -129,7 +129,7 @@
                     Canvas.Left="7"
                     Canvas.Left="7"
                     Canvas.Top="53"
                     Canvas.Top="53"
                     Classes="ButtonBorder altHover"
                     Classes="ButtonBorder altHover"
-                    Command="{CompiledBinding ShowExifWindowCommand}"
+                    Command="{CompiledBinding Window.ShowExifWindow}"
                     Height="46"
                     Height="46"
                     Width="169">
                     Width="169">
                     <StackPanel Orientation="Horizontal">
                     <StackPanel Orientation="Horizontal">
@@ -216,7 +216,7 @@
                     Canvas.Left="7"
                     Canvas.Left="7"
                     Canvas.Top="155"
                     Canvas.Top="155"
                     Classes="ButtonBorder altHover"
                     Classes="ButtonBorder altHover"
-                    Command="{CompiledBinding ShowKeybindingsWindowCommand}"
+                    Command="{CompiledBinding Window.ShowKeybindingsWindow}"
                     Height="46"
                     Height="46"
                     ToolTip.Tip="{CompiledBinding Translation.ApplicationShortcuts.Value,
                     ToolTip.Tip="{CompiledBinding Translation.ApplicationShortcuts.Value,
                                                   Mode=OneWay}"
                                                   Mode=OneWay}"