diff --git a/Wox/Helper/WindowIntelopHelper.cs b/Wox/Helper/WindowIntelopHelper.cs index 4a0223a19e..a9dd5ab217 100644 --- a/Wox/Helper/WindowIntelopHelper.cs +++ b/Wox/Helper/WindowIntelopHelper.cs @@ -88,5 +88,59 @@ namespace Wox.Helper public int Right; public int Bottom; } + + internal enum AccentState + { + ACCENT_DISABLED = 0, + ACCENT_ENABLE_GRADIENT = 1, + ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, + ACCENT_ENABLE_BLURBEHIND = 3, + ACCENT_INVALID_STATE = 4 + } + + [StructLayout(LayoutKind.Sequential)] + internal struct AccentPolicy + { + public AccentState AccentState; + public int AccentFlags; + public int GradientColor; + public int AnimationId; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct WindowCompositionAttributeData + { + public WindowCompositionAttribute Attribute; + public IntPtr Data; + public int SizeOfData; + } + + internal enum WindowCompositionAttribute + { + WCA_ACCENT_POLICY = 19 + } + [DllImport("user32.dll")] + internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); + public static void EnableBlur(Window wind) + { + var windowHelper = new WindowInteropHelper(wind); + + var accent = new AccentPolicy(); + accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND; + accent.GradientColor = 16711680; + var accentStructSize = Marshal.SizeOf(accent); + + var accentPtr = Marshal.AllocHGlobal(accentStructSize); + Marshal.StructureToPtr(accent, accentPtr, false); + + var data = new WindowCompositionAttributeData(); + data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY; + data.SizeOfData = accentStructSize; + data.Data = accentPtr; + + SetWindowCompositionAttribute(windowHelper.Handle, ref data); + + Marshal.FreeHGlobal(accentPtr); + } } } \ No newline at end of file diff --git a/Wox/Languages/en.xaml b/Wox/Languages/en.xaml index 71b8cccf6a..8f53a74ff0 100644 --- a/Wox/Languages/en.xaml +++ b/Wox/Languages/en.xaml @@ -43,6 +43,8 @@ Result Item Font Window Mode Opacity + Windows Accents + Hotkey diff --git a/Wox/Languages/ru.xaml b/Wox/Languages/ru.xaml index 13a7be86cc..0c25bfb5a2 100644 --- a/Wox/Languages/ru.xaml +++ b/Wox/Languages/ru.xaml @@ -43,6 +43,7 @@ Шрифт результатов Оконный режим Прозрачность + Windows Accents Горячие клавиши diff --git a/Wox/Languages/zh-cn.xaml b/Wox/Languages/zh-cn.xaml index 0823b5f3e0..8db385c98d 100644 --- a/Wox/Languages/zh-cn.xaml +++ b/Wox/Languages/zh-cn.xaml @@ -43,7 +43,8 @@ 结果项字体 窗口模式 透明度 - + Windows Accents + 热键 Wox激活热键 diff --git a/Wox/Languages/zh-tw.xaml b/Wox/Languages/zh-tw.xaml index 5d8907fe7a..780bc115a5 100644 --- a/Wox/Languages/zh-tw.xaml +++ b/Wox/Languages/zh-tw.xaml @@ -43,6 +43,7 @@ 結果項字體 窗口模式 透明度 + Windows Accents 熱鍵 diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index 4b5a315fed..e3f249642e 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -13,7 +13,9 @@ AllowDrop="True" ShowInTaskbar="False" Style="{DynamicResource WindowStyle}" - Icon="Images\app.png"> + Icon="Images\app.png" + AllowsTransparency="True" + > diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 5a289131ed..ef46b74f51 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -207,6 +207,7 @@ namespace Wox InitialTray(); Closing += MainWindow_Closing; + } @@ -255,6 +256,7 @@ namespace Wox InitProgressbarAnimation(); WindowIntelopHelper.DisableControlBox(this); + WindowIntelopHelper.EnableBlur(this); CheckUpdate(); } diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 3d94b8fd5b..402aa1506b 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -199,7 +199,20 @@ + + + + + + + + + + + + + diff --git a/Wox/Themes/SimpleBlur.xaml b/Wox/Themes/SimpleBlur.xaml new file mode 100644 index 0000000000..acb26e0ba8 --- /dev/null +++ b/Wox/Themes/SimpleBlur.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + #4F6180 + + + + + + diff --git a/Wox/Themes/Test.xaml b/Wox/Themes/Test.xaml new file mode 100644 index 0000000000..108852a6f5 --- /dev/null +++ b/Wox/Themes/Test.xaml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + #FFBBBBBB + + + + + + diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 7d46e6109a..140595f5a5 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -258,6 +258,15 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + + + Designer + MSBuild:Compile + Designer MSBuild:Compile