Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/Alert.xaml
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

221 lines
14 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:controls="clr-namespace:NeoUI.Controls"
xmlns:conv="clr-namespace:NeoUI.Converters">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/NeoUI;component/Animations/Animations.xaml" />
<ResourceDictionary Source="/NeoUI;component/Assets/CommonGeometry.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:Alert}">
<Setter Property="Padding" Value="15,8" />
<!--<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />-->
<Setter Property="IsTabStop" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="None" />
<Setter Property="IconBrush" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="assists:ControlAssist.CornerRadius" Value="4" />
<!--<Setter Property="Background" Value="{Binding IconBrush, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=1}" />-->
<!--<Setter Property="BorderBrush" Value="{Binding IconBrush, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=3}" />-->
<!--<Setter Property="Background" Value="{DynamicResource PrimaryHighlightBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />-->
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
<!--<Setter Property="b:StylizedBehaviors.Behaviors">
<Setter.Value>
<b:StylizedBehaviorCollection>
<b:VisibilityBehavior>
<b:VisibilityBehavior.Leave>
<Storyboard FillBehavior="Stop">
<DoubleAnimation
Duration="0:0:0.3"
EasingFunction="{StaticResource EaseInOutCirc}"
From="1"
Storyboard.TargetProperty="Opacity"
To="0" />
<DoubleAnimation
Duration="0:0:0.3"
EasingFunction="{StaticResource EaseInOutCirc}"
From="1"
Storyboard.TargetProperty="RenderTransform.ScaleY"
To="0" />
</Storyboard>
</b:VisibilityBehavior.Leave>
</b:VisibilityBehavior>
</b:StylizedBehaviorCollection>
</Setter.Value>
</Setter>-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<Grid>
<Grid.Resources>
<!-- TODO 是否可复用? -->
<Style x:Key="AlertCloseButton" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type controls:IconElement}">
<Setter Property="Opacity" Value="0.65" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85" />
</Trigger>
<DataTrigger Binding="{Binding IsPressed, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource ControlStrongBackgroundFocusedBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="{DynamicResource ControlStrongBackgroundBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<!-- Icon -->
<ColumnDefinition Width="Auto" />
<!-- Text -->
<ColumnDefinition Width="*" />
<!-- Close Button -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!-- Message -->
<RowDefinition />
<!-- Description -->
<RowDefinition />
</Grid.RowDefinitions>
<!-- Icon -->
<Viewbox
x:Name="Icon"
Width="{TemplateBinding FontSize}"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Path
x:Name="IconPath"
Fill="{TemplateBinding IconBrush}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:BooleanToVisibilityConverter.CollapsedInstance}}" />
</Viewbox>
<!--<controls:SymbolIcon
Foreground="{TemplateBinding IconBrush}"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:BooleanToVisibilityConverter.CollapsedInstance}}"
x:Name="Icon" />-->
<!-- Message -->
<ContentPresenter
x:Name="Message"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}" />
<!-- Description -->
<ContentPresenter
x:Name="Description"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
Visibility="Collapsed" />
<!-- Close Button -->
<Button
x:Name="PART_Close"
Grid.Column="2"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Style="{StaticResource AlertCloseButton}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static conv:NullOrEmptyConverter.Instance}}" Value="False">
<Setter TargetName="Message" Property="Margin" Value="0,0,0,4" />
<Setter TargetName="Description" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_Close" Property="FontSize" Value="14" />
<Setter TargetName="Message" Property="TextElement.FontSize" Value="16" />
<Setter TargetName="Message" Property="TextElement.Foreground" Value="{DynamicResource TextPrimaryBrush}" />
</DataTrigger>
<Trigger Property="Type" Value="Info">
<Setter TargetName="IconPath" Property="Data" Value="{DynamicResource info-circle}" />
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter TargetName="IconPath" Property="Data" Value="{DynamicResource check-circle}" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter TargetName="IconPath" Property="Data" Value="{DynamicResource exclamation-circle}" />
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter TargetName="IconPath" Property="Data" Value="{DynamicResource close-circle}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Type" Value="Info">
<!--<Setter Property="Icon" Value="info-circle" />-->
<Setter Property="IconBrush" Value="{DynamicResource InfoBrush}" />
<Setter Property="Background" Value="{DynamicResource InfoLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource InfoDisabledBrush}" />
</Trigger>
<Trigger Property="Type" Value="Success">
<!--<Setter Property="Icon" Value="check-circle" />-->
<Setter Property="IconBrush" Value="{DynamicResource SuccessBrush}" />
<Setter Property="Background" Value="{DynamicResource SuccessLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SuccessDisabledBrush}" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<!--<Setter Property="Icon" Value="exclamation-circle" />-->
<Setter Property="IconBrush" Value="{DynamicResource WarningBrush}" />
<Setter Property="Background" Value="{DynamicResource WarningLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource WarningDisabledBrush}" />
</Trigger>
<Trigger Property="Type" Value="Error">
<!--<Setter Property="Icon" Value="close-circle" />-->
<Setter Property="IconBrush" Value="{DynamicResource ErrorBrush}" />
<Setter Property="Background" Value="{DynamicResource ErrorLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ErrorDisabledBrush}" />
</Trigger>
<Trigger Property="Banner" Value="True">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="assists:ControlAssist.CornerRadius" Value="0" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>