Kaynağa Gözat

Fix RepeatButton and intervals

Ruben 11 ay önce
ebeveyn
işleme
9769f7a76f

+ 2 - 2
src/PicView.Avalonia/CustomControls/IconButton.cs

@@ -43,9 +43,9 @@ public class IconButton : RepeatButton
         AvaloniaProperty.Register<IconButton, double>(nameof(IconHeight));
 
     /// <summary>
-    /// Overrides the default style key to <see cref="Button"/>.
+    /// Overrides the default style key to <see cref="RepeatButton"/>.
     /// </summary>
-    protected override Type StyleKeyOverride => typeof(Button);
+    protected override Type StyleKeyOverride => typeof(RepeatButton);
 
     /// <summary>
     /// Gets or sets the <see cref="DrawingImage"/> displayed as the icon of the button.

+ 1 - 1
src/PicView.Avalonia/PicViewTheme/Classes.axaml

@@ -50,7 +50,7 @@
         <Setter Property="CornerRadius" Value="2" />
     </Style>
 
-    <Style Selector="Button.mainBtn, ToggleButton.mainBtn">
+    <Style Selector="Button.mainBtn, ToggleButton.mainBtn, RepeatButton.mainBtn">
         <Setter Property="Width" Value="NaN" />
         <Setter Property="Height" Value="35" />
         <Setter Property="Padding" Value="10" />

+ 1 - 0
src/PicView.Avalonia/PicViewTheme/Controls/RepeatButton.axaml

@@ -2,6 +2,7 @@
 
     <ControlTheme TargetType="RepeatButton" x:Key="{x:Type RepeatButton}">
         <Setter Property="Focusable" Value="False" />
+        <Setter Property="Interval" Value="-1" />
 
         <Setter Property="RepeatButton.Template">
             <ControlTemplate TargetType="RepeatButton">

+ 37 - 39
src/PicView.Avalonia/Views/BottomBar.axaml.cs

@@ -22,58 +22,56 @@ public partial class BottomBar : UserControl
                 DragAndDropHelper.RemoveDragDropView();
             };
 
-            if (!SettingsHelper.Settings.Theme.GlassTheme)
+            if (SettingsHelper.Settings.Theme.GlassTheme)
             {
-                return;
-            }
-
-            MainBottomBorder.Background = Brushes.Transparent;
-            MainBottomBorder.BorderThickness = new Thickness(0);
+                MainBottomBorder.Background = Brushes.Transparent;
+                MainBottomBorder.BorderThickness = new Thickness(0);
                 
-            FileMenuButton.Background = Brushes.Transparent;
-            FileMenuButton.Classes.Remove("noBorderHover");
-            FileMenuButton.Classes.Add("hover");
+                FileMenuButton.Background = Brushes.Transparent;
+                FileMenuButton.Classes.Remove("noBorderHover");
+                FileMenuButton.Classes.Add("hover");
                 
-            ImageMenuButton.Background = Brushes.Transparent;
-            ImageMenuButton.Classes.Remove("noBorderHover");
-            ImageMenuButton.Classes.Add("hover");
+                ImageMenuButton.Background = Brushes.Transparent;
+                ImageMenuButton.Classes.Remove("noBorderHover");
+                ImageMenuButton.Classes.Add("hover");
                 
-            ToolsMenuButton.Background = Brushes.Transparent;
-            ToolsMenuButton.Classes.Remove("noBorderHover");
-            ToolsMenuButton.Classes.Add("hover");
+                ToolsMenuButton.Background = Brushes.Transparent;
+                ToolsMenuButton.Classes.Remove("noBorderHover");
+                ToolsMenuButton.Classes.Add("hover");
                 
-            SettingsMenuButton.Background = Brushes.Transparent;
-            SettingsMenuButton.Classes.Remove("noBorderHover");
-            SettingsMenuButton.Classes.Add("hover");
+                SettingsMenuButton.Background = Brushes.Transparent;
+                SettingsMenuButton.Classes.Remove("noBorderHover");
+                SettingsMenuButton.Classes.Add("hover");
             
-            NextButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
+                NextButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
                 
-            PreviousButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
+                PreviousButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
 
-            if (!Application.Current.TryGetResource("SecondaryTextColor",
-                    Application.Current.RequestedThemeVariant, out var textColor))
-            {
-                return;
-            }
+                if (!Application.Current.TryGetResource("SecondaryTextColor",
+                        Application.Current.RequestedThemeVariant, out var textColor))
+                {
+                    return;
+                }
 
-            if (textColor is not Color color)
-            {
-                return;
-            }
+                if (textColor is not Color color)
+                {
+                    return;
+                }
 
-            FileMenuButton.Foreground = new SolidColorBrush(color);
-            ImageMenuButton.Foreground = new SolidColorBrush(color);
-            ToolsMenuButton.Foreground = new SolidColorBrush(color);
-            SettingsMenuButton.Foreground = new SolidColorBrush(color);
+                FileMenuButton.Foreground = new SolidColorBrush(color);
+                ImageMenuButton.Foreground = new SolidColorBrush(color);
+                ToolsMenuButton.Foreground = new SolidColorBrush(color);
+                SettingsMenuButton.Foreground = new SolidColorBrush(color);
             
-            NextButton.Foreground = new SolidColorBrush(color);
-            PreviousButton.Foreground = new SolidColorBrush(color);
-
-
-            NextButton.Delay =
+                NextButton.Foreground = new SolidColorBrush(color);
+                PreviousButton.Foreground = new SolidColorBrush(color);
+            }
+            
+            // TODO add interval to mainviewmodel
+            NextButton.Interval =
                 (int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
 
-            PreviousButton.Delay =
+            PreviousButton.Interval =
                 (int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
 
         };

+ 5 - 0
src/PicView.Avalonia/Views/UC/Buttons/ClickArrowLeft.axaml.cs

@@ -1,6 +1,7 @@
 using Avalonia.Controls;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
+using PicView.Core.Config;
 
 namespace PicView.Avalonia.Views.UC.Buttons;
 public partial class ClickArrowLeft : UserControl
@@ -16,6 +17,10 @@ public partial class ClickArrowLeft : UserControl
             }
             HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
             PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);
+            
+            // TODO add interval to mainviewmodel
+            PolyButton.Interval =
+                (int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
         };
     }
 }

+ 5 - 0
src/PicView.Avalonia/Views/UC/Buttons/ClickArrowRight.axaml.cs

@@ -1,6 +1,7 @@
 using Avalonia.Controls;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
+using PicView.Core.Config;
 
 namespace PicView.Avalonia.Views.UC.Buttons;
 public partial class ClickArrowRight : UserControl
@@ -16,6 +17,10 @@ public partial class ClickArrowRight : UserControl
             }
             HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
             PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);
+            
+            // TODO add interval to mainviewmodel
+            PolyButton.Interval =
+                (int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
         };
     }
 }

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

@@ -20,7 +20,7 @@
                     <Setter Property="VerticalAlignment" Value="Center" />
                     <Setter Property="Foreground" Value="{DynamicResource MainTextColor}" />
                 </Style>
-                <Style Selector="Button.btn">
+                <Style Selector="Button.btn, RepeatButton.btn">
                     <Setter Property="Width" Value="45" />
                     <Setter Property="Height" Value="45" />
                     <Setter Property="Background" Value="Transparent" />