瀏覽代碼

Add font style setting

Daniel Chalmers 1 年之前
父節點
當前提交
90b6c451be

+ 1 - 0
DesktopClock/MainWindow.xaml

@@ -17,6 +17,7 @@
         Opacity="0"
         Topmost="{Binding Topmost, Source={x:Static p:Settings.Default}, Mode=TwoWay}"
         FontFamily="{Binding FontFamily, Source={x:Static p:Settings.Default}, Mode=OneWay}"
+        FontStyle="{Binding FontStyle, Source={x:Static p:Settings.Default}, Mode=OneWay}"
         MouseDown="Window_MouseDown"
         MouseDoubleClick="Window_MouseDoubleClick"
         MouseWheel="Window_MouseWheel"

+ 6 - 0
DesktopClock/Properties/Settings.cs

@@ -1,6 +1,7 @@
 using System;
 using System.ComponentModel;
 using System.IO;
+using System.Windows;
 using System.Windows.Media;
 using Newtonsoft.Json;
 using WpfWindowPlacement;
@@ -106,6 +107,11 @@ public sealed class Settings : INotifyPropertyChanged, IDisposable
     /// </summary>
     public string FontFamily { get; set; } = "Consolas";
 
+    /// <summary>
+    /// Style of font to use for the clock's text.
+    /// </summary>
+    public string FontStyle { get; set; } = "Normal";
+
     /// <summary>
     /// Text color for the clock's text.
     /// </summary>

+ 7 - 0
DesktopClock/SettingsWindow.xaml

@@ -95,6 +95,13 @@
                            FontStyle="Italic"
                            FontSize="10"
                            Margin="0,0,0,12" />
+                
+                <TextBlock Text="Font Style:" />
+                <ComboBox ItemsSource="{Binding FontStyles}" SelectedItem="{Binding Settings.FontStyle, Mode=TwoWay}" />
+                <TextBlock Text="Style of font to use for the clock's text."
+                           FontStyle="Italic"
+                           FontSize="10"
+                           Margin="0,0,0,12" />
 
                 <TextBlock Text="Text Color:" />
                 <TextBox Text="{Binding Settings.TextColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

+ 6 - 0
DesktopClock/SettingsWindow.xaml.cs

@@ -80,6 +80,7 @@ public partial class SettingsWindowViewModel : ObservableObject
     {
         Settings = settings;
         FontFamilies = Fonts.SystemFontFamilies.Select(ff => ff.Source).ToList();
+        FontStyles = ["Normal", "Italic", "Oblique"];
         TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(tz => tz.Id).ToList();
     }
 
@@ -88,6 +89,11 @@ public partial class SettingsWindowViewModel : ObservableObject
     /// </summary>
     public IList<string> FontFamilies { get; }
 
+    /// <summary>
+    /// All available font styles.
+    /// </summary>
+    public IList<string> FontStyles { get; }
+
     /// <summary>
     /// All available time zones reported by the system.
     /// </summary>