Changed WindowsAccentMode (int32) Theme setting to ThemeBlurEnabled (boolean):

- Exposed a new function "SetBlurForWindow" in WindowIntelopHelper that handles the blur.
- Deleted Accent and Test themes
- Changed SimpleBlur and Base themes according to changes
This commit is contained in:
Boris Makogonyuk
2015-11-10 12:18:03 +01:00
parent 9a56ebea81
commit ece09a93cd
11 changed files with 36 additions and 142 deletions

View File

@@ -89,7 +89,11 @@ namespace Wox.Helper
public int Bottom;
}
internal enum AccentState
#region Blur Handling
/*
Found on https://github.com/riverar/sample-win10-aeroglass
*/
public enum AccentState
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
@@ -120,14 +124,23 @@ namespace Wox.Helper
WCA_ACCENT_POLICY = 19
}
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
public static void SetWindowAccent(Window wind, int themeAccentMode)
private static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
/// <summary>
/// Sets the blur for a window via SetWindowCompositionAttribute
/// </summary>
/// <param name="wind">window to blur</param>
/// <param name="status">true/false - on or off correspondingly</param>
public static void SetBlurForWindow(Window wind, bool status)
{
SetWindowAccent(wind, status ? AccentState.ACCENT_ENABLE_BLURBEHIND : AccentState.ACCENT_DISABLED);
}
private static void SetWindowAccent(Window wind, AccentState themeAccentMode)
{
if (themeAccentMode < 0 || themeAccentMode > 3)
themeAccentMode = 0;
var windowHelper = new WindowInteropHelper(wind);
var accent = new AccentPolicy();
accent.AccentState = (AccentState) themeAccentMode;
accent.AccentState = themeAccentMode;
var accentStructSize = Marshal.SizeOf(accent);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
@@ -142,5 +155,8 @@ namespace Wox.Helper
Marshal.FreeHGlobal(accentPtr);
}
#endregion
}
}

View File

@@ -255,6 +255,7 @@ namespace Wox
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
WindowIntelopHelper.SetBlurForWindow(this, UserSettingStorage.Instance.ThemeBlurEnabled);
CheckUpdate();
}

View File

@@ -460,7 +460,7 @@ namespace Wox
Dispatcher.DelayInvoke("delayChangeTheme", () =>
{
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
WindowIntelopHelper.SetWindowAccent(MainWindow, UserSettingStorage.Instance.ThemeAccentMode);
WindowIntelopHelper.SetBlurForWindow(MainWindow, UserSettingStorage.Instance.ThemeBlurEnabled);
}, TimeSpan.FromMilliseconds(100));
}

View File

@@ -1,44 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
<system:Int32 x:Key="WindowsAccentMode">2</system:Int32>
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
</Style>
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
<Setter Property="Background" Value="Transparent" />
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Background" Value="Transparent"></Setter>
</Style>
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}">
</Style>
<!-- Item Style -->
<Style x:Key="ItemTitleStyle" BasedOn="{StaticResource BaseItemTitleStyle}" TargetType="{x:Type TextBlock}">
</Style>
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}" >
</Style>
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
</Style>
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
</Style>
<Color x:Key="ItemSelectedBackgroundColor">#4F6180</Color>
<!-- button style in the middle of the scrollbar -->
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
</Style>
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}">
</Style>
</ResourceDictionary>

View File

@@ -27,8 +27,8 @@
<Setter Property="Stroke" Value="Blue" />
</Style>
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
<system:Int32 x:Key="WindowsAccentMode">0</system:Int32>
<system:Boolean x:Key="ThemeBlurEnabled">false</system:Boolean>
<!-- Item Style -->

View File

@@ -4,10 +4,9 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
<system:Int32 x:Key="WindowsAccentMode">3</system:Int32>
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="#FFFFFFFF" />
<Setter Property="Background" Value="#01000001" />

View File

@@ -4,10 +4,9 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
<system:Int32 x:Key="WindowsAccentMode">3</system:Int32>
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="#FF000000" />
<Setter Property="Background" Value="#01FFFFFF" />

View File

@@ -1,72 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
<system:Int32 x:Key="WindowsAccentMode">3</system:Int32>
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="Black"></Setter>
<Setter Property="FontFamily" Value="Helvetica"/>
<Setter Property="FontSize" Value="32"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="#AA000000"></Setter>
<Setter Property="BorderThickness" Value="10"></Setter>
<Setter Property="CornerRadius" Value="10"/>
<Setter Property="Background" Value="Transparent"></Setter>
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Background" Value="Transparent"></Setter>
<!--<Setter Property="AllowsTransparency" Value="True"></Setter>-->
</Style>
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}">
<Setter Property="Stroke" Value="Black"></Setter>
<Setter Property="StrokeThickness" Value="5"></Setter>
<Setter Property="Height" Value="5"></Setter>
</Style>
<!-- Item Style -->
<Style x:Key="ItemTitleStyle" BasedOn="{StaticResource BaseItemTitleStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#000000"></Setter>
<Setter Property="FontFamily" Value="Helvetica"/>
<Setter Property="FontSize" Value="22"/>
</Style>
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#656565"></Setter>
<Setter Property="FontFamily" Value="Helvetica"/>
</Style>
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#000000"></Setter>
<Setter Property="FontFamily" Value="Helvetica"/>
<Setter Property="FontSize" Value="22"/>
</Style>
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#656565"></Setter>
<Setter Property="FontFamily" Value="Helvetica"/>
</Style>
<Color x:Key="ItemSelectedBackgroundColor">Transparent</Color>
<!-- button style in the middle of the scrollbar -->
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border CornerRadius="2" DockPanel.Dock="Right" Background="#DEDEDE" BorderBrush="Transparent" BorderThickness="0" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}">
</Style>
</ResourceDictionary>

View File

@@ -258,21 +258,16 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="Themes\Accent.xaml">
<Page Include="Themes\SimpleBlur-Black.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
<Page Include="Themes\SimpleBlur.xaml">
<Page Include="Themes\SimpleBlur-White.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
<Page Include="Themes\Test.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Page>
<Page Include="WoxUpdate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>