소스 검색

macOS updates.

Ruben 6 달 전
부모
커밋
f3036c2f57

+ 1 - 1
src/PicView.Avalonia.MacOS/Views/AboutWindow.axaml.cs

@@ -17,7 +17,7 @@ public partial class AboutWindow : Window
         }
         Loaded += delegate
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Title = $"{TranslationManager.Translation.About} - PicView";
         };
         KeyDown += (_, e) =>

+ 2 - 9
src/PicView.Avalonia.MacOS/Views/BatchResizeWindow.axaml

@@ -24,26 +24,19 @@
         BorderThickness="1"
         CornerRadius="8">
         <StackPanel>
-
             <DockPanel
                 Background="{DynamicResource SecondaryBackgroundColor}"
                 Height="28"
                 PointerPressed="MoveWindow"
                 VerticalAlignment="Top">
-
                 <TextBlock
                     Classes="txt"
                     Text="{CompiledBinding Translation.ResizeImage,
                                            Mode=OneWay}"
                     TextAlignment="Center" />
             </DockPanel>
-
-
-            <customControls:AutoScrollViewer
-                Background="{DynamicResource WindowBackgroundColor}"
-                Margin="5,0,0,0"
-                PointerPressed="MoveWindow">
-                <views:BatchResizeView x:Name="XAboutView" />
+            <customControls:AutoScrollViewer Background="{DynamicResource WindowBackgroundColor}" PointerPressed="MoveWindow">
+                <views:BatchResizeView Padding="5,0" x:Name="XAboutView" />
             </customControls:AutoScrollViewer>
         </StackPanel>
     </Border>

+ 1 - 1
src/PicView.Avalonia.MacOS/Views/BatchResizeWindow.axaml.cs

@@ -13,7 +13,7 @@ public partial class BatchResizeWindow : Window
         InitializeComponent();
         Loaded += (_, _) =>
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Height = 500;
             Title = TranslationManager.Translation.BatchResize + " - PicView";
             

+ 1 - 1
src/PicView.Avalonia.MacOS/Views/EffectsWindow.axaml.cs

@@ -18,7 +18,7 @@ public partial class EffectsWindow : Window
         }
         Loaded += delegate
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Title = $"{TranslationManager.Translation.Effects} - PicView";
             
             ClientSizeProperty.Changed.Subscribe(size =>

+ 11 - 10
src/PicView.Avalonia.MacOS/Views/KeybindingsWindow.axaml

@@ -18,34 +18,35 @@
     <Design.DataContext>
         <viewModels:MainViewModel />
     </Design.DataContext>
+
     <Border
         BorderBrush="{DynamicResource WindowBorderColor}"
         BorderThickness="1"
         CornerRadius="8">
         <Panel>
 
-            <DockPanel
+            <Panel
                 Background="{DynamicResource WindowBackgroundColor}"
-                Height="28"
-                PointerPressed="MoveWindow"
+                Height="{StaticResource TopBorderHeight}"
                 VerticalAlignment="Top"
                 x:Name="WindowBorder">
 
                 <TextBlock
                     Classes="txt"
+                    Foreground="{DynamicResource MainTextColor}"
                     Text="{CompiledBinding Translation.ApplicationShortcuts}"
                     TextAlignment="Center" />
-            </DockPanel>
+            </Panel>
 
-            <customControls:AutoScrollViewer
+            <Border
                 Background="{DynamicResource WindowBackgroundColor}"
                 Focusable="True"
                 Margin="0,28,0,0"
-                Padding="5,2,5,10"
-                PointerPressed="MoveWindow"
-                x:Name="XKeybindingsView">
-                <views:KeybindingsView />
-            </customControls:AutoScrollViewer>
+                PointerPressed="MoveWindow">
+                <customControls:AutoScrollViewer Padding="5,2,5,10">
+                    <views:KeybindingsView x:Name="XKeybindingsView" />
+                </customControls:AutoScrollViewer>
+            </Border>
         </Panel>
     </Border>
 </Window>

+ 3 - 1
src/PicView.Avalonia.MacOS/Views/KeybindingsWindow.axaml.cs

@@ -2,6 +2,7 @@ using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Media;
 using PicView.Avalonia.Input;
+using PicView.Avalonia.UI;
 using PicView.Core.Localization;
 
 namespace PicView.Avalonia.MacOS.Views;
@@ -10,6 +11,7 @@ public partial class KeybindingsWindow : Window
 {
     public KeybindingsWindow()
     {
+        MaxHeight = ScreenHelper.ScreenSize.WorkingAreaHeight;
         InitializeComponent();
         if (!Settings.Theme.Dark || Settings.Theme.GlassTheme)
         {
@@ -18,7 +20,7 @@ public partial class KeybindingsWindow : Window
         }
         Loaded += (sender, e) =>
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Title = $"{TranslationManager.Translation.ApplicationShortcuts} - PicView";
         };
         KeyDown += (_, e) =>

+ 5 - 2
src/PicView.Avalonia.MacOS/Views/MacMainWindow.axaml

@@ -27,7 +27,7 @@
                     <NativeMenuItem Command="{CompiledBinding OpenFileCommand}" Header="{CompiledBinding Translation.Open, Mode=OneWay}" />
                     <NativeMenuItem
                         Command="{CompiledBinding OpenWithCommand}"
-                        CommandParameter="{CompiledBinding PicViewer.FileInfo,
+                        CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
                                                            FallbackValue=''}"
                         Header="{CompiledBinding Translation.OpenWith,
                                                  Mode=OneWay}" />
@@ -79,7 +79,7 @@
                     <NativeMenuItem Command="{CompiledBinding RotateRightCommand}" Header="{CompiledBinding Translation.RotateRight, Mode=OneWay}" />
                     <NativeMenuItem Command="{CompiledBinding FlipCommand}" Header="{CompiledBinding Translation.Flip, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
-                    <NativeMenuItem Command="{CompiledBinding CropCommand}" Header="{CompiledBinding Crop, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding CropCommand}" Header="{CompiledBinding Translation.Crop, Mode=OneWay}" />
                     <NativeMenuItemSeparator />
                     <!--  TODO Implement setting as wallpaper for macOS  -->
                     <NativeMenuItem
@@ -112,6 +112,9 @@
                 <NativeMenu>
                     <NativeMenuItem Command="{CompiledBinding SlideshowCommand}" Header="{CompiledBinding Translation.Slideshow}" />
                     <NativeMenuItemSeparator />
+                    <NativeMenuItem Command="{CompiledBinding FirstCommand}" Header="{CompiledBinding Translation.FirstImage}" />
+                    <NativeMenuItem Command="{CompiledBinding LastCommand}" Header="{CompiledBinding Translation.LastImage}" />
+                    <NativeMenuItemSeparator />
                     <NativeMenuItem Command="{CompiledBinding Skip10Command}" Header="{CompiledBinding Translation.AdvanceBy10Images}" />
                     <NativeMenuItem Command="{CompiledBinding Skip100Command}" Header="{CompiledBinding Translation.AdvanceBy100Images}" />
                     <NativeMenuItem Command="{CompiledBinding Prev10Command}" Header="{CompiledBinding Translation.GoBackBy10Images}" />

+ 1 - 1
src/PicView.Avalonia.MacOS/Views/SettingsWindow.axaml.cs

@@ -28,7 +28,7 @@ public partial class SettingsWindow : Window
         }
         Loaded += delegate
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Height = 500;
             Title = TranslationManager.Translation.Settings + " - PicView";
         };

+ 1 - 1
src/PicView.Avalonia.MacOS/Views/SingleImageResizeWindow.axaml.cs

@@ -12,7 +12,7 @@ public partial class SingleImageResizeWindow : Window
         InitializeComponent();
         Loaded += (_, _) =>
         {
-            MinWidth = MaxWidth = Width;
+            MinWidth = MaxWidth = Bounds.Width;
             Height = 500;
             Title = TranslationManager.Translation.ResizeImage + " - PicView";
         };

+ 2 - 2
src/PicView.Avalonia/Crop/CropResizer.cs

@@ -100,8 +100,8 @@ public static class CropResizer
         // Update the view model
         vm.SelectionX = Convert.ToInt32(newX);
         vm.SelectionY = Convert.ToInt32(newY);
-        vm.SelectionWidth = newWidth;
-        vm.SelectionHeight = newHeight;
+        vm.SelectionWidth = Convert.ToInt32(newWidth);
+        vm.SelectionHeight = Convert.ToInt32(newHeight);
         
         // Update the rectangle position on canvas
         Canvas.SetLeft(control.MainRectangle, newX);

+ 0 - 1
src/PicView.Avalonia/Views/MainView.axaml.cs

@@ -77,7 +77,6 @@ public partial class MainView : UserControl
 
             if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
             {
-                MaximizeMenuItem.IsVisible = false;
                 WallpaperMenuItem.IsVisible = false;
             }
             else

+ 12 - 1
src/PicView.Avalonia/Views/UC/CropControl.axaml.cs

@@ -1,4 +1,5 @@
-using Avalonia.Controls;
+using System.Runtime.InteropServices;
+using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.Media;
@@ -16,6 +17,16 @@ public partial class CropControl : UserControl
     public CropControl()
     {
         InitializeComponent();
+        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+        {
+            TopMiddleButton.Cursor = Cursor.Parse("TopSide");
+            BottomMiddleButton.Cursor = Cursor.Parse("BottomSide");
+            LeftMiddleButton.Cursor = Cursor.Parse("LeftSide");
+            RightMiddleButton.Cursor = Cursor.Parse("RightSide");
+            
+            MainRectangle.Cursor = Cursor.Parse("DragMove");
+            
+        }
         _keyboardManager = new CropKeyboardManager(this);
         _dragHandler = new CropDragHandler(this);
         _resizeHandler = new CropResizeHandler(this);

+ 17 - 6
src/PicView.Core/Keybindings/KeybindingFunctions.cs

@@ -1,8 +1,21 @@
-namespace PicView.Core.Keybindings;
+using System.Runtime.InteropServices;
+
+namespace PicView.Core.Keybindings;
 
 public static class KeybindingFunctions
 {
-    public static string? CurrentKeybindingsPath { get; private set; }
+    private static string? _currentKeybindingsPath;
+    public static string? CurrentKeybindingsPath
+    {
+        get
+        {
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {
+                return _currentKeybindingsPath.Replace("/", "\\");;
+            }
+            return _currentKeybindingsPath;
+        }
+    }
     public static async Task SaveKeyBindingsFile(string json)
     {
         try
@@ -10,7 +23,6 @@ public static class KeybindingFunctions
             var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/keybindings.json");
             await using var writer = new StreamWriter(path);
             await writer.WriteAsync(json).ConfigureAwait(false);
-            CurrentKeybindingsPath = path.Replace("/", "\\");;
         }
         catch (Exception)
         {
@@ -22,7 +34,6 @@ public static class KeybindingFunctions
             }
             await using var newWriter = new StreamWriter(newPath);
             await newWriter.WriteAsync(json).ConfigureAwait(false);
-            CurrentKeybindingsPath = newPath.Replace("/", "\\");;
         }
     }
 
@@ -32,7 +43,7 @@ public static class KeybindingFunctions
         if (File.Exists(path))
         {
             var text = await File.ReadAllTextAsync(path).ConfigureAwait(false);
-            CurrentKeybindingsPath = path.Replace("/", "\\");;
+            _currentKeybindingsPath = path;
             return text;
         }
 
@@ -40,7 +51,7 @@ public static class KeybindingFunctions
         if (File.Exists(newPath))
         {
             var text = await File.ReadAllTextAsync(newPath).ConfigureAwait(false);
-            CurrentKeybindingsPath = path.Replace("/", "\\");;
+            _currentKeybindingsPath = newPath;
             return text;
         }