功能更新
This commit is contained in:
101
Melskin/Controls/Decorations/SlotBorder.xaml
Normal file
101
Melskin/Controls/Decorations/SlotBorder.xaml
Normal file
@@ -0,0 +1,101 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:conv="clr-namespace:Melskin.Converters"
|
||||
xmlns:dec="clr-namespace:Melskin.Controls.Decorations"
|
||||
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style TargetType="{x:Type dec:SlotBorder}">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="LightShadowBrush" Value="{DynamicResource LightShadowBrush}" />
|
||||
<Setter Property="DarkShadowBrush" Value="{DynamicResource DarkShadowBrush}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="CornerRadius" Value="4" />
|
||||
<Setter Property="Padding" Value="2" />
|
||||
<Setter Property="ShaderEnabled" Value="True" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Intensity" Value="1" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type dec:SlotBorder}">
|
||||
<Grid>
|
||||
<!-- 隐藏阴影的时候呈现背景色 -->
|
||||
<!-- 默认4的边距显示光影效果 -->
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="4" />
|
||||
<!-- 内阴影效果 -->
|
||||
<Grid Visibility="{TemplateBinding ShaderEnabled, Converter={x:Static conv:BooleanToVisibilityConverter.CollapsedInstance}}">
|
||||
<!-- 背景填充 -->
|
||||
<Rectangle Fill="{TemplateBinding Background}" />
|
||||
<!-- 左上阴影 -->
|
||||
<Border
|
||||
Background="{TemplateBinding DarkShadowBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="{TemplateBinding Intensity,
|
||||
Converter={x:Static internal:IntensityToSlotShadowMarginConverter.Instance}}" />
|
||||
<!-- 右下高亮 -->
|
||||
<Border
|
||||
Background="{TemplateBinding LightShadowBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="{TemplateBinding Intensity,
|
||||
Converter={x:Static internal:IntensityToSlotLightMarginConverter.Instance}}" />
|
||||
<!-- 背景中央 -->
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="{TemplateBinding Intensity,
|
||||
Converter={x:Static internal:IntensityToSlotMarginConverter.Instance}}" />
|
||||
<!-- 裁切区域 -->
|
||||
<Grid.Clip>
|
||||
<MultiBinding
|
||||
Converter="{x:Static internal:CreateSlotClipGeometryConverter.Instance}"
|
||||
ConverterParameter="4"
|
||||
Mode="OneWay">
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="CornerRadius"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualWidth"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
<Binding
|
||||
Mode="OneWay"
|
||||
Path="ActualHeight"
|
||||
RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
</MultiBinding>
|
||||
</Grid.Clip>
|
||||
<Grid.Effect>
|
||||
<BlurEffect Radius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Intensity, Converter={x:Static internal:IntensityToSlotBlurConverter.Instance}, Mode=OneWay}" />
|
||||
</Grid.Effect>
|
||||
</Grid>
|
||||
<!-- 显示边框和内容 -->
|
||||
<!-- 默认4的边距显示光影效果 -->
|
||||
<Border
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Margin="4">
|
||||
<ContentPresenter
|
||||
Focusable="False"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
TextElement.Foreground="{TemplateBinding Foreground}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="contentPresenter" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user