formatted code

This commit is contained in:
chenjie02_cd committed 2021-07-10 20:16:03 +08:00
1 parent 63aa73f427
commit 0007f95e1c
2 files changed
+16 -17

No files matched your search

@@ -1,6 +1,5 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Interop;
using HandyControl.Data; using HandyControl.Data;
using HandyControl.Tools; using HandyControl.Tools;
using HandyControl.Tools.Helper; using HandyControl.Tools.Helper;
@@ -10,29 +9,27 @@ namespace HandyControl.Controls
{ {
public class BlurWindow : Window public class BlurWindow : Window
{ {
private static readonly int WM_EXITSIZEMOVE = 0x0232; protected override void OnSourceInitialized(EventArgs e)
private static readonly int WM_ENTERSIZEMOVE = 0x0231;
public BlurWindow()
{ {
var versionInfo = SystemHelper.GetSystemVersionInfo(); var versionInfo = SystemHelper.GetSystemVersionInfo();
if (versionInfo >= SystemVersionInfo.Windows10_1903) if (versionInfo >= SystemVersionInfo.Windows10_1903)
{ {
var source = HwndSource.FromHwnd(WindowHelper.GetHandle(this)); this.GetHwndSource()?.AddHook(HwndSourceHook);
source.AddHook(WndProc);
} }
base.OnSourceInitialized(e);
} }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) private IntPtr HwndSourceHook(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
{ {
if (msg == WM_ENTERSIZEMOVE) switch (msg)
{ {
EnableBlur(this, false); case InteropValues.WM_ENTERSIZEMOVE:
} EnableBlur(this, false);
else if (msg == WM_EXITSIZEMOVE) break;
{ case InteropValues.WM_EXITSIZEMOVE:
EnableBlur(this); EnableBlur(this, true);
break;
} }
return IntPtr.Zero; return IntPtr.Zero;
@@ -41,10 +38,10 @@ namespace HandyControl.Controls
public override void OnApplyTemplate() public override void OnApplyTemplate()
{ {
base.OnApplyTemplate(); base.OnApplyTemplate();
EnableBlur(this); EnableBlur(this, true);
} }
internal static void EnableBlur(Window window, bool isEnabled = true) private static void EnableBlur(Window window, bool isEnabled)
{ {
var versionInfo = SystemHelper.GetSystemVersionInfo(); var versionInfo = SystemHelper.GetSystemVersionInfo();
@@ -72,6 +72,8 @@ namespace HandyControl.Tools.Interop
WM_LBUTTONUP = 0x0202, WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203, WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONUP = 0x0205, WM_RBUTTONUP = 0x0205,
WM_ENTERSIZEMOVE = 0x0231,
WM_EXITSIZEMOVE = 0x0232,
WM_CLIPBOARDUPDATE = 0x031D, WM_CLIPBOARDUPDATE = 0x031D,
WM_USER = 0x0400, WM_USER = 0x0400,
WS_VISIBLE = 0x10000000, WS_VISIBLE = 0x10000000,