@@ -76,7 +76,7 @@ public Theme(IPublicAPI publicAPI, Settings settings)
7676 {
7777 _api . LogError ( ClassName , "Current theme resource not found. Initializing with default theme." ) ;
7878 _oldTheme = Constant . DefaultTheme ;
79- } ;
79+ }
8080 }
8181
8282 #endregion
@@ -126,7 +126,7 @@ public void UpdateFonts()
126126 // Load a ResourceDictionary for the specified theme.
127127 var themeName = _settings . Theme ;
128128 var dict = GetThemeResourceDictionary ( themeName ) ;
129-
129+
130130 // Apply font settings to the theme resource.
131131 ApplyFontSettings ( dict ) ;
132132 UpdateResourceDictionary ( dict ) ;
@@ -152,11 +152,11 @@ private void ApplyFontSettings(ResourceDictionary dict)
152152 var fontStyle = FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . QueryBoxFontStyle ) ;
153153 var fontWeight = FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . QueryBoxFontWeight ) ;
154154 var fontStretch = FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . QueryBoxFontStretch ) ;
155-
155+
156156 SetFontProperties ( queryBoxStyle , fontFamily , fontStyle , fontWeight , fontStretch , true ) ;
157157 SetFontProperties ( querySuggestionBoxStyle , fontFamily , fontStyle , fontWeight , fontStretch , false ) ;
158158 }
159-
159+
160160 if ( dict [ "ItemTitleStyle" ] is Style resultItemStyle &&
161161 dict [ "ItemTitleSelectedStyle" ] is Style resultItemSelectedStyle &&
162162 dict [ "ItemHotkeyStyle" ] is Style resultHotkeyItemStyle &&
@@ -172,7 +172,7 @@ private void ApplyFontSettings(ResourceDictionary dict)
172172 SetFontProperties ( resultHotkeyItemStyle , fontFamily , fontStyle , fontWeight , fontStretch , false ) ;
173173 SetFontProperties ( resultHotkeyItemSelectedStyle , fontFamily , fontStyle , fontWeight , fontStretch , false ) ;
174174 }
175-
175+
176176 if ( dict [ "ItemSubTitleStyle" ] is Style resultSubItemStyle &&
177177 dict [ "ItemSubTitleSelectedStyle" ] is Style resultSubItemSelectedStyle )
178178 {
@@ -197,7 +197,7 @@ private static void SetFontProperties(Style style, FontFamily fontFamily, FontSt
197197 // First, find the setters to remove and store them in a list
198198 var settersToRemove = style . Setters
199199 . OfType < Setter > ( )
200- . Where ( setter =>
200+ . Where ( setter =>
201201 setter . Property == Control . FontFamilyProperty ||
202202 setter . Property == Control . FontStyleProperty ||
203203 setter . Property == Control . FontWeightProperty ||
@@ -227,18 +227,18 @@ private static void SetFontProperties(Style style, FontFamily fontFamily, FontSt
227227 {
228228 var settersToRemove = style . Setters
229229 . OfType < Setter > ( )
230- . Where ( setter =>
230+ . Where ( setter =>
231231 setter . Property == TextBlock . FontFamilyProperty ||
232232 setter . Property == TextBlock . FontStyleProperty ||
233233 setter . Property == TextBlock . FontWeightProperty ||
234234 setter . Property == TextBlock . FontStretchProperty )
235235 . ToList ( ) ;
236-
236+
237237 foreach ( var setter in settersToRemove )
238238 {
239239 style . Setters . Remove ( setter ) ;
240240 }
241-
241+
242242 style . Setters . Add ( new Setter ( TextBlock . FontFamilyProperty , fontFamily ) ) ;
243243 style . Setters . Add ( new Setter ( TextBlock . FontStyleProperty , fontStyle ) ) ;
244244 style . Setters . Add ( new Setter ( TextBlock . FontWeightProperty , fontWeight ) ) ;
@@ -421,7 +421,7 @@ public bool ChangeTheme(string theme = null)
421421
422422 // Retrieve theme resource – always use the resource with font settings applied.
423423 var resourceDict = GetResourceDictionary ( theme ) ;
424-
424+
425425 UpdateResourceDictionary ( resourceDict ) ;
426426
427427 _settings . Theme = theme ;
@@ -584,59 +584,42 @@ private void SetResizeBoarderThickness(Thickness? effectMargin)
584584 /// <summary>
585585 /// Refreshes the frame to apply the current theme settings.
586586 /// </summary>
587- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Usage" , "VSTHRD103:Call async methods when in an async method" , Justification = "<Pending>" ) ]
588587 public async Task RefreshFrameAsync ( )
589588 {
590- // When application is exiting, the Application.Current will be null
591- if ( Application . Current == null ) return ;
592-
593- // Must check access so that we will not block the UI thread which causes other issues
594- if ( ! Application . Current . Dispatcher . CheckAccess ( ) )
589+ await Application . Current . Dispatcher . InvokeAsync ( ( ) =>
595590 {
596- // When application is exiting, the Application.Current will be null
597- await Application . Current ? . Dispatcher . InvokeAsync ( RefreshFrameAsync , DispatcherPriority . Render ) ;
598- return ;
599- }
600-
601- // Get the actual backdrop type and drop shadow effect settings
602- var ( backdropType , useDropShadowEffect ) = GetActualValue ( ) ;
591+ // Get the actual backdrop type and drop shadow effect settings
592+ var ( backdropType , useDropShadowEffect ) = GetActualValue ( ) ;
603593
604- // Remove OS minimizing/maximizing animation
605- // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
594+ // Remove OS minimizing/maximizing animation
595+ // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
606596
607- // The timing of adding the shadow effect should vary depending on whether the theme is transparent.
608- if ( BlurEnabled )
609- {
610- AutoDropShadow ( useDropShadowEffect ) ;
611- }
612- SetBlurForWindow ( _settings . Theme , backdropType ) ;
597+ // The timing of adding the shadow effect should vary depending on whether the theme is transparent.
598+ if ( BlurEnabled )
599+ {
600+ AutoDropShadow ( useDropShadowEffect ) ;
601+ }
602+ SetBlurForWindow ( _settings . Theme , backdropType ) ;
613603
614- if ( ! BlurEnabled )
615- {
616- AutoDropShadow ( useDropShadowEffect ) ;
617- }
604+ if ( ! BlurEnabled )
605+ {
606+ AutoDropShadow ( useDropShadowEffect ) ;
607+ }
608+ } , DispatcherPriority . Render ) ;
618609 }
619610
620611 /// <summary>
621612 /// Sets the blur for a window via SetWindowCompositionAttribute
622613 /// </summary>
623614 public async Task SetBlurForWindowAsync ( )
624615 {
625- // When application is exiting, the Application.Current will be null
626- if ( Application . Current == null ) return ;
627-
628- // Must check access so that we will not block the UI thread which causes other issues
629- if ( ! Application . Current . Dispatcher . CheckAccess ( ) )
616+ await Application . Current . Dispatcher . InvokeAsync ( ( ) =>
630617 {
631- // When application is exiting, the Application.Current will be null
632- await Application . Current ? . Dispatcher . InvokeAsync ( SetBlurForWindowAsync , DispatcherPriority . Render ) ;
633- return ;
634- }
635-
636- // Get the actual backdrop type and drop shadow effect settings
637- var ( backdropType , _) = GetActualValue ( ) ;
618+ // Get the actual backdrop type and drop shadow effect settings
619+ var ( backdropType , _) = GetActualValue ( ) ;
638620
639- SetBlurForWindow ( _settings . Theme , backdropType ) ;
621+ SetBlurForWindow ( _settings . Theme , backdropType ) ;
622+ } , DispatcherPriority . Render ) ;
640623 }
641624
642625 /// <summary>
0 commit comments