Files
ShrlAlgoToolkit/AntDesignWPF/Controls/Alert/Alert.xaml

204 lines
14 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-07-31 20:12:24 +08:00
xmlns:b="clr-namespace:AntDesignWPF.Behaviors"
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-11 09:20:23 +08:00
<ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:24 +08:00
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Animations.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Controls/Control.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Dark.xaml" />-->
2025-07-11 09:20:23 +08:00
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource Ant.Control}" TargetType="{x:Type controls:Alert}">
2025-07-31 20:12:01 +08:00
<Setter Property="Padding" Value="15,8" />
2025-07-31 20:12:24 +08:00
<!--<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />-->
2025-07-11 09:20:23 +08:00
<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" />
2025-07-31 20:12:24 +08:00
<Setter Property="IconBrush" Value="{DynamicResource AntDesign.Brush.Info}" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderThickness" Value="{DynamicResource BorderThicknessBase}" />
2025-07-31 20:12:24 +08:00
<Setter Property="helpers:AntControl.BorderStyle" Value="{DynamicResource BorderStyleBase}" />
<Setter Property="helpers:AntControl.CornerRadius" Value="{DynamicResource BorderRadiusBase}" />
<!--<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 AntDesign.Brush.InfoBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.InfoBorder}" />
2025-07-11 09:20:23 +08:00
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
2025-07-31 20:12:24 +08:00
<Setter Property="b:StylizedBehaviors.Behaviors">
2025-07-11 09:20:23 +08:00
<Setter.Value>
2025-07-31 20:12:24 +08:00
<b:StylizedBehaviorCollection>
<b:VisibilityBehavior>
<b:VisibilityBehavior.Leave>
2025-07-11 09:20:23 +08:00
<Storyboard FillBehavior="Stop">
2025-07-31 20:12:01 +08:00
<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" />
2025-07-11 09:20:23 +08:00
</Storyboard>
2025-07-31 20:12:24 +08:00
</b:VisibilityBehavior.Leave>
</b:VisibilityBehavior>
</b:StylizedBehaviorCollection>
2025-07-11 09:20:23 +08:00
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
2025-07-31 20:12:24 +08:00
<controls:AntBorder
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2025-07-31 20:12:24 +08:00
BorderStyle="{TemplateBinding helpers:AntControl.BorderStyle}"
2025-07-31 20:12:01 +08:00
BorderThickness="{TemplateBinding BorderThickness}"
2025-07-31 20:12:24 +08:00
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
2025-07-31 20:12:01 +08:00
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
2025-07-11 09:20:23 +08:00
<Grid>
<Grid.Resources>
2025-07-31 20:12:01 +08:00
<!-- TODO Does it have other uses? -->
<Style TargetType="{x:Type Button}" x:Key="Ant.AlertCloseButton">
2025-07-11 09:20:23 +08:00
<Setter Property="Padding" Value="0" />
2025-07-31 20:12:24 +08:00
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Normal}" />
2025-07-11 09:20:23 +08:00
<Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type controls:Icon}">
<Setter Property="Opacity" Value="0.65" />
2025-07-31 20:12:24 +08:00
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />
2025-07-11 09:20:23 +08:00
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85" />
</Trigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding IsPressed, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Opacity" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2025-07-31 20:12:24 +08:00
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Hover}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsPressed" Value="True">
2025-07-31 20:12:24 +08:00
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Press}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<!-- Icon -->
2025-07-11 09:20:23 +08:00
<ColumnDefinition Width="Auto" />
2025-07-31 20:12:01 +08:00
<!-- Text -->
2025-07-11 09:20:23 +08:00
<ColumnDefinition Width="*" />
2025-07-31 20:12:01 +08:00
<!-- Close Button -->
2025-07-11 09:20:23 +08:00
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<!-- Message -->
2025-07-11 09:20:23 +08:00
<RowDefinition />
2025-07-31 20:12:01 +08:00
<!-- Description -->
2025-07-11 09:20:23 +08:00
<RowDefinition />
</Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<!-- Icon -->
<controls:Icon
Foreground="{TemplateBinding IconBrush}"
Margin="0,0,8,0"
Theme="Filled"
Type="{TemplateBinding Icon}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
x:Name="Icon" />
<!-- Message -->
<ContentPresenter
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToTextBlockConverter}}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="Message" />
<!-- Description -->
<ContentPresenter
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToTextBlockConverter}}"
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Visibility="Collapsed"
x:Name="Description" />
<!-- Close Button -->
<Button
Grid.Column="2"
Style="{StaticResource Ant.AlertCloseButton}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Close" />
2025-07-11 09:20:23 +08:00
</Grid>
2025-07-31 20:12:24 +08:00
</controls:AntBorder>
2025-07-11 09:20:23 +08:00
<ControlTemplate.Triggers>
2025-07-31 20:12:01 +08:00
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource IsNullConverter}}" Value="False">
<Setter Property="FontSize" TargetName="Icon" Value="24" />
<Setter Property="Theme" TargetName="Icon" Value="Outlined" />
<Setter Property="Margin" TargetName="Message" Value="0,0,0,4" />
<Setter Property="Visibility" TargetName="Description" Value="Visible" />
<Setter Property="FontSize" TargetName="PART_Close" Value="{DynamicResource FontSizeBase}" />
<Setter Property="TextElement.FontSize" TargetName="Message" Value="{DynamicResource FontSizeLarge}" />
2025-07-31 20:12:24 +08:00
<Setter Property="TextElement.Foreground" TargetName="Message" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />
2025-07-11 09:20:23 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Type" Value="Info">
<Setter Property="Icon" Value="info-circle" />
2025-07-31 20:12:24 +08:00
<Setter Property="IconBrush" Value="{DynamicResource AntDesign.Brush.Info}" />
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.InfoBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.InfoBorder}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter Property="Icon" Value="check-circle" />
2025-07-31 20:12:24 +08:00
<Setter Property="IconBrush" Value="{DynamicResource AntDesign.Brush.Success}" />
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.SuccessBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.SuccessBorder}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter Property="Icon" Value="exclamation-circle" />
2025-07-31 20:12:24 +08:00
<Setter Property="IconBrush" Value="{DynamicResource AntDesign.Brush.Warning}" />
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.WarningBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.WarningBorder}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter Property="Icon" Value="close-circle" />
2025-07-31 20:12:24 +08:00
<Setter Property="IconBrush" Value="{DynamicResource AntDesign.Brush.Error}" />
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.ErrorBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.ErrorBorder}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Banner" Value="True">
<Setter Property="BorderThickness" Value="0" />
2025-07-31 20:12:24 +08:00
<Setter Property="helpers:AntControl.CornerRadius" Value="0" />
2025-07-11 09:20:23 +08:00
</Trigger>
</Style.Triggers>
</Style>
2025-07-31 20:12:01 +08:00
2025-07-11 09:20:23 +08:00
</ResourceDictionary>