Files
ShrlAlgoToolkit/Melskin/Controls/Alert.xaml
2026-02-12 21:29:00 +08:00

315 lines
20 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:converters="clr-namespace:Melskin.Converters"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
<!--<ResourceDictionary Source="/NeoUI;component/Themes/Metrics.xaml" />-->
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Button}" x:Key="AlertCloseButtonStyle">
<Setter Property="Padding" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<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>
<Style TargetType="{x:Type controls:Alert}" x:Key="AlertBaseStyle">
<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="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
<!-- 这里不放 Template由子样式决定 -->
</Style>
<Style
BasedOn="{StaticResource AlertBaseStyle}"
TargetType="{x:Type controls:Alert}"
x:Key="EmbossAlertStyle">
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
<decorations:EmbossBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
DarkShadowBrush="{TemplateBinding assists:ShadingAssist.DarkShadowBrush}"
Intensity="0.3"
LightShadowBrush="{TemplateBinding assists:ShadingAssist.LightShadowBrush}"
Padding="{TemplateBinding Padding}"
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 -->
<!--<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 converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
</Viewbox>-->
<controls:IconElement
Foreground="{TemplateBinding IconBrush}"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}"
x:Name="Icon" />
<!-- Message -->
<ContentPresenter
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
Grid.Column="1"
Grid.Row="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="Message" />
<!-- Description -->
<ContentPresenter
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed"
x:Name="Description" />
<!-- Close Button -->
<Button
Grid.Column="2"
Grid.Row="0"
Style="{StaticResource AlertCloseButtonStyle}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed"
x:Name="PART_Close" />
</Grid>
</decorations:EmbossBorder>
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
<Setter Property="Visibility" TargetName="PART_Close" Value="Visible" />
</Trigger>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
<Setter Property="Margin" TargetName="Message" Value="0,0,0,4" />
<Setter Property="Visibility" TargetName="Description" Value="Visible" />
<Setter Property="FontSize" TargetName="PART_Close" Value="14" />
<Setter Property="TextElement.FontSize" TargetName="Message" Value="16" />
<Setter Property="TextElement.Foreground" TargetName="Message" Value="{DynamicResource TextPrimaryBrush}" />
</DataTrigger>
<Trigger Property="Type" Value="Info">
<Setter Property="Symbol" TargetName="Icon" Value="Info" />
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter Property="Symbol" TargetName="Icon" Value="CheckCircle" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter Property="Symbol" TargetName="Icon" Value="Warning" />
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter Property="Symbol" TargetName="Icon" Value="Error" />
</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}" />
<Setter Property="assists:ShadingAssist.LightShadowBrush" Value="{DynamicResource InfoLightShadowBrush}" />
<Setter Property="assists:ShadingAssist.DarkShadowBrush" Value="{DynamicResource InfoDarkShadowBrush}" />
</Trigger>
<Trigger Property="Type" Value="Success">
<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}" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<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}" />
</Trigger>
<Trigger Property="Type" Value="Error">
<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}" />
</Trigger>
<Trigger Property="Banner" Value="True">
<Setter Property="assists:ControlAssist.CornerRadius" Value="0" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource AlertBaseStyle}" TargetType="{x:Type controls:Alert}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Alert}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
Padding="{TemplateBinding Padding}"
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
Foreground="{TemplateBinding IconBrush}"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}"
x:Name="Icon" />
<!-- Message -->
<ContentPresenter
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
Grid.Column="1"
Grid.Row="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="Message" />
<!-- Description -->
<ContentPresenter
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed"
x:Name="Description" />
<!-- Close Button -->
<Button
Grid.Column="2"
Grid.Row="0"
Style="{StaticResource AlertCloseButtonStyle}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed"
x:Name="PART_Close" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
<Setter Property="Visibility" TargetName="PART_Close" Value="Visible" />
</Trigger>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
<Setter Property="Margin" TargetName="Message" Value="0,0,0,4" />
<Setter Property="Visibility" TargetName="Description" Value="Visible" />
<Setter Property="FontSize" TargetName="PART_Close" Value="14" />
<Setter Property="TextElement.FontSize" TargetName="Message" Value="16" />
<Setter Property="TextElement.Foreground" TargetName="Message" Value="{DynamicResource TextPrimaryBrush}" />
</DataTrigger>
<Trigger Property="Type" Value="Info">
<Setter Property="Symbol" TargetName="Icon" Value="Info" />
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter Property="Symbol" TargetName="Icon" Value="CheckCircle" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter Property="Symbol" TargetName="Icon" Value="Warning" />
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter Property="Symbol" TargetName="Icon" Value="Error" />
</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>
</ResourceDictionary>