Browse Source

Ctrl + scroll wheel to adjust height

Daniel Chalmers 3 năm trước cách đây
mục cha
commit
8a4157e866
2 tập tin đã thay đổi với 16 bổ sung1 xóa
  1. 1 0
      DesktopClock/MainWindow.xaml
  2. 15 1
      DesktopClock/MainWindow.xaml.cs

+ 1 - 0
DesktopClock/MainWindow.xaml

@@ -13,6 +13,7 @@
         FontFamily="{Binding FontFamily, Source={x:Static p:Settings.Default}, Mode=OneWay}"
         MouseDown="Window_MouseDown"
         MouseDoubleClick="Window_MouseDoubleClick"
+		MouseWheel="Window_MouseWheel"
         ResizeMode="NoResize"
         ShowInTaskbar="{Binding ShowInTaskbar, Source={x:Static p:Settings.Default}, Mode=TwoWay}"
         SizeToContent="WidthAndHeight"

+ 15 - 1
DesktopClock/MainWindow.xaml.cs

@@ -1,4 +1,5 @@
-using System.Diagnostics;
+using System;
+using System.Diagnostics;
 using System.Windows;
 using System.Windows.Input;
 using DesktopClock.Properties;
@@ -31,6 +32,19 @@ public partial class MainWindow : Window
         CopyToClipboard();
     }
 
+    private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
+    {
+        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;
+        }
+    }
+
     private void MenuItemCopy_OnClick(object sender, RoutedEventArgs e)
     {
         CopyToClipboard();