129 lines
8.3 KiB
Plaintext
129 lines
8.3 KiB
Plaintext
|
|
<ResourceDictionary
|
||
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
|
|
xmlns:controls="clr-namespace:NeoUI.Controls"
|
||
|
|
xmlns:conv="clr-namespace:NeoUI.Converters"
|
||
|
|
xmlns:internal="clr-namespace:NeoUI.Converters.Internal"
|
||
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||
|
|
|
||
|
|
<FontFamily x:Key="MaterialIconFont">pack://application:,,,/NeoUI;component/Assets/#Material Symbols Rounded</FontFamily>
|
||
|
|
|
||
|
|
<!-- DataTemplates -->
|
||
|
|
<DataTemplate x:Key="MaterialTemplate">
|
||
|
|
<TextBlock
|
||
|
|
FontFamily="{Binding FontFamily, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
FontSize="{Binding FontSize, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Text="{Binding Symbol, RelativeSource={RelativeSource AncestorType=controls:IconElement}, Converter={x:Static internal:SymbolToCharConverter.Instance}}"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}" />
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<DataTemplate x:Key="GlyphTemplate">
|
||
|
|
<TextBlock
|
||
|
|
FontFamily="{Binding FontFamily, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
FontSize="{Binding FontSize, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Text="{Binding Glyph, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}" />
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<DataTemplate x:Key="ImageTemplate">
|
||
|
|
<Image
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
SnapsToDevicePixels="True"
|
||
|
|
Source="{Binding ImageSource, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Stretch="{Binding ImageStretch, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}" />
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<DataTemplate x:Key="GeometryTemplate">
|
||
|
|
<Viewbox
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Stretch="Uniform"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}">
|
||
|
|
<Path
|
||
|
|
Data="{Binding Geometry, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Fill="{Binding GeometryFill, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Stretch="Uniform"
|
||
|
|
Stroke="{Binding GeometryStroke, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
StrokeThickness="{Binding GeometryStrokeThickness, RelativeSource={RelativeSource AncestorType=controls:IconElement}}" />
|
||
|
|
</Viewbox>
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<DataTemplate x:Key="DrawingTemplate">
|
||
|
|
<Image
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Source="{Binding DrawingImage, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Stretch="Uniform"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}" />
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<DataTemplate x:Key="DrawingBrushTemplate">
|
||
|
|
<Viewbox
|
||
|
|
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Stretch="Uniform"
|
||
|
|
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType=controls:IconElement}}">
|
||
|
|
<Rectangle
|
||
|
|
Fill="{Binding DrawingBrush, RelativeSource={RelativeSource AncestorType=controls:IconElement}}"
|
||
|
|
Height="24"
|
||
|
|
Width="24" />
|
||
|
|
</Viewbox>
|
||
|
|
</DataTemplate>
|
||
|
|
|
||
|
|
<!-- 样式 -->
|
||
|
|
<Style TargetType="{x:Type controls:IconElement}" x:Key="IconElementStyle">
|
||
|
|
<Setter Property="FontFamily" Value="{StaticResource MaterialIconFont}" />
|
||
|
|
<Setter Property="FontSize" Value="16" />
|
||
|
|
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||
|
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||
|
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||
|
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||
|
|
<Setter Property="Focusable" Value="False" />
|
||
|
|
<Setter Property="Template">
|
||
|
|
<Setter.Value>
|
||
|
|
<ControlTemplate TargetType="{x:Type controls:IconElement}">
|
||
|
|
<Border Background="Transparent">
|
||
|
|
<ContentControl Focusable="False" x:Name="PART_Content" />
|
||
|
|
</Border>
|
||
|
|
<ControlTemplate.Triggers>
|
||
|
|
<Trigger Property="controls:IconElement.EffectiveContentType" Value="Material">
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource MaterialTemplate}" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="controls:IconElement.EffectiveContentType" Value="Glyph">
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource GlyphTemplate}" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="controls:IconElement.EffectiveContentType" Value="Image">
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource ImageTemplate}" />
|
||
|
|
</Trigger>
|
||
|
|
<Trigger Property="controls:IconElement.EffectiveContentType" Value="Geometry">
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource GeometryTemplate}" />
|
||
|
|
</Trigger>
|
||
|
|
<!-- Drawing (没有 Brush) -->
|
||
|
|
<MultiTrigger>
|
||
|
|
<MultiTrigger.Conditions>
|
||
|
|
<Condition Property="controls:IconElement.EffectiveContentType" Value="Drawing" />
|
||
|
|
<Condition Property="DrawingBrush" Value="{x:Null}" />
|
||
|
|
</MultiTrigger.Conditions>
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource DrawingTemplate}" />
|
||
|
|
</MultiTrigger>
|
||
|
|
<!-- DrawingBrush 优先 -->
|
||
|
|
<MultiTrigger>
|
||
|
|
<MultiTrigger.Conditions>
|
||
|
|
<Condition Property="controls:IconElement.EffectiveContentType" Value="Brush" />
|
||
|
|
</MultiTrigger.Conditions>
|
||
|
|
<Setter Property="ContentTemplate" TargetName="PART_Content" Value="{StaticResource DrawingBrushTemplate}" />
|
||
|
|
</MultiTrigger>
|
||
|
|
<Trigger Property="IsEnabled" Value="False">
|
||
|
|
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||
|
|
<Setter Property="Opacity" TargetName="PART_Content" Value="0.55" />
|
||
|
|
</Trigger>
|
||
|
|
</ControlTemplate.Triggers>
|
||
|
|
</ControlTemplate>
|
||
|
|
</Setter.Value>
|
||
|
|
</Setter>
|
||
|
|
</Style>
|
||
|
|
|
||
|
|
<!-- 默认引用 -->
|
||
|
|
<Style BasedOn="{StaticResource IconElementStyle}" TargetType="{x:Type controls:IconElement}" />
|
||
|
|
</ResourceDictionary>
|