mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Remove AllowsTransparency which is buggy in XP and poor performance.
This commit is contained in:
73
Wox/Helper/DWMDropShadow.cs
Normal file
73
Wox/Helper/DWMDropShadow.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
|
||||||
|
namespace Wox.Helper
|
||||||
|
{
|
||||||
|
public class DwmDropShadow
|
||||||
|
{
|
||||||
|
|
||||||
|
[DllImport("dwmapi.dll", PreserveSig = true)]
|
||||||
|
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||||
|
|
||||||
|
[DllImport("dwmapi.dll")]
|
||||||
|
private static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMarInset);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops a standard shadow to a WPF Window, even if the window isborderless. Only works with DWM (Vista and Seven).
|
||||||
|
/// This method is much more efficient than setting AllowsTransparency to true and using the DropShadow effect,
|
||||||
|
/// as AllowsTransparency involves a huge permormance issue (hardware acceleration is turned off for all the window).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="window">Window to which the shadow will be applied</param>
|
||||||
|
public static void DropShadowToWindow(Window window)
|
||||||
|
{
|
||||||
|
if (!DropShadow(window))
|
||||||
|
{
|
||||||
|
window.SourceInitialized += new EventHandler(window_SourceInitialized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void window_SourceInitialized(object sender, EventArgs e) //fixed typo
|
||||||
|
{
|
||||||
|
Window window = (Window)sender;
|
||||||
|
|
||||||
|
DropShadow(window);
|
||||||
|
|
||||||
|
window.SourceInitialized -= new EventHandler(window_SourceInitialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The actual method that makes API calls to drop the shadow to the window
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="window">Window to which the shadow will be applied</param>
|
||||||
|
/// <returns>True if the method succeeded, false if not</returns>
|
||||||
|
private static bool DropShadow(Window window)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WindowInteropHelper helper = new WindowInteropHelper(window);
|
||||||
|
int val = 2;
|
||||||
|
int ret1 = DwmSetWindowAttribute(helper.Handle, 2, ref val, 4);
|
||||||
|
|
||||||
|
if (ret1 == 0)
|
||||||
|
{
|
||||||
|
Margins m = new Margins { Bottom = 0, Left = 0, Right = 0, Top = 0 };
|
||||||
|
int ret2 = DwmExtendFrameIntoClientArea(helper.Handle, ref m);
|
||||||
|
return ret2 == 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Probably dwmapi.dll not found (incompatible OS)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,8 +9,6 @@
|
|||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
WindowStartupLocation="Manual"
|
WindowStartupLocation="Manual"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
AllowsTransparency="True"
|
|
||||||
Background="{x:Null}"
|
|
||||||
Style="{DynamicResource WindowStyle}"
|
Style="{DynamicResource WindowStyle}"
|
||||||
Icon="Images\app.png"
|
Icon="Images\app.png"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace Wox
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
|
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
progressBar.ToolTip = toolTip;
|
progressBar.ToolTip = toolTip;
|
||||||
@@ -57,9 +58,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
SetTheme(CommonStorage.Instance.UserSetting.Theme);
|
SetTheme(CommonStorage.Instance.UserSetting.Theme);
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
SetTheme(CommonStorage.Instance.UserSetting.Theme = "Default");
|
SetTheme(CommonStorage.Instance.UserSetting.Theme = "Dark");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHotkey(CommonStorage.Instance.UserSetting.Hotkey, OnHotkey);
|
SetHotkey(CommonStorage.Instance.UserSetting.Hotkey, OnHotkey);
|
||||||
@@ -75,6 +76,8 @@ namespace Wox
|
|||||||
Plugins.Init();
|
Plugins.Init();
|
||||||
|
|
||||||
InitProgressbarAnimation();
|
InitProgressbarAnimation();
|
||||||
|
//only works for win7+
|
||||||
|
DwmDropShadow.DropShadowToWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
||||||
<Setter Property="BorderThickness" Value="0" />
|
|
||||||
<Setter Property="CornerRadius" Value="5" />
|
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
|
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
|
||||||
|
|||||||
@@ -13,14 +13,14 @@
|
|||||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
|
<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
|
||||||
<Setter Property="CornerRadius" Value="10" />
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="CornerRadius" Value="0" />
|
||||||
<Setter Property="Background" Value="#424242"></Setter>
|
<Setter Property="Background" Value="#424242"></Setter>
|
||||||
<Setter Property="Padding" Value="8 10 8 8" />
|
<Setter Property="Padding" Value="8 10 8 8" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
|
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
|
||||||
<Setter Property="Height" Value="80" />
|
<Setter Property="Height" Value="80" />
|
||||||
<Setter Property="Width" Value="500" />
|
<Setter Property="Width" Value="500" />
|
||||||
<Setter Property="Background" Value="#424242" />
|
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">
|
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">
|
||||||
|
|||||||
@@ -10,13 +10,11 @@
|
|||||||
<Setter Property="Foreground" Value="#000000" />
|
<Setter Property="Foreground" Value="#000000" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
||||||
<Setter Property="Background" Value="#FFFFFF"></Setter>
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
<Setter Property="BorderBrush" Value="#AAAAAA" />
|
<Setter Property="BorderBrush" Value="#AAAAAA" />
|
||||||
<Setter Property="BorderThickness" Value="10" />
|
<Setter Property="BorderThickness" Value="5" />
|
||||||
|
<Setter Property="Background" Value="#ffffff"></Setter>
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource BaseWindowStyle}" >
|
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource BaseWindowStyle}" >
|
||||||
<Setter Property="Width" Value="520"></Setter>
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}" >
|
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}" >
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
30
Wox/Themes/Pink.xaml
Normal file
30
Wox/Themes/Pink.xaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Default.xaml"></ResourceDictionary>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||||
|
<Setter Property="Background" Value="#1f1d1f"/>
|
||||||
|
<Setter Property="Foreground" Value="#cc1081" />
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
||||||
|
<Setter Property="Background" Value="#1f1d1f"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource BaseWindowStyle}" >
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}" ></Style>
|
||||||
|
<Style x:Key="ItemTitleStyle" BasedOn="{StaticResource BaseItemTitleStyle}" TargetType="{x:Type TextBlock}" >
|
||||||
|
<Setter Property="Foreground" Value="#f5f5f5"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}" >
|
||||||
|
<Setter Property="Foreground" Value="#c2c2c2"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="#f5f5f5" />
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="#c2c2c2" />
|
||||||
|
</Style>
|
||||||
|
<Color x:Key="ItemSelectedBackgroundColor">#cc1081</Color>
|
||||||
|
<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>
|
||||||
@@ -129,6 +129,7 @@
|
|||||||
<DependentUpon>CustomPluginHotkeySetting.xaml</DependentUpon>
|
<DependentUpon>CustomPluginHotkeySetting.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="DispatcherExtensions.cs" />
|
<Compile Include="DispatcherExtensions.cs" />
|
||||||
|
<Compile Include="Helper\DWMDropShadow.cs" />
|
||||||
<Compile Include="Helper\Log.cs" />
|
<Compile Include="Helper\Log.cs" />
|
||||||
<Compile Include="Helper\PluginInstaller.cs" />
|
<Compile Include="Helper\PluginInstaller.cs" />
|
||||||
<Compile Include="Helper\WoxException.cs" />
|
<Compile Include="Helper\WoxException.cs" />
|
||||||
@@ -200,6 +201,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Themes\Pink.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="WebSearchSetting.xaml">
|
<Page Include="WebSearchSetting.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user