This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -19,7 +19,7 @@ public enum MessageBoxButton
/// <summary>
/// The secondary button
/// </summary>
Secondary,
Accent,
/// <summary>
/// The close button

View File

@@ -40,9 +40,9 @@ public class MessageWindow : System.Windows.Window
new PropertyMetadata(string.Empty)
);
/// <summary>Identifies the <see cref="SecondaryButtonText"/> dependency property.</summary>
public static readonly DependencyProperty SecondaryButtonTextProperty = DependencyProperty.Register(
nameof(SecondaryButtonText),
/// <summary>Identifies the <see cref="AccentButtonText"/> dependency property.</summary>
public static readonly DependencyProperty AccentButtonTextProperty = DependencyProperty.Register(
nameof(AccentButtonText),
typeof(string),
typeof(MessageWindow),
new PropertyMetadata(string.Empty)
@@ -64,9 +64,9 @@ public class MessageWindow : System.Windows.Window
new PropertyMetadata(null)
);
/// <summary>Identifies the <see cref="SecondaryButtonIcon"/> dependency property.</summary>
public static readonly DependencyProperty SecondaryButtonIconProperty = DependencyProperty.Register(
nameof(SecondaryButtonIcon),
/// <summary>Identifies the <see cref="AccentButtonIcon"/> dependency property.</summary>
public static readonly DependencyProperty AccentButtonIconProperty = DependencyProperty.Register(
nameof(AccentButtonIcon),
typeof(IconElement),
typeof(MessageWindow),
new PropertyMetadata(null)
@@ -88,12 +88,12 @@ public class MessageWindow : System.Windows.Window
new PropertyMetadata(ControlAppearance.Primary)
);
/// <summary>Identifies the <see cref="SecondaryButtonAppearance"/> dependency property.</summary>
public static readonly DependencyProperty SecondaryButtonAppearanceProperty = DependencyProperty.Register(
nameof(SecondaryButtonAppearance),
/// <summary>Identifies the <see cref="AccentButtonAppearance"/> dependency property.</summary>
public static readonly DependencyProperty AccentButtonAppearanceProperty = DependencyProperty.Register(
nameof(AccentButtonAppearance),
typeof(ControlAppearance),
typeof(MessageWindow),
new PropertyMetadata(ControlAppearance.Secondary)
new PropertyMetadata(ControlAppearance.Accent)
);
/// <summary>Identifies the <see cref="CloseButtonAppearance"/> dependency property.</summary>
@@ -101,7 +101,7 @@ public class MessageWindow : System.Windows.Window
nameof(CloseButtonAppearance),
typeof(ControlAppearance),
typeof(MessageWindow),
new PropertyMetadata(ControlAppearance.Secondary)
new PropertyMetadata(ControlAppearance.Accent)
);
/// <summary>Identifies the <see cref="IsPrimaryButtonEnabled"/> dependency property.</summary>
@@ -112,9 +112,9 @@ public class MessageWindow : System.Windows.Window
new PropertyMetadata(true)
);
/// <summary>Identifies the <see cref="IsSecondaryButtonEnabled"/> dependency property.</summary>
public static readonly DependencyProperty IsSecondaryButtonEnabledProperty = DependencyProperty.Register(
nameof(IsSecondaryButtonEnabled),
/// <summary>Identifies the <see cref="IsAccentButtonEnabled"/> dependency property.</summary>
public static readonly DependencyProperty IsAccentButtonEnabledProperty = DependencyProperty.Register(
nameof(IsAccentButtonEnabled),
typeof(bool),
typeof(MessageWindow),
new PropertyMetadata(true)
@@ -149,10 +149,10 @@ public class MessageWindow : System.Windows.Window
/// <summary>
/// Gets or sets the text to be displayed on the secondary button.
/// </summary>
public string SecondaryButtonText
public string AccentButtonText
{
get => (string)GetValue(SecondaryButtonTextProperty);
set => SetValue(SecondaryButtonTextProperty, value);
get => (string)GetValue(AccentButtonTextProperty);
set => SetValue(AccentButtonTextProperty, value);
}
/// <summary>
@@ -176,10 +176,10 @@ public class MessageWindow : System.Windows.Window
/// <summary>
/// Gets or sets the <see cref="SymbolRegular"/> on the secondary button
/// </summary>
public IconElement? SecondaryButtonIcon
public IconElement? AccentButtonIcon
{
get => (IconElement?)GetValue(SecondaryButtonIconProperty);
set => SetValue(SecondaryButtonIconProperty, value);
get => (IconElement?)GetValue(AccentButtonIconProperty);
set => SetValue(AccentButtonIconProperty, value);
}
/// <summary>
@@ -203,10 +203,10 @@ public class MessageWindow : System.Windows.Window
/// <summary>
/// Gets or sets the <see cref="ControlAppearance"/> on the secondary button
/// </summary>
public ControlAppearance SecondaryButtonAppearance
public ControlAppearance AccentButtonAppearance
{
get => (ControlAppearance)GetValue(SecondaryButtonAppearanceProperty);
set => SetValue(SecondaryButtonAppearanceProperty, value);
get => (ControlAppearance)GetValue(AccentButtonAppearanceProperty);
set => SetValue(AccentButtonAppearanceProperty, value);
}
/// <summary>
@@ -221,10 +221,10 @@ public class MessageWindow : System.Windows.Window
/// <summary>
/// Gets or sets a value indicating whether the <see cref="MessageWindow"/> primary button is enabled.
/// </summary>
public bool IsSecondaryButtonEnabled
public bool IsAccentButtonEnabled
{
get => (bool)GetValue(IsSecondaryButtonEnabledProperty);
set => SetValue(IsSecondaryButtonEnabledProperty, value);
get => (bool)GetValue(IsAccentButtonEnabledProperty);
set => SetValue(IsAccentButtonEnabledProperty, value);
}
/// <summary>
@@ -432,7 +432,7 @@ public class MessageWindow : System.Windows.Window
MessageBoxResult result = button switch
{
MessageBoxButton.Primary => MessageBoxResult.Primary,
MessageBoxButton.Secondary => MessageBoxResult.Secondary,
MessageBoxButton.Accent => MessageBoxResult.Secondary,
_ => MessageBoxResult.None,
};

View File

@@ -1,21 +1,14 @@
<!--
This Source Code Form is subject to the terms of the MIT License.
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
All Rights Reserved.
-->
<ResourceDictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFluent.Controls">
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type controls:MessageWindow}">
<Setter Property="MaxWidth" Value="450" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="{DynamicResource MessageBoxBackground}" />
<Setter Property="Background" Value="{DynamicResource SolidBackgroundFillColorBaseBrush}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="{DynamicResource MessageBoxForeground}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="TextElement.FontWeight" Value="Regular" />
<Setter Property="WindowStyle" Value="ToolWindow" />
<Setter Property="ShowInTaskbar" Value="False" />
@@ -52,14 +45,14 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.RowSpan="2" Background="{DynamicResource MessageBoxTopOverlay}" />
<Border Background="{DynamicResource LayerFillColorAltBrush}" Grid.RowSpan="2" />
<TextBlock
x:Name="Title"
Grid.Row="0"
Margin="12,12,12,0"
FontWeight="SemiBold"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Title}" />
Grid.Row="0"
Margin="12,12,12,0"
Text="{TemplateBinding Title}"
x:Name="Title" />
<controls:TitleBar
Grid.Row="0"
@@ -67,12 +60,12 @@
ShowMinimize="False" />
<ContentPresenter
x:Name="ContentPresenter"
Grid.Row="1"
Margin="12,10,12,12"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}">
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Grid.Row="1"
Margin="12,10,12,12"
x:Name="ContentPresenter">
<ContentPresenter.Resources>
<Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="WrapWithOverflow" />
@@ -82,48 +75,48 @@
</ContentPresenter>
<Border
Grid.Row="2"
Padding="12"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
BorderBrush="{DynamicResource MessageBoxSeparatorBorderBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0"
CornerRadius="0">
CornerRadius="0"
Grid.Row="2"
HorizontalAlignment="Stretch"
Padding="12"
VerticalAlignment="Bottom">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="PrimaryColumn" Width="*" />
<ColumnDefinition x:Name="FirstSpacer" Width="8" />
<ColumnDefinition x:Name="SecondaryColumn" Width="*" />
<ColumnDefinition x:Name="SecondSpacer" Width="8" />
<ColumnDefinition x:Name="CloseColumn" Width="*" />
<ColumnDefinition Width="*" x:Name="PrimaryColumn" />
<ColumnDefinition Width="8" x:Name="FirstSpacer" />
<ColumnDefinition Width="*" x:Name="SecondaryColumn" />
<ColumnDefinition Width="8" x:Name="SecondSpacer" />
<ColumnDefinition Width="*" x:Name="CloseColumn" />
</Grid.ColumnDefinitions>
<controls:Button
Grid.Column="0"
HorizontalAlignment="Stretch"
Appearance="{TemplateBinding PrimaryButtonAppearance}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:MessageWindow}}, Path=TemplateButtonCommand, Mode=OneTime}"
CommandParameter="{x:Static controls:MessageBoxButton.Primary}"
Content="{TemplateBinding PrimaryButtonText}"
Grid.Column="0"
HorizontalAlignment="Stretch"
Icon="{TemplateBinding PrimaryButtonIcon}"
IsDefault="True" />
<controls:Button
Appearance="{TemplateBinding AccentButtonAppearance}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:MessageWindow}}, Path=TemplateButtonCommand, Mode=OneTime}"
CommandParameter="{x:Static controls:MessageBoxButton.Accent}"
Content="{TemplateBinding AccentButtonText}"
Grid.Column="2"
HorizontalAlignment="Stretch"
Appearance="{TemplateBinding SecondaryButtonAppearance}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:MessageWindow}}, Path=TemplateButtonCommand, Mode=OneTime}"
CommandParameter="{x:Static controls:MessageBoxButton.Secondary}"
Content="{TemplateBinding SecondaryButtonText}"
Icon="{TemplateBinding SecondaryButtonIcon}" />
Icon="{TemplateBinding AccentButtonIcon}" />
<controls:Button
Grid.Column="4"
HorizontalAlignment="Stretch"
Appearance="{TemplateBinding CloseButtonAppearance}"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:MessageWindow}}, Path=TemplateButtonCommand, Mode=OneTime}"
CommandParameter="{x:Static controls:MessageBoxButton.Close}"
Content="{TemplateBinding CloseButtonText}"
Grid.Column="4"
HorizontalAlignment="Stretch"
Icon="{TemplateBinding CloseButtonIcon}"
IsCancel="True" />
</Grid>
@@ -133,29 +126,29 @@
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="ContentPresenter" Property="Margin" Value="8" />
<Setter Property="Margin" TargetName="ContentPresenter" Value="8" />
</Trigger>
<Trigger Property="IsPrimaryButtonEnabled" Value="False">
<Setter TargetName="PrimaryColumn" Property="Width" Value="0" />
<Setter Property="Width" TargetName="PrimaryColumn" Value="0" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsPrimaryButtonEnabled" Value="False" />
<Condition Property="IsSecondaryButtonEnabled" Value="False" />
<Condition Property="IsAccentButtonEnabled" Value="False" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="SecondSpacer" Property="Width" Value="0" />
<Setter Property="Width" TargetName="SecondSpacer" Value="0" />
</MultiTrigger.Setters>
</MultiTrigger>
<Trigger Property="IsSecondaryButtonEnabled" Value="False">
<Setter TargetName="FirstSpacer" Property="Width" Value="0" />
<Setter TargetName="SecondaryColumn" Property="Width" Value="0" />
<Trigger Property="IsAccentButtonEnabled" Value="False">
<Setter Property="Width" TargetName="FirstSpacer" Value="0" />
<Setter Property="Width" TargetName="SecondaryColumn" Value="0" />
</Trigger>
<Trigger Property="PrimaryButtonText" Value="">
<Setter Property="IsPrimaryButtonEnabled" Value="False" />
</Trigger>
<Trigger Property="SecondaryButtonText" Value="">
<Setter Property="IsSecondaryButtonEnabled" Value="False" />
<Trigger Property="AccentButtonText" Value="">
<Setter Property="IsAccentButtonEnabled" Value="False" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>