Files

170 lines
8.7 KiB
Plaintext
Raw Permalink Normal View History

2025-07-31 20:12:01 +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:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
2026-02-20 15:31:44 +08:00
xmlns:internal="clr-namespace:Melskin.Converters.Internal">
<Style x:Key="CodeSwitchStyle" TargetType="{x:Type ToggleButton}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Opacity" Value="0.55" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border
2026-02-20 15:31:44 +08:00
Padding="{TemplateBinding Padding}"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2026-02-20 15:31:44 +08:00
BorderThickness="{TemplateBinding BorderThickness}">
2025-07-31 20:12:01 +08:00
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type controls:CodeBox}">
2025-08-12 23:08:54 +08:00
<!--<Setter Property="FontFamily" Value="Chinese Quote" />-->
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderThickness" Value="1" />
2025-07-31 20:12:24 +08:00
<Setter Property="Margin" Value="0,0,0,16" />
2025-07-31 20:12:01 +08:00
<Setter Property="Padding" Value="24,42,24,50" />
<Setter Property="SnapsToDevicePixels" Value="True" />
2025-08-12 23:08:54 +08:00
<Setter Property="assists:ControlAssist.CornerRadius" Value="2" />
2025-07-31 20:12:01 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:CodeBox}">
<Grid UseLayoutRounding="True">
<Grid.RowDefinitions>
<!-- Content -->
<RowDefinition Height="Auto" />
<!-- Title -->
<RowDefinition Height="Auto" />
<!-- Description -->
<RowDefinition Height="Auto" />
<!-- Code -->
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Border -->
<Border
2026-02-20 15:31:44 +08:00
Grid.Row="0"
Grid.RowSpan="4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2025-08-12 23:08:54 +08:00
CornerRadius="{Binding Path=(assists:ControlAssist.CornerRadius), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-07-31 20:12:01 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<!-- Content -->
<ContentControl
2026-02-20 15:31:44 +08:00
Grid.Row="0"
Margin="{TemplateBinding Padding}"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
2026-02-20 15:31:44 +08:00
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
2025-07-31 20:12:01 +08:00
<!-- Title -->
<ContentControl
2026-02-20 15:31:44 +08:00
Grid.Row="1"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding Title}"
ContentTemplate="{TemplateBinding TitleTemplate}"
2026-02-20 15:31:44 +08:00
Focusable="False" />
2025-07-31 20:12:01 +08:00
<!-- Description -->
<ToggleButton
2026-02-20 15:31:44 +08:00
x:Name="CodeSwitch"
2025-07-31 20:12:01 +08:00
Grid.Row="2"
2026-01-02 17:30:30 +08:00
Margin="0,0,8,8"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Right"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Bottom"
2026-02-20 15:31:44 +08:00
Style="{StaticResource CodeSwitchStyle}"
ToolTip="Show Code">
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="CodeSwitchPath"
2026-01-02 17:30:30 +08:00
Width="16"
2026-02-20 15:31:44 +08:00
Height="16"
Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}}"
Symbol="CodeOff" />
2025-07-31 20:12:01 +08:00
</ToggleButton>
<ContentControl
2026-02-20 15:31:44 +08:00
Grid.Row="2"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding Description}"
ContentTemplate="{TemplateBinding DescriptionTemplate}"
2026-02-20 15:31:44 +08:00
Focusable="False" />
2025-07-31 20:12:01 +08:00
<!-- Code -->
<ContentControl
2026-02-20 15:31:44 +08:00
x:Name="Code"
Grid.Row="3"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding Code}"
ContentTemplate="{TemplateBinding CodeTemplate}"
Focusable="False"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-07-31 20:12:01 +08:00
</Grid>
<ControlTemplate.Triggers>
2026-02-20 15:31:44 +08:00
<Trigger SourceName="CodeSwitch" Property="IsChecked" Value="True">
<Setter TargetName="CodeSwitch" Property="ToolTip" Value="Hide Code" />
<Setter TargetName="CodeSwitchPath" Property="Symbol" Value="Code" />
<Setter TargetName="Code" Property="Visibility" Value="Visible" />
2025-07-31 20:12:01 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="TitleTemplate">
<Setter.Value>
<DataTemplate>
<Canvas>
<Border
Canvas.Left="0"
Canvas.Top="0"
2026-02-20 15:31:44 +08:00
Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
BorderThickness="0,1,0,0" />
2025-07-31 20:12:01 +08:00
<TextBlock
Canvas.Left="32"
Canvas.Top="-10"
Padding="8,1"
Panel.ZIndex="1"
2026-02-20 15:31:44 +08:00
Background="{DynamicResource ControlBackgroundNormalBrush}"
FontWeight="Medium"
2025-07-31 20:12:01 +08:00
Text="{TemplateBinding Content}" />
</Canvas>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="DescriptionTemplate">
<Setter.Value>
<DataTemplate>
<ContentPresenter
2026-01-02 17:30:30 +08:00
Margin="32,18"
2026-02-20 15:31:44 +08:00
Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:StringToMarkDownConverter.Instance}}"
2025-07-31 20:12:01 +08:00
TextBlock.LineHeight="28" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="CodeTemplate">
<Setter.Value>
<DataTemplate>
<Border
2026-02-20 15:31:44 +08:00
Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
2026-01-02 17:30:30 +08:00
Padding="32,16"
2026-02-20 15:31:44 +08:00
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
BorderThickness="0,1,0,0">
2025-08-20 12:10:35 +08:00
<ContentPresenter Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:StringToCodeConverter.Instance}}" />
2025-07-31 20:12:01 +08:00
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
2025-08-12 23:08:54 +08:00
2025-07-31 20:12:24 +08:00
<!--<Style BasedOn="{StaticResource Antd.CodeBox}" TargetType="controls:CodeBox" />-->
2025-07-31 20:12:01 +08:00
</ResourceDictionary>