@@ -259,79 +259,26 @@ private ResourceDictionary GetThemeResourceDictionary(string theme)
259259 {
260260 Source = new Uri ( uri , UriKind . Absolute )
261261 } ;
262-
263262 return dict ;
264263 }
265264
266265 private ResourceDictionary GetResourceDictionary ( string theme )
267266 {
268267 var dict = GetThemeResourceDictionary ( theme ) ;
269268
270- if ( dict [ "QueryBoxStyle" ] is Style queryBoxStyle &&
271- dict [ "QuerySuggestionBoxStyle" ] is Style querySuggestionBoxStyle )
272- {
273- var fontFamily = new FontFamily ( _settings . QueryBoxFont ) ;
274- var fontStyle = FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . QueryBoxFontStyle ) ;
275- var fontWeight = FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . QueryBoxFontWeight ) ;
276- var fontStretch = FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . QueryBoxFontStretch ) ;
269+ /* Apply font settings */
270+ ApplyFontSettings ( dict ) ;
277271
278- queryBoxStyle . Setters . Add ( new Setter ( Control . FontFamilyProperty , fontFamily ) ) ;
279- queryBoxStyle . Setters . Add ( new Setter ( Control . FontStyleProperty , fontStyle ) ) ;
280- queryBoxStyle . Setters . Add ( new Setter ( Control . FontWeightProperty , fontWeight ) ) ;
281- queryBoxStyle . Setters . Add ( new Setter ( Control . FontStretchProperty , fontStretch ) ) ;
282-
283- var caretBrushProperty = queryBoxStyle . Setters . OfType < Setter > ( ) . Where ( x => x . Property . Name == "CaretBrush" ) ?
284- . FirstOrDefault ( ) ;
285- var foregroundPropertyValue = queryBoxStyle . Setters . OfType < Setter > ( ) . Where ( x => x . Property . Name == "Foreground" )
286- . Select ( x => x . Value ) . FirstOrDefault ( ) ;
287- if ( caretBrushProperty != null && foregroundPropertyValue != null )
272+ /* Ignore Theme Window Width and use setting */
273+ if ( dict . Contains ( "WindowStyle" ) && dict [ "WindowStyle" ] is Style windowStyle )
274+ {
275+ var windowStyleProperty = windowStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( s => s . Property == FrameworkElement . WidthProperty ) ;
276+ if ( windowStyleProperty != null )
288277 {
289- queryBoxStyle . Setters . Remove ( caretBrushProperty ) ;
290- queryBoxStyle . Setters . Add ( new Setter ( TextBoxBase . CaretBrushProperty , foregroundPropertyValue ) ) ;
278+ windowStyle . Setters . Remove ( windowStyleProperty ) ;
291279 }
292-
293- // Query suggestion box's font style is aligned with query box
294- querySuggestionBoxStyle . Setters . Add ( new Setter ( Control . FontFamilyProperty , fontFamily ) ) ;
295- querySuggestionBoxStyle . Setters . Add ( new Setter ( Control . FontStyleProperty , fontStyle ) ) ;
296- querySuggestionBoxStyle . Setters . Add ( new Setter ( Control . FontWeightProperty , fontWeight ) ) ;
297- querySuggestionBoxStyle . Setters . Add ( new Setter ( Control . FontStretchProperty , fontStretch ) ) ;
280+ windowStyle . Setters . Add ( new Setter ( FrameworkElement . WidthProperty , _settings . WindowSize ) ) ;
298281 }
299-
300- if ( dict [ "ItemTitleStyle" ] is Style resultItemStyle &&
301- dict [ "ItemTitleSelectedStyle" ] is Style resultItemSelectedStyle &&
302- dict [ "ItemHotkeyStyle" ] is Style resultHotkeyItemStyle &&
303- dict [ "ItemHotkeySelectedStyle" ] is Style resultHotkeyItemSelectedStyle )
304- {
305- Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( _settings . ResultFont ) ) ;
306- Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . ResultFontStyle ) ) ;
307- Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . ResultFontWeight ) ) ;
308- Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . ResultFontStretch ) ) ;
309-
310- Setter [ ] setters = { fontFamily , fontStyle , fontWeight , fontStretch } ;
311- Array . ForEach (
312- new [ ] { resultItemStyle , resultItemSelectedStyle , resultHotkeyItemStyle , resultHotkeyItemSelectedStyle } , o
313- => Array . ForEach ( setters , p => o . Setters . Add ( p ) ) ) ;
314- }
315-
316- if (
317- dict [ "ItemSubTitleStyle" ] is Style resultSubItemStyle &&
318- dict [ "ItemSubTitleSelectedStyle" ] is Style resultSubItemSelectedStyle )
319- {
320- Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( _settings . ResultSubFont ) ) ;
321- Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . ResultSubFontStyle ) ) ;
322- Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . ResultSubFontWeight ) ) ;
323- Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . ResultSubFontStretch ) ) ;
324-
325- Setter [ ] setters = { fontFamily , fontStyle , fontWeight , fontStretch } ;
326- Array . ForEach (
327- new [ ] { resultSubItemStyle , resultSubItemSelectedStyle } , o
328- => Array . ForEach ( setters , p => o . Setters . Add ( p ) ) ) ;
329- }
330-
331- /* Ignore Theme Window Width and use setting */
332- var windowStyle = dict [ "WindowStyle" ] as Style ;
333- var width = _settings . WindowSize ;
334- windowStyle . Setters . Add ( new Setter ( FrameworkElement . WidthProperty , width ) ) ;
335282 return dict ;
336283 }
337284
0 commit comments