Files
ShrlAlgoToolkit/Melskin/Controls/Alert.xaml

315 lines
20 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-20 15:31:44 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2026-01-02 17:30:41 +08:00
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:converters="clr-namespace:Melskin.Converters"
2026-02-20 15:31:44 +08:00
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
2025-07-11 09:20:23 +08:00
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
2025-12-23 21:35:54 +08:00
<!--<ResourceDictionary Source="/NeoUI;component/Themes/Metrics.xaml" />-->
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
2025-07-11 09:20:23 +08:00
</ResourceDictionary.MergedDictionaries>
2025-12-23 21:35:54 +08:00
2026-02-20 15:31:44 +08:00
<Style x:Key="AlertCloseButtonStyle" 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="Button">
2025-12-23 21:35:54 +08:00
<controls:IconElement Style="{StaticResource ToolIcon}" Symbol="Close" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
</Trigger>
</Style.Triggers>
</Style>
2025-12-23 21:35:54 +08:00
2026-02-20 15:31:44 +08:00
<Style x:Key="AlertBaseStyle" TargetType="{x:Type controls:Alert}">
2025-07-31 20:12:01 +08:00
<Setter Property="Padding" Value="15,8" />
2025-08-24 13:49:55 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
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-08-12 23:08:54 +08:00
<Setter Property="IconBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
2025-12-23 21:35:54 +08:00
<!-- 这里不放 Template由子样式决定 -->
</Style>
<Style
2026-02-20 15:31:44 +08:00
x:Key="EmbossAlertStyle"
2025-12-23 21:35:54 +08:00
BasedOn="{StaticResource AlertBaseStyle}"
2026-02-20 15:31:44 +08:00
TargetType="{x:Type controls:Alert}">
2025-12-23 21:35:54 +08:00
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
2025-09-04 22:39:00 +08:00
<decorations:EmbossBorder
2026-02-20 15:31:44 +08:00
Padding="{TemplateBinding Padding}"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2025-08-12 23:08:54 +08:00
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
DarkShadowBrush="{TemplateBinding assists:ShadingAssist.DarkShadowBrush}"
2025-09-04 23:13:36 +08:00
Intensity="0.3"
LightShadowBrush="{TemplateBinding assists:ShadingAssist.LightShadowBrush}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
2025-07-31 20:12:01 +08:00
UseLayoutRounding="True">
2025-07-11 09:20:23 +08:00
<Grid>
<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 -->
<!--<Viewbox
2025-08-20 12:10:35 +08:00
x:Name="Icon"
2025-08-12 23:08:54 +08:00
Width="{TemplateBinding FontSize}"
2025-08-20 12:10:35 +08:00
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
2025-08-12 23:08:54 +08:00
<Path
2025-08-20 12:10:35 +08:00
x:Name="IconPath"
2025-08-12 23:08:54 +08:00
Fill="{TemplateBinding IconBrush}"
2025-09-04 22:39:00 +08:00
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
</Viewbox>-->
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="Icon"
2025-07-31 20:12:01 +08:00
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Foreground="{TemplateBinding IconBrush}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
2025-07-31 20:12:01 +08:00
<!-- Message -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Message"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="1"
2025-07-31 20:12:01 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-07-31 20:12:01 +08:00
<!-- Description -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Description"
Grid.Row="1"
2025-07-31 20:12:01 +08:00
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2026-01-02 17:30:30 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
Visibility="Collapsed" />
2025-07-31 20:12:01 +08:00
<!-- Close Button -->
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_Close"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="2"
2026-01-02 17:30:30 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Style="{StaticResource AlertCloseButtonStyle}"
Visibility="Collapsed" />
2025-07-11 09:20:23 +08:00
</Grid>
2025-09-04 22:39:00 +08:00
</decorations:EmbossBorder>
2025-07-11 09:20:23 +08:00
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_Close" Property="Visibility" Value="Visible" />
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- With Description -->
2025-09-04 22:39:00 +08:00
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
2026-02-20 15:31:44 +08:00
<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}" />
2025-07-11 09:20:23 +08:00
</DataTrigger>
2025-08-12 23:08:54 +08:00
<Trigger Property="Type" Value="Info">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Info" />
2025-08-12 23:08:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Success">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="CheckCircle" />
2025-08-12 23:08:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Warning">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Warning" />
2025-08-12 23:08:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Error">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Error" />
2025-08-12 23:08:54 +08:00
</Trigger>
2025-07-11 09:20:23 +08:00
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Type" Value="Info">
2025-08-20 12:10:35 +08:00
<Setter Property="IconBrush" Value="{DynamicResource InfoBrush}" />
<Setter Property="Background" Value="{DynamicResource InfoLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource InfoDisabledBrush}" />
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource InfoLightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource InfoDarkShadowBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Success">
2025-08-12 23:08:54 +08:00
<Setter Property="IconBrush" Value="{DynamicResource SuccessBrush}" />
<Setter Property="Background" Value="{DynamicResource SuccessLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SuccessDisabledBrush}" />
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource SuccessLightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource SuccessDarkShadowBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Warning">
2025-08-12 23:08:54 +08:00
<Setter Property="IconBrush" Value="{DynamicResource WarningBrush}" />
<Setter Property="Background" Value="{DynamicResource WarningLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource WarningDisabledBrush}" />
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource WarningLightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource WarningDarkShadowBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Type" Value="Error">
2025-08-12 23:08:54 +08:00
<Setter Property="IconBrush" Value="{DynamicResource ErrorBrush}" />
<Setter Property="Background" Value="{DynamicResource ErrorLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ErrorDisabledBrush}" />
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource ErrorLightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource ErrorDarkShadowBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="Banner" Value="True">
2025-08-12 23:08:54 +08:00
<Setter Property="assists:ControlAssist.CornerRadius" Value="0" />
2025-07-11 09:20:23 +08:00
</Trigger>
</Style.Triggers>
</Style>
2025-12-23 21:35:54 +08:00
<Style BasedOn="{StaticResource AlertBaseStyle}" TargetType="{x:Type controls:Alert}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
<Border
2026-02-20 15:31:44 +08:00
Padding="{TemplateBinding Padding}"
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<Grid>
<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 -->
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="Icon"
2025-12-23 21:35:54 +08:00
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Foreground="{TemplateBinding IconBrush}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
2025-12-23 21:35:54 +08:00
<!-- Message -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Message"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="1"
2025-12-23 21:35:54 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-12-23 21:35:54 +08:00
<!-- Description -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Description"
Grid.Row="1"
2025-12-23 21:35:54 +08:00
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2026-01-02 17:30:30 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
Visibility="Collapsed" />
2025-12-23 21:35:54 +08:00
<!-- Close Button -->
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_Close"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="2"
2026-01-02 17:30:30 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Style="{StaticResource AlertCloseButtonStyle}"
Visibility="Collapsed" />
2025-12-23 21:35:54 +08:00
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_Close" Property="Visibility" Value="Visible" />
2025-12-23 21:35:54 +08:00
</Trigger>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
2026-02-20 15:31:44 +08:00
<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}" />
2025-12-23 21:35:54 +08:00
</DataTrigger>
<Trigger Property="Type" Value="Info">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Info" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Success">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="CheckCircle" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Warning">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Warning" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="Type" Value="Error">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Icon" Property="Symbol" Value="Error" />
2025-12-23 21:35:54 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Type" Value="Info">
<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="IconBrush" Value="{DynamicResource SuccessBrush}" />
<Setter Property="Background" Value="{DynamicResource SuccessLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SuccessDisabledBrush}" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<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="IconBrush" Value="{DynamicResource ErrorBrush}" />
<Setter Property="Background" Value="{DynamicResource ErrorLightShadowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ErrorDisabledBrush}" />
</Trigger>
<Trigger Property="Banner" Value="True">
<Setter Property="assists:ControlAssist.CornerRadius" Value="0" />
</Trigger>
</Style.Triggers>
</Style>
2025-07-31 20:12:01 +08:00
2025-07-11 09:20:23 +08:00
</ResourceDictionary>