Explorar o código

Smoother resizing

Daniel Chalmers %!s(int64=3) %!d(string=hai) anos
pai
achega
3e465a850e

+ 0 - 1
DesktopClock/MainWindow.xaml

@@ -53,7 +53,6 @@
 						        IsSnapToTickEnabled="True"
 						        Maximum="160"
 						        Minimum="16"
-						        TickFrequency="4"
 						        Value="{Binding Height, Source={x:Static p:Settings.Default}, Mode=TwoWay}" />
 					</StackPanel>
 				</MenuItem.Header>

+ 4 - 6
DesktopClock/MainWindow.xaml.cs

@@ -36,12 +36,10 @@ public partial class MainWindow : Window
     {
         if (Keyboard.Modifiers == ModifierKeys.Control)
         {
-            var newSize = Settings.Default.Height + e.Delta;
-
-            newSize = Math.Max(newSize, 16);
-            newSize = Math.Min(newSize, 160);
-
-            Settings.Default.Height = newSize;
+            // Scale size based on scroll amount, with one notch on a default PC mouse being a change of 15%.
+            var steps = e.Delta / (double)Mouse.MouseWheelDeltaForOneLine;
+            var change = Settings.Default.Height * steps * 0.15;
+            Settings.Default.Height = Math.Min(Math.Max(Settings.Default.Height + change, 16), 160);
         }
     }
 

+ 1 - 1
DesktopClock/Properties/Settings.cs

@@ -38,7 +38,7 @@ public sealed class Settings : INotifyPropertyChanged
     public WindowPlacement Placement { get; set; }
     public bool Topmost { get; set; } = true;
     public bool ShowInTaskbar { get; set; } = true;
-    public int Height { get; set; } = 48;
+    public double Height { get; set; } = 48;
     public string TimeZone { get; set; } = string.Empty;
     public string Format { get; set; } = "dddd, MMM dd, HH:mm:ss";
     public bool BackgroundEnabled { get; set; } = true;