Merge pull request #383 from lances101/dev

Wox now has Blur
This commit is contained in:
qianlifeng
2015-11-13 11:05:29 +08:00
15 changed files with 214 additions and 6 deletions

View File

@@ -88,5 +88,75 @@ namespace Wox.Helper
public int Right;
public int Bottom;
}
#region Blur Handling
/*
Found on https://github.com/riverar/sample-win10-aeroglass
*/
public 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")]
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)
{
var windowHelper = new WindowInteropHelper(wind);
var accent = new AccentPolicy();
accent.AccentState = themeAccentMode;
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);
}
#endregion
}
}

View File

@@ -43,6 +43,8 @@
<system:String x:Key="resultItemFont">Result Item Font</system:String>
<system:String x:Key="windowMode">Window Mode</system:String>
<system:String x:Key="opacity">Opacity</system:String>
<system:String x:Key="windowsAccents">Windows Accents</system:String>
<!--Setting Hotkey-->
<system:String x:Key="hotkey">Hotkey</system:String>

View File

@@ -43,6 +43,7 @@
<system:String x:Key="resultItemFont">Шрифт результатов</system:String>
<system:String x:Key="windowMode">Оконный режим</system:String>
<system:String x:Key="opacity">Прозрачность</system:String>
<system:String x:Key="windowsAccents">Windows Accents</system:String>
<!--Setting Hotkey-->
<system:String x:Key="hotkey">Горячие клавиши</system:String>

View File

@@ -43,7 +43,8 @@
<system:String x:Key="resultItemFont">结果项字体</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<system:String x:Key="windowsAccents">Windows Accents</system:String>
<!--设置,热键-->
<system:String x:Key="hotkey">热键</system:String>
<system:String x:Key="woxHotkey">Wox激活热键</system:String>

View File

@@ -43,6 +43,7 @@
<system:String x:Key="resultItemFont">結果項字體</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
<system:String x:Key="opacity">透明度</system:String>
<system:String x:Key="windowsAccents">Windows Accents</system:String>
<!--設置,熱鍵-->
<system:String x:Key="hotkey">熱鍵</system:String>

View File

@@ -13,7 +13,9 @@
AllowDrop="True"
ShowInTaskbar="False"
Style="{DynamicResource WindowStyle}"
Icon="Images\app.png">
Icon="Images\app.png"
AllowsTransparency="True"
>
<Window.Resources>
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
</Window.Resources>

View File

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

View File

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

View File

@@ -27,6 +27,10 @@
<Setter Property="Stroke" Value="Blue" />
</Style>
<system:Boolean x:Key="ThemeBlurEnabled">false</system:Boolean>
<!-- Item Style -->
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#FFFFF8" />

View File

@@ -14,6 +14,8 @@
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
</Style>
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}">
</Style>

View File

@@ -0,0 +1,54 @@
<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>
<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" />
</Style>
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
<Setter Property="Background" Value="#CC000000" />
<Setter Property="BorderBrush" Value="#50FFFFFF" />
<Setter Property="BorderThickness" Value="10" />
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Background" Value="#01000001"></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}">
<Setter Property="Margin" Value="0, -10"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Margin" Value="0, -10"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Color x:Key="ItemSelectedBackgroundColor">#356ef3</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}">
<Setter Property="Background" Value="#a0a0a0"/>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,54 @@
<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>
<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" />
</Style>
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
<Setter Property="Background" Value="#CCFFFFFF" />
<Setter Property="BorderBrush" Value="#70000000" />
<Setter Property="BorderThickness" Value="10" />
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Background" Value="#01FFFFFF"></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}">
<Setter Property="Margin" Value="0, -10"/>
<Setter Property="Foreground" Value="#FF000000"/>
</Style>
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#FF000000"/>
</Style>
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Margin" Value="0, -10"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#FFFFFFFF"/>
</Style>
<Color x:Key="ItemSelectedBackgroundColor">#356ef3</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}">
<Setter Property="Background" Value="#a0a0a0"/>
</Style>
</ResourceDictionary>

View File

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