@@ -145,11 +145,9 @@ private ResourceDictionary CurrentThemeResourceDictionary()
145
145
public ResourceDictionary GetResourceDictionary ( )
146
146
{
147
147
var dict = CurrentThemeResourceDictionary ( ) ;
148
-
149
- Style queryBoxStyle = dict [ "QueryBoxStyle" ] as Style ;
150
- Style querySuggestionBoxStyle = dict [ "QuerySuggestionBoxStyle" ] as Style ;
151
-
152
- if ( queryBoxStyle != null && querySuggestionBoxStyle != null )
148
+
149
+ if ( dict [ "QueryBoxStyle" ] is Style queryBoxStyle &&
150
+ dict [ "QuerySuggestionBoxStyle" ] is Style querySuggestionBoxStyle )
153
151
{
154
152
var fontFamily = new FontFamily ( Settings . QueryBoxFont ) ;
155
153
var fontStyle = FontHelper . GetFontStyleFromInvariantStringOrNormal ( Settings . QueryBoxFontStyle ) ;
@@ -174,19 +172,22 @@ public ResourceDictionary GetResourceDictionary()
174
172
querySuggestionBoxStyle . Setters . Add ( new Setter ( TextBox . FontStretchProperty , fontStretch ) ) ;
175
173
}
176
174
177
- Style resultItemStyle = dict [ "ItemTitleStyle" ] as Style ;
178
- Style resultSubItemStyle = dict [ "ItemSubTitleStyle" ] as Style ;
179
- Style resultItemSelectedStyle = dict [ "ItemTitleSelectedStyle" ] as Style ;
180
- Style resultSubItemSelectedStyle = dict [ "ItemSubTitleSelectedStyle" ] as Style ;
181
- if ( resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null )
175
+ if ( dict [ "ItemTitleStyle" ] is Style resultItemStyle &&
176
+ dict [ "ItemSubTitleStyle" ] is Style resultSubItemStyle &&
177
+ dict [ "ItemSubTitleSelectedStyle" ] is Style resultSubItemSelectedStyle &&
178
+ dict [ "ItemTitleSelectedStyle" ] is Style resultItemSelectedStyle &&
179
+ dict [ "ItemHotkeyStyle" ] is Style resultHotkeyItemStyle &&
180
+ dict [ "ItemHotkeySelectedStyle" ] is Style resultHotkeyItemSelectedStyle )
182
181
{
183
182
Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( Settings . ResultFont ) ) ;
184
183
Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( Settings . ResultFontStyle ) ) ;
185
184
Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( Settings . ResultFontWeight ) ) ;
186
185
Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( Settings . ResultFontStretch ) ) ;
187
186
188
187
Setter [ ] setters = { fontFamily , fontStyle , fontWeight , fontStretch } ;
189
- Array . ForEach ( new [ ] { resultItemStyle , resultSubItemStyle , resultItemSelectedStyle , resultSubItemSelectedStyle } , o => Array . ForEach ( setters , p => o . Setters . Add ( p ) ) ) ;
188
+ Array . ForEach (
189
+ new [ ] { resultItemStyle , resultSubItemStyle , resultItemSelectedStyle , resultSubItemSelectedStyle , resultHotkeyItemStyle , resultHotkeyItemSelectedStyle } , o
190
+ => Array . ForEach ( setters , p => o . Setters . Add ( p ) ) ) ;
190
191
}
191
192
192
193
var windowStyle = dict [ "WindowStyle" ] as Style ;
@@ -236,17 +237,19 @@ private string GetThemePath(string themeName)
236
237
237
238
public void AddDropShadowEffectToCurrentTheme ( )
238
239
{
239
- var dict = CurrentThemeResourceDictionary ( ) ;
240
+ var dict = GetResourceDictionary ( ) ;
240
241
241
242
var windowBorderStyle = dict [ "WindowBorderStyle" ] as Style ;
242
243
243
- var effectSetter = new Setter ( ) ;
244
- effectSetter . Property = Border . EffectProperty ;
245
- effectSetter . Value = new DropShadowEffect
244
+ var effectSetter = new Setter
246
245
{
247
- Opacity = 0.9 ,
248
- ShadowDepth = 2 ,
249
- BlurRadius = 15
246
+ Property = Border . EffectProperty ,
247
+ Value = new DropShadowEffect
248
+ {
249
+ Opacity = 0.4 ,
250
+ ShadowDepth = 2 ,
251
+ BlurRadius = 15
252
+ }
250
253
} ;
251
254
252
255
var marginSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) as Setter ;
@@ -261,7 +264,7 @@ public void AddDropShadowEffectToCurrentTheme()
261
264
}
262
265
else
263
266
{
264
- var baseMargin = ( Thickness ) marginSetter . Value ;
267
+ var baseMargin = ( Thickness ) marginSetter . Value ;
265
268
var newMargin = new Thickness (
266
269
baseMargin . Left + ShadowExtraMargin ,
267
270
baseMargin . Top + ShadowExtraMargin ,
@@ -282,8 +285,8 @@ public void RemoveDropShadowEffectFromCurrentTheme()
282
285
283
286
var effectSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . EffectProperty ) as Setter ;
284
287
var marginSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) as Setter ;
285
-
286
- if ( effectSetter != null )
288
+
289
+ if ( effectSetter != null )
287
290
{
288
291
windowBorderStyle . Setters . Remove ( effectSetter ) ;
289
292
}
@@ -371,11 +374,11 @@ private bool IsBlurTheme()
371
374
private void SetWindowAccent ( Window w , AccentState state )
372
375
{
373
376
var windowHelper = new WindowInteropHelper ( w ) ;
374
-
377
+
375
378
// this determines the width of the main query window
376
379
w . Width = mainWindowWidth ;
377
380
windowHelper . EnsureHandle ( ) ;
378
-
381
+
379
382
var accent = new AccentPolicy { AccentState = state } ;
380
383
var accentStructSize = Marshal . SizeOf ( accent ) ;
381
384
0 commit comments