11using System . Text . Json ;
22using Microsoft . UI . Composition . SystemBackdrops ;
33using Microsoft . UI . Xaml ;
4+ using Microsoft . UI . Xaml . Controls ;
45using Microsoft . UI . Xaml . Media ;
56using WinRT ;
67
@@ -55,6 +56,82 @@ public static void SaveLanguage(string lang)
5556 MergeAndSaveSettings ( new Dictionary < string , object > { [ "language" ] = lang } ) ;
5657 }
5758
59+ // ── Font ─────────────────────────────────────────────────
60+
61+ public static string LoadFontSetting ( )
62+ {
63+ try
64+ {
65+ if ( File . Exists ( SettingsPath ) )
66+ {
67+ var json = File . ReadAllText ( SettingsPath ) ;
68+ var doc = JsonDocument . Parse ( json ) ;
69+ if ( doc . RootElement . TryGetProperty ( "font" , out var prop ) )
70+ return prop . GetString ( ) ?? "geist" ;
71+ }
72+ }
73+ catch { }
74+ return "geist" ;
75+ }
76+
77+ public static void SaveFontSetting ( string font )
78+ {
79+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "font" ] = font } ) ;
80+ }
81+
82+ public static FontFamily GetFontFamily ( string font )
83+ {
84+ return font switch
85+ {
86+ "segoe" => new FontFamily ( "Segoe UI" ) ,
87+ "inter" => new FontFamily ( "Assets/Fonts/Inter-Regular.ttf#Inter" ) ,
88+ "jetbrains" => new FontFamily ( "Assets/Fonts/JetBrainsMono-Regular.ttf#JetBrains Mono" ) ,
89+ _ => new FontFamily ( "Assets/Fonts/Geist-Regular.otf#Geist" ) ,
90+ } ;
91+ }
92+
93+ public static void ApplyFontToTree ( FrameworkElement root , FontFamily fontFamily )
94+ {
95+ if ( root is Control c )
96+ c . FontFamily = fontFamily ;
97+ else if ( root is TextBlock tb )
98+ tb . FontFamily = fontFamily ;
99+
100+ if ( root is Panel panel )
101+ {
102+ foreach ( var child in panel . Children )
103+ if ( child is FrameworkElement fe )
104+ ApplyFontToTree ( fe , fontFamily ) ;
105+ }
106+ else if ( root is ContentControl cc && cc . Content is FrameworkElement content )
107+ {
108+ ApplyFontToTree ( content , fontFamily ) ;
109+ }
110+ }
111+
112+ // ── Note style ────────────────────────────────────────────
113+
114+ public static string LoadNoteStyle ( )
115+ {
116+ try
117+ {
118+ if ( File . Exists ( SettingsPath ) )
119+ {
120+ var json = File . ReadAllText ( SettingsPath ) ;
121+ var doc = JsonDocument . Parse ( json ) ;
122+ if ( doc . RootElement . TryGetProperty ( "noteStyle" , out var prop ) )
123+ return prop . GetString ( ) ?? "titlebar" ;
124+ }
125+ }
126+ catch { }
127+ return "titlebar" ;
128+ }
129+
130+ public static void SaveNoteStyle ( string style )
131+ {
132+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "noteStyle" ] = style } ) ;
133+ }
134+
58135 // ── Slash commands ──────────────────────────────────────────
59136
60137 public static bool LoadSlashEnabled ( )
@@ -240,7 +317,8 @@ private static void ConfigureBackdropController(
240317 }
241318 }
242319
243- public static void ApplyThemeToWindow ( Window window , string theme )
320+ public static void ApplyThemeToWindow ( Window window , string theme ,
321+ SystemBackdropConfiguration ? configSource = null )
244322 {
245323 if ( window . Content is FrameworkElement fe )
246324 {
@@ -250,6 +328,9 @@ public static void ApplyThemeToWindow(Window window, string theme)
250328 "dark" => ElementTheme . Dark ,
251329 _ => ElementTheme . Default
252330 } ;
331+
332+ if ( configSource != null )
333+ configSource . Theme = ( SystemBackdropTheme ) fe . ActualTheme ;
253334 }
254335 }
255336
0 commit comments