更新整理

This commit is contained in:
GG Z
2025-04-24 20:56:44 +08:00
parent 155cef46f8
commit 5b6d67b571
813 changed files with 14437 additions and 12362 deletions

View File

@@ -1,15 +1,17 @@
using WPFluent.Designer;
using WPFluent.Extensions;
using WPFluent.Input;
using WPFluent.Interop;
using System.Diagnostics;
using System.Windows.Data;
using System.Windows.Input;
using WPFluent.Designer;
using WPFluent.Extensions;
using WPFluent.Input;
using WPFluent.Interop;
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
@@ -237,10 +239,10 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
_titleBlock = new TextBlock();
_titleBlock.VerticalAlignment = VerticalAlignment.Center;
_ = _titleBlock.SetBinding(
_titleBlock.SetBinding(
System.Windows.Controls.TextBlock.TextProperty,
new Binding(nameof(Title)) { Source = this });
_ = _titleBlock.SetBinding(
_titleBlock.SetBinding(
System.Windows.Controls.TextBlock.FontSizeProperty,
new Binding(nameof(FontSize)) { Source = this });
Header = _titleBlock;
@@ -291,7 +293,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
$"INFO | {typeof(TitleBar)}.CloseWindow:ForceShutdown - {ForceShutdown}",
"WPFluent.TitleBar");
if(ForceShutdown)
if (ForceShutdown)
{
UiApplication.Current.Shutdown();
return;
@@ -304,7 +306,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
{
var element = GetTemplateChild(name);
if(element is not T tElement)
if (element is not T tElement)
{
throw new InvalidOperationException($"Template part '{name}' is not found or is not of type {typeof(T)}");
}
@@ -316,7 +318,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
{
var message = (User32.WM)msg;
if(message
if (message
is not (
User32.WM.NCHITTEST
or User32.WM.NCMOUSELEAVE
@@ -327,22 +329,22 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
return IntPtr.Zero;
}
foreach(TitleBarButton button in _buttons)
foreach (TitleBarButton button in _buttons)
{
if(!button.ReactToHwndHook(message, lParam, out IntPtr returnIntPtr))
if (!button.ReactToHwndHook(message, lParam, out IntPtr returnIntPtr))
{
continue;
}
// Fix for when sometimes, button hover backgrounds aren't cleared correctly, causing multiple buttons to appear as if hovered.
foreach(TitleBarButton anotherButton in _buttons)
foreach (TitleBarButton anotherButton in _buttons)
{
if(anotherButton == button)
if (anotherButton == button)
{
continue;
}
if(anotherButton.IsHovered && button.IsHovered)
if (anotherButton.IsHovered && button.IsHovered)
{
anotherButton.RemoveHover();
}
@@ -354,12 +356,12 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
var isMouseOverHeaderContent = false;
if(message == User32.WM.NCHITTEST && (TrailingContent is UIElement || Header is UIElement))
if (message == User32.WM.NCHITTEST && (TrailingContent is UIElement || Header is UIElement))
{
var headerLeftUIElement = Header as UIElement;
var headerRightUiElement = TrailingContent as UIElement;
if(headerLeftUIElement is not null && headerLeftUIElement != _titleBlock)
if (headerLeftUIElement is not null && headerLeftUIElement != _titleBlock)
{
isMouseOverHeaderContent =
headerLeftUIElement.IsMouseOverElement(lParam) ||
@@ -371,7 +373,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
}
}
switch(message)
switch (message)
{
case User32.WM.NCHITTEST when CloseWindowByDoubleClickOnIcon && _icon.IsMouseOverElement(lParam):
// Ideally, clicking on the icon should open the system menu, but when the system menu is opened manually, double-clicking on the icon does not close the window
@@ -387,19 +389,19 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
private void MaximizeWindow()
{
if(!CanMaximize)
if (!CanMaximize)
{
return;
}
if(MaximizeActionOverride is not null)
if (MaximizeActionOverride is not null)
{
MaximizeActionOverride(this, _currentWindow);
return;
}
if(_currentWindow.WindowState == WindowState.Normal)
if (_currentWindow.WindowState == WindowState.Normal)
{
SetCurrentValue(IsMaximizedProperty, true);
_currentWindow.SetCurrentValue(Window.WindowStateProperty, WindowState.Maximized);
@@ -413,7 +415,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
private void MinimizeWindow()
{
if(MinimizeActionOverride is not null)
if (MinimizeActionOverride is not null)
{
MinimizeActionOverride(this, _currentWindow);
@@ -425,7 +427,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
private void OnParentWindowStateChanged(object sender, EventArgs e)
{
if(IsMaximized != (_currentWindow.WindowState == WindowState.Maximized))
if (IsMaximized != (_currentWindow.WindowState == WindowState.Maximized))
{
SetCurrentValue(IsMaximizedProperty, _currentWindow.WindowState == WindowState.Maximized);
}
@@ -433,7 +435,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
private void OnTemplateButtonClick(TitleBarButtonType buttonType)
{
switch(buttonType)
switch (buttonType)
{
case TitleBarButtonType.Maximize
or TitleBarButtonType.Restore:
@@ -470,7 +472,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
/// </summary>
private void OnWindowContentRendered(object sender, EventArgs e)
{
if(sender is not Window window)
if (sender is not Window window)
{
return;
}
@@ -490,7 +492,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
{
var point = PointToScreen(e.GetPosition(this));
if(dpiScale is null)
if (dpiScale is null)
{
throw new InvalidOperationException("dpiScale is not initialized.");
}
@@ -511,7 +513,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
protected virtual void OnLoaded(object sender, RoutedEventArgs e)
{
if(DesignerHelper.IsInDesignMode)
if (DesignerHelper.IsInDesignMode)
{
return;
}
@@ -544,7 +546,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
_parentWindow = VisualTreeHelper.GetParent(this);
while(_parentWindow is not null and not Window)
while (_parentWindow is not null and not Window)
{
_parentWindow = VisualTreeHelper.GetParent(_parentWindow);
}
@@ -678,7 +680,7 @@ public class TitleBar : System.Windows.Controls.Control, IThemeControl
/// <summary>
/// Gets the command triggered when clicking the titlebar button.
/// </summary>
public IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty);
internal IRelayCommand TemplateButtonCommand => (IRelayCommand)GetValue(TemplateButtonCommandProperty);
/// <summary>
/// Gets or sets title displayed on the left.