Skip to content

Commit 7a85439

Browse files
committed
Improve code quality
1 parent db37ab7 commit 7a85439

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public class Theme
3434
private string _oldTheme;
3535
private const string Folder = Constant.Themes;
3636
private const string Extension = ".xaml";
37-
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
38-
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
37+
private static string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
38+
private static string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
3939

4040
public string CurrentTheme => _settings.Theme;
4141

@@ -119,7 +119,7 @@ private void AutoDropShadow()
119119
}
120120
}
121121

122-
private void SetWindowCornerPreference(string cornerType)
122+
private static void SetWindowCornerPreference(string cornerType)
123123
{
124124
Application.Current.Dispatcher.Invoke(() =>
125125
{
@@ -173,13 +173,13 @@ public void SetBlurForWindow()
173173

174174
// Apply the blur effect
175175
Win32Helper.DWMSetBackdropForWindow(mainWindow, _settings.BackdropType);
176-
ColorizeWindow(GetSystemBG());
176+
ColorizeWindow();
177177
}
178178
else
179179
{
180180
// Apply default style when Blur is disabled
181181
Win32Helper.DWMSetBackdropForWindow(mainWindow, BackdropTypes.None);
182-
ColorizeWindow(GetSystemBG());
182+
ColorizeWindow();
183183
}
184184

185185
UpdateResourceDictionary(dict);
@@ -266,7 +266,7 @@ private void ApplyPreviewBackground(Color? bgColor = null)
266266
}, DispatcherPriority.Render);
267267
}
268268

269-
private void ColorizeWindow(string mode)
269+
private void ColorizeWindow()
270270
{
271271
Application.Current.Dispatcher.Invoke(() =>
272272
{
@@ -363,7 +363,7 @@ private void ColorizeWindow(string mode)
363363
}, DispatcherPriority.Normal);
364364
}
365365

366-
public bool IsBlurTheme()
366+
private static bool IsBlurTheme()
367367
{
368368
if (!Win32Helper.IsBackdropSupported()) // Windows 11 미만이면 무조건 false
369369
return false;
@@ -373,21 +373,6 @@ public bool IsBlurTheme()
373373
return resource is bool b && b;
374374
}
375375

376-
public string GetSystemBG()
377-
{
378-
if (Environment.OSVersion.Version >= new Version(6, 2))
379-
{
380-
var resource = Application.Current.TryFindResource("SystemBG");
381-
382-
if (resource is string str)
383-
return str;
384-
385-
return null;
386-
}
387-
388-
return null;
389-
}
390-
391376
#endregion
392377

393378
private void MakeSureThemeDirectoriesExist()
@@ -544,9 +529,9 @@ public ResourceDictionary GetResourceDictionary(string theme)
544529
return dict;
545530
}
546531

547-
private ResourceDictionary GetCurrentResourceDictionary( )
532+
private ResourceDictionary GetCurrentResourceDictionary()
548533
{
549-
return GetResourceDictionary(_settings.Theme);
534+
return GetResourceDictionary(_settings.Theme);
550535
}
551536

552537
public List<ThemeData> LoadAvailableThemes()
@@ -583,7 +568,7 @@ private ThemeData GetThemeDataFromPath(string path)
583568
{
584569
if (line.StartsWith(ThemeMetadataNamePrefix, StringComparison.OrdinalIgnoreCase))
585570
{
586-
name = line.Remove(0, ThemeMetadataNamePrefix.Length).Trim();
571+
name = line[ThemeMetadataNamePrefix.Length..].Trim();
587572
}
588573
else if (line.StartsWith(ThemeMetadataIsDarkPrefix, StringComparison.OrdinalIgnoreCase))
589574
{

0 commit comments

Comments
 (0)