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

70 lines
4.2 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cvt="clr-namespace:Melskin.Converters"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
xmlns:internal="clr-namespace:Melskin.Converters.Internal">
<Style TargetType="{x:Type decorations:EmbossBorder}">
<Setter Property="Focusable" Value="False" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="4" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Intensity" Value="1" />
<Setter Property="LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
<Setter Property="DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type decorations:EmbossBorder}">
<Grid>
<!-- 光影区域 -->
<!-- 默认4的边距显示光影效果 -->
<Grid Margin="4" Visibility="{TemplateBinding ShaderEnabled, Converter={x:Static cvt:BooleanToVisibilityConverter.CollapsedInstance}}">
<!-- 暗部 -->
<Border
x:Name="DarkBorder"
Margin="{TemplateBinding Intensity,
Converter={x:Static internal:IntensityToEmbossMarginRightBottomConverter.Instance}}"
Background="{TemplateBinding DarkShadowBrush}"
CornerRadius="{TemplateBinding CornerRadius}" />
<!-- 亮部 -->
<Border
Margin="{TemplateBinding Intensity,
Converter={x:Static internal:IntensityToEmbossMarginLeftTopConverter.Instance}}"
Background="{TemplateBinding LightShadowBrush}"
CornerRadius="{TemplateBinding CornerRadius}" />
<!-- 模糊效果 -->
<Grid.Effect>
<BlurEffect Radius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Intensity, Converter={x:Static internal:IntensityToEmbossBlurConverter.Instance}, Mode=OneWay}" />
</Grid.Effect>
</Grid>
<!-- 内容区域 -->
<!-- 默认4的边距显示光影效果 -->
<Border
Margin="4"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter
x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>