Files
Shrlalgo.RvKits/Melskin/Controls/Alert.xaml
2026-02-20 15:31:44 +08:00

315 lines
20 KiB
XML
Raw Permalink 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:x="http://schemas.microsoft.com/winfx/2006/xaml"
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">
<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 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">
<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 x:Key="AlertBaseStyle" 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="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
<!-- 这里不放 Template由子样式决定 -->
</Style>
<Style
x:Key="EmbossAlertStyle"
BasedOn="{StaticResource AlertBaseStyle}"
TargetType="{x:Type controls:Alert}">
<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
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
DarkShadowBrush="{TemplateBinding assists:ShadingAssist.DarkShadowBrush}"
Intensity="0.3"
LightShadowBrush="{TemplateBinding assists:ShadingAssist.LightShadowBrush}"
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
x:Name="Icon"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Foreground="{TemplateBinding IconBrush}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
<!-- Message -->
<ContentPresenter
x:Name="Message"
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
<!-- Description -->
<ContentPresenter
x:Name="Description"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
Visibility="Collapsed" />
<!-- Close Button -->
<Button
x:Name="PART_Close"
Grid.Row="0"
Grid.Column="2"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Style="{StaticResource AlertCloseButtonStyle}"
Visibility="Collapsed" />
</Grid>
</decorations:EmbossBorder>
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
<Setter TargetName="PART_Close" Property="Visibility" Value="Visible" />
</Trigger>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters: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="Icon" Property="Symbol" Value="Info" />
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter TargetName="Icon" Property="Symbol" Value="CheckCircle" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter TargetName="Icon" Property="Symbol" Value="Warning" />
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter TargetName="Icon" Property="Symbol" 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
Padding="{TemplateBinding Padding}"
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
x:Name="Icon"
Margin="0,0,8,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Foreground="{TemplateBinding IconBrush}"
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" />
<!-- Message -->
<ContentPresenter
x:Name="Message"
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
<!-- Description -->
<ContentPresenter
x:Name="Description"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
Visibility="Collapsed" />
<!-- Close Button -->
<Button
x:Name="PART_Close"
Grid.Row="0"
Grid.Column="2"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Style="{StaticResource AlertCloseButtonStyle}"
Visibility="Collapsed" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Closable" Value="True">
<Setter TargetName="PART_Close" Property="Visibility" Value="Visible" />
</Trigger>
<!-- With Description -->
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters: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="Icon" Property="Symbol" Value="Info" />
</Trigger>
<Trigger Property="Type" Value="Success">
<Setter TargetName="Icon" Property="Symbol" Value="CheckCircle" />
</Trigger>
<Trigger Property="Type" Value="Warning">
<Setter TargetName="Icon" Property="Symbol" Value="Warning" />
</Trigger>
<Trigger Property="Type" Value="Error">
<Setter TargetName="Icon" Property="Symbol" 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>