功能更新
This commit is contained in:
148
Melskin/Controls/IconElement.xaml
Normal file
148
Melskin/Controls/IconElement.xaml
Normal file
@@ -0,0 +1,148 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Melskin;component/Themes/Fonts.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- 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="Padding" Value="0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<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}">
|
||||
<ContentPresenter
|
||||
Focusable="False"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
x:Name="PART_Content" />
|
||||
<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}" />
|
||||
|
||||
<Style
|
||||
BasedOn="{StaticResource IconElementStyle}"
|
||||
TargetType="controls:IconElement"
|
||||
x:Key="ToolIcon">
|
||||
<!-- <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /> -->
|
||||
<!-- <Setter Property="FontSize" Value="16" /> -->
|
||||
<Setter Property="Opacity" Value="0.65" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value="0.85" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user