MainWindow: AllowsTransparency set to True

WindowIntelopHelper: Added accent handling
SettingsWindow: Added combobox with accent selector to Theme tab (not functional yet)
Languages: Added entries for accent colors (all are in english for now)

[TEMP] Blur and Accent themes experiments
[TEMP] blur set in mainwindow on load.
This commit is contained in:
Boris Makogonyuk
2015-11-10 00:51:22 +01:00
parent c456ef9118
commit f24a6f0e3c
11 changed files with 197 additions and 2 deletions

View File

@@ -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);
}
}
}

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

@@ -207,6 +207,7 @@ namespace Wox
InitialTray();
Closing += MainWindow_Closing;
}
@@ -255,6 +256,7 @@ namespace Wox
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
WindowIntelopHelper.EnableBlur(this);
CheckUpdate();
}

View File

@@ -199,7 +199,20 @@
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 2">
<TextBlock Text="{DynamicResource windowsAccents}"/>
<ComboBox Width="100">
<ComboBox.Items>
<ComboBoxItem Content="None"/>
<ComboBoxItem Content="Accent"/>
<ComboBoxItem Content="Accent Blur"/>
<ComboBoxItem Content="Blur"/>
</ComboBox.Items>
</ComboBox>
</StackPanel>
</StackPanel>
</Grid>
</Grid>

View File

@@ -0,0 +1,41 @@
<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>
<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="#80FFFFFF" />
</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>

69
Wox/Themes/Test.xaml Normal file
View File

@@ -0,0 +1,69 @@
<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>
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="#FFBBBBBB"></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">#FFBBBBBB</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,6 +258,15 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="Themes\SimpleBlur.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
<Page Include="Themes\Test.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WoxUpdate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>