diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs
index fe64e0c3e..e7a19d6a4 100644
--- a/Flow.Launcher.Core/Resource/Theme.cs
+++ b/Flow.Launcher.Core/Resource/Theme.cs
@@ -28,6 +28,8 @@ namespace Flow.Launcher.Core.Resource
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
+ public bool BlurEnabled { get; set; }
+
public Theme()
{
_themeDirectories.Add(DirectoryPath);
@@ -88,7 +90,9 @@ namespace Flow.Launcher.Core.Resource
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
}
- if (Settings.UseDropShadowEffect)
+ BlurEnabled = IsBlurTheme();
+
+ if (Settings.UseDropShadowEffect && !BlurEnabled)
AddDropShadowEffectToCurrentTheme();
}
catch (DirectoryNotFoundException e)
@@ -252,7 +256,7 @@ namespace Flow.Launcher.Core.Resource
UpdateResourceDictionary(dict);
}
- public void RemoveDropShadowEffectToCurrentTheme()
+ public void RemoveDropShadowEffectFromCurrentTheme()
{
var dict = CurrentThemeResourceDictionary();
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
@@ -320,30 +324,29 @@ namespace Flow.Launcher.Core.Resource
///
public void SetBlurForWindow()
{
+ if (BlurEnabled)
+ {
+ SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_ENABLE_BLURBEHIND);
+ }
+ else
+ {
+ SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_DISABLED);
+ }
+ }
- // Exception of FindResource can't be cathed if global exception handle is set
+ private bool IsBlurTheme()
+ {
if (Environment.OSVersion.Version >= new Version(6, 2))
{
var resource = Application.Current.TryFindResource("ThemeBlurEnabled");
- bool blur;
- if (resource is bool)
- {
- blur = (bool)resource;
- }
- else
- {
- blur = false;
- }
- if (blur)
- {
- SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_ENABLE_BLURBEHIND);
- }
- else
- {
- SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_DISABLED);
- }
+ if (resource is bool)
+ return (bool)resource;
+
+ return false;
}
+
+ return false;
}
private void SetWindowAccent(Window w, AccentState state)
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index 4355cda15..177953912 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -61,7 +61,8 @@ namespace Flow.Launcher
// show notify icon when flowlauncher is hidden
InitializeNotifyIcon();
- // todo is there a way to set blur only once?
+ // currently blur can only be called when loading main window.
+ // is there a way to set blur only once?
ThemeManager.Instance.SetBlurForWindow();
WindowsInteropHelper.DisableControlBox(this);
InitProgressbarAnimation();
diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml
index 0d966f1d6..1a8a12100 100644
--- a/Flow.Launcher/SettingWindow.xaml
+++ b/Flow.Launcher/SettingWindow.xaml
@@ -242,7 +242,7 @@
-
+
diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
index b974efd03..b476599b5 100644
--- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
+++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs
@@ -271,6 +271,10 @@ namespace Flow.Launcher.ViewModel
{
Settings.Theme = value;
ThemeManager.Instance.ChangeTheme(value);
+
+ if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect)
+ DropShadowEffect = false;
+
}
}
@@ -282,13 +286,19 @@ namespace Flow.Launcher.ViewModel
get { return Settings.UseDropShadowEffect; }
set
{
+ if (ThemeManager.Instance.BlurEnabled && value)
+ {
+ MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
+ return;
+ }
+
if (value)
{
ThemeManager.Instance.AddDropShadowEffectToCurrentTheme();
}
else
{
- ThemeManager.Instance.RemoveDropShadowEffectToCurrentTheme();
+ ThemeManager.Instance.RemoveDropShadowEffectFromCurrentTheme();
}
Settings.UseDropShadowEffect = value;