Browse Source

Use OS native chrome icons

CPKreuz 2 years ago
parent
commit
3dbb56d4c4
2 changed files with 20 additions and 6 deletions
  1. 18 3
      src/PixiEditor/App.xaml.cs
  2. 2 3
      src/PixiEditor/Styles/Titlebar.xaml

+ 18 - 3
src/PixiEditor/App.xaml.cs

@@ -1,6 +1,7 @@
 using System.IO;
 using System.Text.RegularExpressions;
 using System.Windows;
+using System.Windows.Media;
 using PixiEditor.Localization;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
@@ -40,11 +41,25 @@ internal partial class App : Application
             return;
         }
 
-        if (HandleNewInstance())
+        if (!HandleNewInstance())
         {
-            MainWindow = new MainWindow();
-            MainWindow.Show();
+            return;
         }
+
+        AddNativeAssets();
+        
+        MainWindow = new MainWindow();
+        MainWindow.Show();
+
+    }
+
+    private void AddNativeAssets()
+    {
+        var iconFont = OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000)
+            ? "Segoe Fluent Icons"
+            : "Segoe MDL2 Assets";
+        
+        Resources.Add("NativeIconFont", new FontFamily(iconFont));
     }
 
     private bool HandleNewInstance()

+ 2 - 3
src/PixiEditor/Styles/Titlebar.xaml

@@ -7,7 +7,7 @@
             <Setter.Value>
                 <ControlTemplate TargetType="Button">
                     <Grid x:Name="LayoutRoot" Background="Transparent" Width="44" Height="35">
-                        <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets"
+                        <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="{DynamicResource NativeIconFont}"
                                    FontSize="10"
                                    Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"
                                    RenderOptions.ClearTypeHint="Auto" TextOptions.TextRenderingMode="Aliased"
@@ -46,8 +46,7 @@
             <Setter.Value>
                 <ControlTemplate TargetType="Button">
                     <Grid x:Name="LayoutRoot" Background="Transparent" Width="44" Height="35">
-                        <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets"
-                                   FontSize="10"
+                        <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="{DynamicResource NativeIconFont}"
                                    Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"
                                    RenderOptions.ClearTypeHint="Auto" TextOptions.TextRenderingMode="Aliased"
                                    TextOptions.TextFormattingMode="Display" />