@@ -25,9 +25,9 @@ public class Theme
25
25
26
26
private const int ShadowExtraMargin = 32 ;
27
27
28
- private readonly IPublicAPI API ;
29
- private readonly Settings Settings ;
30
- private readonly List < string > _themeDirectories = new List < string > ( ) ;
28
+ private readonly IPublicAPI _api ;
29
+ private readonly Settings _settings ;
30
+ private readonly List < string > _themeDirectories = new ( ) ;
31
31
private ResourceDictionary _oldResource ;
32
32
private string _oldTheme ;
33
33
private const string Folder = Constant . Themes ;
@@ -41,8 +41,8 @@ public class Theme
41
41
42
42
public Theme ( IPublicAPI publicAPI , Settings settings )
43
43
{
44
- API = publicAPI ;
45
- Settings = settings ;
44
+ _api = publicAPI ;
45
+ _settings = settings ;
46
46
47
47
_themeDirectories . Add ( DirectoryPath ) ;
48
48
_themeDirectories . Add ( UserDirectoryPath ) ;
@@ -94,7 +94,7 @@ public bool ChangeTheme(string theme)
94
94
// to things like fonts
95
95
UpdateResourceDictionary ( GetResourceDictionary ( theme ) ) ;
96
96
97
- Settings . Theme = theme ;
97
+ _settings . Theme = theme ;
98
98
99
99
100
100
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
@@ -105,7 +105,7 @@ public bool ChangeTheme(string theme)
105
105
106
106
BlurEnabled = Win32Helper . IsBlurTheme ( ) ;
107
107
108
- if ( Settings . UseDropShadowEffect && ! BlurEnabled )
108
+ if ( _settings . UseDropShadowEffect && ! BlurEnabled )
109
109
AddDropShadowEffectToCurrentTheme ( ) ;
110
110
111
111
Win32Helper . SetBlurForWindow ( Application . Current . MainWindow , BlurEnabled ) ;
@@ -115,7 +115,7 @@ public bool ChangeTheme(string theme)
115
115
Log . Error ( $ "|Theme.ChangeTheme|Theme <{ theme } > path can't be found") ;
116
116
if ( theme != defaultTheme )
117
117
{
118
- API . ShowMsgBox ( string . Format ( InternationalizationManager . Instance . GetTranslation ( "theme_load_failure_path_not_exists" ) , theme ) ) ;
118
+ _api . ShowMsgBox ( string . Format ( InternationalizationManager . Instance . GetTranslation ( "theme_load_failure_path_not_exists" ) , theme ) ) ;
119
119
ChangeTheme ( defaultTheme ) ;
120
120
}
121
121
return false ;
@@ -125,7 +125,7 @@ public bool ChangeTheme(string theme)
125
125
Log . Error ( $ "|Theme.ChangeTheme|Theme <{ theme } > fail to parse") ;
126
126
if ( theme != defaultTheme )
127
127
{
128
- API . ShowMsgBox ( string . Format ( InternationalizationManager . Instance . GetTranslation ( "theme_load_failure_parse_error" ) , theme ) ) ;
128
+ _api . ShowMsgBox ( string . Format ( InternationalizationManager . Instance . GetTranslation ( "theme_load_failure_parse_error" ) , theme ) ) ;
129
129
ChangeTheme ( defaultTheme ) ;
130
130
}
131
131
return false ;
@@ -153,7 +153,7 @@ private ResourceDictionary GetThemeResourceDictionary(string theme)
153
153
return dict ;
154
154
}
155
155
156
- private ResourceDictionary CurrentThemeResourceDictionary ( ) => GetThemeResourceDictionary ( Settings . Theme ) ;
156
+ private ResourceDictionary CurrentThemeResourceDictionary ( ) => GetThemeResourceDictionary ( _settings . Theme ) ;
157
157
158
158
public ResourceDictionary GetResourceDictionary ( string theme )
159
159
{
@@ -162,10 +162,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
162
162
if ( dict [ "QueryBoxStyle" ] is Style queryBoxStyle &&
163
163
dict [ "QuerySuggestionBoxStyle" ] is Style querySuggestionBoxStyle )
164
164
{
165
- var fontFamily = new FontFamily ( Settings . QueryBoxFont ) ;
166
- var fontStyle = FontHelper . GetFontStyleFromInvariantStringOrNormal ( Settings . QueryBoxFontStyle ) ;
167
- var fontWeight = FontHelper . GetFontWeightFromInvariantStringOrNormal ( Settings . QueryBoxFontWeight ) ;
168
- var fontStretch = FontHelper . GetFontStretchFromInvariantStringOrNormal ( Settings . QueryBoxFontStretch ) ;
165
+ var fontFamily = new FontFamily ( _settings . QueryBoxFont ) ;
166
+ var fontStyle = FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . QueryBoxFontStyle ) ;
167
+ var fontWeight = FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . QueryBoxFontWeight ) ;
168
+ var fontStretch = FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . QueryBoxFontStretch ) ;
169
169
170
170
queryBoxStyle . Setters . Add ( new Setter ( TextBox . FontFamilyProperty , fontFamily ) ) ;
171
171
queryBoxStyle . Setters . Add ( new Setter ( TextBox . FontStyleProperty , fontStyle ) ) ;
@@ -190,10 +190,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
190
190
dict [ "ItemHotkeyStyle" ] is Style resultHotkeyItemStyle &&
191
191
dict [ "ItemHotkeySelectedStyle" ] is Style resultHotkeyItemSelectedStyle )
192
192
{
193
- Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( Settings . ResultFont ) ) ;
194
- Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( Settings . ResultFontStyle ) ) ;
195
- Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( Settings . ResultFontWeight ) ) ;
196
- Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( Settings . ResultFontStretch ) ) ;
193
+ Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( _settings . ResultFont ) ) ;
194
+ Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . ResultFontStyle ) ) ;
195
+ Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . ResultFontWeight ) ) ;
196
+ Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . ResultFontStretch ) ) ;
197
197
198
198
Setter [ ] setters = { fontFamily , fontStyle , fontWeight , fontStretch } ;
199
199
Array . ForEach (
@@ -205,10 +205,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
205
205
dict [ "ItemSubTitleStyle" ] is Style resultSubItemStyle &&
206
206
dict [ "ItemSubTitleSelectedStyle" ] is Style resultSubItemSelectedStyle )
207
207
{
208
- Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( Settings . ResultSubFont ) ) ;
209
- Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( Settings . ResultSubFontStyle ) ) ;
210
- Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( Settings . ResultSubFontWeight ) ) ;
211
- Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( Settings . ResultSubFontStretch ) ) ;
208
+ Setter fontFamily = new Setter ( TextBlock . FontFamilyProperty , new FontFamily ( _settings . ResultSubFont ) ) ;
209
+ Setter fontStyle = new Setter ( TextBlock . FontStyleProperty , FontHelper . GetFontStyleFromInvariantStringOrNormal ( _settings . ResultSubFontStyle ) ) ;
210
+ Setter fontWeight = new Setter ( TextBlock . FontWeightProperty , FontHelper . GetFontWeightFromInvariantStringOrNormal ( _settings . ResultSubFontWeight ) ) ;
211
+ Setter fontStretch = new Setter ( TextBlock . FontStretchProperty , FontHelper . GetFontStretchFromInvariantStringOrNormal ( _settings . ResultSubFontStretch ) ) ;
212
212
213
213
Setter [ ] setters = { fontFamily , fontStyle , fontWeight , fontStretch } ;
214
214
Array . ForEach (
@@ -218,15 +218,15 @@ public ResourceDictionary GetResourceDictionary(string theme)
218
218
219
219
/* Ignore Theme Window Width and use setting */
220
220
var windowStyle = dict [ "WindowStyle" ] as Style ;
221
- var width = Settings . WindowSize ;
221
+ var width = _settings . WindowSize ;
222
222
windowStyle . Setters . Add ( new Setter ( Window . WidthProperty , width ) ) ;
223
223
mainWindowWidth = ( double ) width ;
224
224
return dict ;
225
225
}
226
226
227
227
private ResourceDictionary GetCurrentResourceDictionary ( )
228
228
{
229
- return GetResourceDictionary ( Settings . Theme ) ;
229
+ return GetResourceDictionary ( _settings . Theme ) ;
230
230
}
231
231
232
232
public List < ThemeData > LoadAvailableThemes ( )
0 commit comments