diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index 358500911..14a223eaf 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -56,6 +56,12 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public bool EnablePythonPlugins { get; set; } + [JsonProperty] + public double Opacity { get; set; } + + [JsonProperty] + public OpacityMode OpacityMode { get; set; } + public List LoadDefaultWebSearches() { List webSearches = new List(); @@ -123,6 +129,16 @@ namespace Wox.Infrastructure.Storage.UserSettings Hotkey = "Alt + Space"; QueryBoxFont = FontFamily.GenericSansSerif.Name; ResultItemFont = FontFamily.GenericSansSerif.Name; + Opacity = 1; + OpacityMode = OpacityMode.Normal; } + + } + + public enum OpacityMode + { + Normal = 0, + LayeredWindow = 1, + DWM = 2 } } diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 2b02ed8c9..245968619 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -51,6 +51,9 @@ namespace Wox InitializeComponent(); initialized = true; + if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow) + this.AllowsTransparency = true; + System.Net.WebRequest.RegisterPrefix("data", new DataWebRequestFactory()); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; @@ -89,8 +92,10 @@ namespace Wox Plugins.Init(); InitProgressbarAnimation(); + //only works for win7+ - DwmDropShadow.DropShadowToWindow(this); + if (UserSettingStorage.Instance.OpacityMode == OpacityMode.DWM) + DwmDropShadow.DropShadowToWindow(this); WindowIntelopHelper.DisableControlBox(this); } @@ -461,6 +466,11 @@ namespace Wox Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(dict); + + if (this.AllowsTransparency) + this.Opacity = UserSettingStorage.Instance.Opacity; + else + this.Opacity = 1; } #region Public API diff --git a/Wox/OpacityModeConverter.cs b/Wox/OpacityModeConverter.cs new file mode 100644 index 000000000..4e1300cd7 --- /dev/null +++ b/Wox/OpacityModeConverter.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Data; +using System.Windows.Markup; +using Wox.Infrastructure.Storage.UserSettings; + +namespace Wox +{ + public class OpacityModeConverter : MarkupExtension, IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (!(value is OpacityMode)) return value.ToString(); + + var mode = (OpacityMode) value; + switch (mode) + { + case OpacityMode.Normal: + return "Normal Window"; + case OpacityMode.LayeredWindow: + { + if (Environment.OSVersion.Version.Major < 5) + return "Layered Window (not supported by your Windows)"; + if (Environment.OSVersion.Version.Major == 5) + return "Layered Window (not recommended on your Windows)"; + return "Layered Window"; + } + case OpacityMode.DWM: + { + if (Environment.OSVersion.Version.Major < 6) + return "DWM-Enabled Window (not supported by your Windows)"; + return "DWM-Enabled Window"; + } + } + return value.ToString(); + } + + public object ConvertBack( + object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + } +} diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index b179df311..099001392 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -1,7 +1,8 @@ - - - - + + + - Wox Hotkey: + - - + + - Custom Plugin Hotkey: + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + - - + - - + +