Files
ShrlAlgoToolkit/Melskin/Controls/Avatar.xaml

102 lines
5.7 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:13 +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:controls="clr-namespace:Melskin.Controls"
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
2026-02-20 15:31:44 +08:00
xmlns:ncd="clr-namespace:Melskin.Controls.Decorations">
2025-08-20 12:10:13 +08:00
2026-02-20 15:31:44 +08:00
<Style x:Key="SlotAvatarStyle" TargetType="{x:Type controls:Avatar}">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="CornerRadius" Value="20" />
<Setter Property="Width" Value="40" />
<Setter Property="Height" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Stretch" Value="Uniform" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Avatar}">
<Grid>
2026-02-20 15:31:44 +08:00
<ncd:EmbossBorder Margin="-4" CornerRadius="{TemplateBinding CornerRadius}">
2025-08-20 12:10:13 +08:00
<!--<Grid>
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=ClipMask}" />
</Grid.OpacityMask>
-->
<!-- 用于裁剪的蒙版 -->
<!--
<Border
x:Name="ClipMask"
Background="White"
CornerRadius="{TemplateBinding CornerRadius}" />
</Grid>-->
</ncd:EmbossBorder>
2025-12-23 21:35:54 +08:00
<ncd:SlotBorder
2026-02-20 15:31:44 +08:00
Margin="-4"
Padding="{TemplateBinding Padding}"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Intensity="0.2"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<Viewbox Stretch="{TemplateBinding Stretch}">
<ContentPresenter
2026-01-02 17:30:30 +08:00
Margin="{TemplateBinding Padding}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True" />
2025-08-20 12:10:13 +08:00
</Viewbox>
</ncd:SlotBorder>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-12-23 21:35:54 +08:00
<Style TargetType="{x:Type controls:Avatar}">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="CornerRadius" Value="{Binding ActualWidth, Converter={x:Static internal:DoubleToCornerRadiusConverter.Instance}, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="Width" Value="40" />
<Setter Property="Height" Value="{Binding ActualWidth, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Stretch" Value="Uniform" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Avatar}">
<Grid>
<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}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<Viewbox Stretch="{TemplateBinding Stretch}">
<ContentPresenter
2026-01-02 17:30:30 +08:00
Margin="{TemplateBinding Padding}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True" />
2025-12-23 21:35:54 +08:00
</Viewbox>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-08-20 12:10:13 +08:00
</ResourceDictionary>