mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
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:
@@ -56,7 +56,7 @@ namespace Wox.Core.Theme
|
|||||||
ResourceMerger.ApplyThemeResource(this);
|
ResourceMerger.ApplyThemeResource(this);
|
||||||
|
|
||||||
UserSettingStorage.Instance.Theme = themeName;
|
UserSettingStorage.Instance.Theme = themeName;
|
||||||
UserSettingStorage.Instance.ThemeAccentMode = (int)Application.Current.Resources["WindowsAccentMode"];
|
UserSettingStorage.Instance.ThemeBlurEnabled = (bool)Application.Current.Resources["ThemeBlurEnabled"];
|
||||||
UserSettingStorage.Instance.Save();
|
UserSettingStorage.Instance.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Wox.Core.UserSettings
|
|||||||
public string ResultItemFontStretch { get; set; }
|
public string ResultItemFontStretch { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public int ThemeAccentMode { get; set; }
|
public bool ThemeBlurEnabled { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public double WindowLeft { get; set; }
|
public double WindowLeft { get; set; }
|
||||||
|
|||||||
@@ -89,7 +89,11 @@ namespace Wox.Helper
|
|||||||
public int Bottom;
|
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_DISABLED = 0,
|
||||||
ACCENT_ENABLE_GRADIENT = 1,
|
ACCENT_ENABLE_GRADIENT = 1,
|
||||||
@@ -120,14 +124,23 @@ namespace Wox.Helper
|
|||||||
WCA_ACCENT_POLICY = 19
|
WCA_ACCENT_POLICY = 19
|
||||||
}
|
}
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
private static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||||
public static void SetWindowAccent(Window wind, int themeAccentMode)
|
|
||||||
|
/// <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 windowHelper = new WindowInteropHelper(wind);
|
||||||
var accent = new AccentPolicy();
|
var accent = new AccentPolicy();
|
||||||
accent.AccentState = (AccentState) themeAccentMode;
|
accent.AccentState = themeAccentMode;
|
||||||
var accentStructSize = Marshal.SizeOf(accent);
|
var accentStructSize = Marshal.SizeOf(accent);
|
||||||
|
|
||||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||||
@@ -142,5 +155,8 @@ namespace Wox.Helper
|
|||||||
|
|
||||||
Marshal.FreeHGlobal(accentPtr);
|
Marshal.FreeHGlobal(accentPtr);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +255,7 @@ namespace Wox
|
|||||||
|
|
||||||
InitProgressbarAnimation();
|
InitProgressbarAnimation();
|
||||||
WindowIntelopHelper.DisableControlBox(this);
|
WindowIntelopHelper.DisableControlBox(this);
|
||||||
|
WindowIntelopHelper.SetBlurForWindow(this, UserSettingStorage.Instance.ThemeBlurEnabled);
|
||||||
CheckUpdate();
|
CheckUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ namespace Wox
|
|||||||
Dispatcher.DelayInvoke("delayChangeTheme", () =>
|
Dispatcher.DelayInvoke("delayChangeTheme", () =>
|
||||||
{
|
{
|
||||||
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||||
WindowIntelopHelper.SetWindowAccent(MainWindow, UserSettingStorage.Instance.ThemeAccentMode);
|
WindowIntelopHelper.SetBlurForWindow(MainWindow, UserSettingStorage.Instance.ThemeBlurEnabled);
|
||||||
}, TimeSpan.FromMilliseconds(100));
|
}, TimeSpan.FromMilliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
<Setter Property="Stroke" Value="Blue" />
|
<Setter Property="Stroke" Value="Blue" />
|
||||||
</Style>
|
</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 -->
|
<!-- Item Style -->
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Base.xaml" />
|
<ResourceDictionary Source="Base.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
|
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
|
||||||
<system:Int32 x:Key="WindowsAccentMode">3</system:Int32>
|
|
||||||
|
|
||||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||||
<Setter Property="Foreground" Value="#FFFFFFFF" />
|
<Setter Property="Foreground" Value="#FFFFFFFF" />
|
||||||
<Setter Property="Background" Value="#01000001" />
|
<Setter Property="Background" Value="#01000001" />
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Base.xaml" />
|
<ResourceDictionary Source="Base.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<!-- Windows Accent Mode: 0 - none, 1 - Accent color, 2 - Accent with transparency, 3 - Blur -->
|
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
|
||||||
<system:Int32 x:Key="WindowsAccentMode">3</system:Int32>
|
|
||||||
|
|
||||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||||
<Setter Property="Foreground" Value="#FF000000" />
|
<Setter Property="Foreground" Value="#FF000000" />
|
||||||
<Setter Property="Background" Value="#01FFFFFF" />
|
<Setter Property="Background" Value="#01FFFFFF" />
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -258,21 +258,16 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<Page Include="Themes\Accent.xaml">
|
<Page Include="Themes\SimpleBlur-Black.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Themes\SimpleBlur.xaml">
|
<Page Include="Themes\SimpleBlur-White.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Themes\Test.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Page>
|
|
||||||
<Page Include="WoxUpdate.xaml">
|
<Page Include="WoxUpdate.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user