更新整理
This commit is contained in:
@@ -1,18 +1,8 @@
|
||||
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using WPFluent.Interop;
|
||||
using WPFluent.Interop.WinDef;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Interop;
|
||||
|
||||
using System.Windows.Threading;
|
||||
|
||||
|
||||
namespace WPFluent.Controls;
|
||||
@@ -58,22 +48,22 @@ public static class PendingBox
|
||||
{
|
||||
if (!e.Cancel)
|
||||
{
|
||||
_ = User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
}
|
||||
};
|
||||
dialog.Closed += (s, e) =>
|
||||
{
|
||||
pending.RaiseClosedEvent(s, e);
|
||||
_ = User32.EnableWindow(new WindowInteropHelper(owner).Handle, true);
|
||||
_ = User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
User32.EnableWindow(new WindowInteropHelper(owner).Handle, true);
|
||||
User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
};
|
||||
dialog.Canceled += (s, e) =>
|
||||
{
|
||||
pending.RaiseCanceledEvent(s, e);
|
||||
_ = User32.EnableWindow(new WindowInteropHelper(owner).Handle, true);
|
||||
User32.EnableWindow(new WindowInteropHelper(owner).Handle, true);
|
||||
};
|
||||
|
||||
_ = User32.EnableWindow(new WindowInteropHelper(owner).Handle, false);
|
||||
User32.EnableWindow(new WindowInteropHelper(owner).Handle, false);
|
||||
dialog.Show();
|
||||
return pending;
|
||||
});
|
||||
@@ -92,7 +82,7 @@ public static class PendingBox
|
||||
owner?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Rect rect = new();
|
||||
_ = User32.GetWindowRect(new WindowInteropHelper(owner).Handle, out rect);
|
||||
User32.GetWindowRect(new WindowInteropHelper(owner).Handle, out rect);
|
||||
Point p = new(rect.Left + (int)((rect.Right - rect.Left) / 2d), rect.Top + (int)((rect.Bottom - rect.Top) / 2d));
|
||||
center = new(p.X, p.Y);
|
||||
});
|
||||
@@ -115,7 +105,7 @@ public static class PendingBox
|
||||
{
|
||||
if (!e.Cancel)
|
||||
{
|
||||
_ = User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
User32.SetForegroundWindow(new WindowInteropHelper(owner).Handle);
|
||||
}
|
||||
};
|
||||
dialog.Closed += (s, e) =>
|
||||
@@ -164,14 +154,14 @@ file static class LayoutHelper
|
||||
}
|
||||
|
||||
Rect rect = default;
|
||||
_ = User32.GetWindowRect(hwnd, out rect);
|
||||
User32.GetWindowRect(hwnd, out rect);
|
||||
|
||||
nint monitorHandle = User32.MonitorFromWindow(hwnd, User32.MonitorDefaultTo.Nearest);
|
||||
User32.MONITORINFO monitorInfo = new()
|
||||
{
|
||||
cbSize = Marshal.SizeOf<User32.MONITORINFO>()
|
||||
};
|
||||
_ = User32.GetMonitorInfo(monitorHandle, ref monitorInfo);
|
||||
User32.GetMonitorInfo(monitorHandle, ref monitorInfo);
|
||||
Rect screen = monitorInfo.rcMonitor;
|
||||
|
||||
(double x, double y) = ((int)center.X, (int)center.Y);
|
||||
@@ -197,6 +187,6 @@ file static class LayoutHelper
|
||||
y = screen.Top + h;
|
||||
}
|
||||
|
||||
_ = User32.MoveWindow(hwnd, x, y, w, h, false);
|
||||
User32.MoveWindow(hwnd, x, y, w, h, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
|
||||
using WPFluent.Interop;
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using TextBlock = System.Windows.Controls.TextBlock;
|
||||
using WPFluent.Interop;
|
||||
|
||||
namespace WPFluent.Controls;
|
||||
|
||||
@@ -87,17 +78,17 @@ public partial class PendingBoxDialog : Window
|
||||
base.OnSourceInitialized(e);
|
||||
InvalidateMeasure();
|
||||
|
||||
if (WindowBackdrop.IsSupported(WindowBackdropType.Mica))
|
||||
{
|
||||
Background = new SolidColorBrush(Colors.Transparent);
|
||||
WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Mica);
|
||||
}
|
||||
//if (WindowBackdrop.IsSupported(WindowBackdropType.Mica))
|
||||
//{
|
||||
// Background = new SolidColorBrush(Colors.Transparent);
|
||||
// WindowBackdrop.ApplyBackdrop(this, WindowBackdropType.Mica);
|
||||
//}
|
||||
|
||||
// Hide the all window control buttons
|
||||
{
|
||||
nint hwnd = new WindowInteropHelper(this).Handle;
|
||||
long currentStyle = User32.GetWindowLong(hwnd, User32.GWL.GWL_STYLE);
|
||||
_ = User32.SetWindowLong(hwnd, User32.GWL.GWL_STYLE, currentStyle & ~User32.WS_SYSMENU);
|
||||
User32.SetWindowLong(hwnd, User32.GWL.GWL_STYLE, currentStyle & ~User32.WS_SYSMENU);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user