Files
ShrlAlgoToolkit/NeoUI/Melskin/Controls/CodeBox.xaml

170 lines
8.7 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-01-02 17:30:30 +08:00
xmlns:assists="clr-namespace:VariaStudio.Assists"
xmlns:controls="clr-namespace:VariaStudio.Controls"
xmlns:internal="clr-namespace:VariaStudio.Converters.Internal"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type ToggleButton}" x:Key="CodeSwitchStyle">
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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2026-01-02 17:30:30 +08:00
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
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
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}}"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
Grid.RowSpan="4"
2025-07-31 20:12:01 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<!-- Content -->
<ContentControl
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
2026-01-02 17:30:30 +08:00
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Grid.Row="0"
Margin="{TemplateBinding Padding}" />
2025-07-31 20:12:01 +08:00
<!-- Title -->
<ContentControl
Content="{TemplateBinding Title}"
ContentTemplate="{TemplateBinding TitleTemplate}"
2026-01-02 17:30:30 +08:00
Focusable="False"
Grid.Row="1" />
2025-07-31 20:12:01 +08:00
<!-- Description -->
<ToggleButton
Grid.Row="2"
2025-12-23 21:35:54 +08:00
HorizontalAlignment="Right"
2026-01-02 17:30:30 +08:00
Margin="0,0,8,8"
2025-12-23 21:35:54 +08:00
Style="{StaticResource CodeSwitchStyle}"
2026-01-02 17:30:30 +08:00
ToolTip="Show Code"
VerticalAlignment="Bottom"
x:Name="CodeSwitch">
<controls:IconElement
2025-12-23 21:35:54 +08:00
Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}}"
2026-01-02 17:30:30 +08:00
Height="16"
Symbol="CodeOff"
Width="16"
x:Name="CodeSwitchPath" />
2025-07-31 20:12:01 +08:00
</ToggleButton>
<ContentControl
Content="{TemplateBinding Description}"
ContentTemplate="{TemplateBinding DescriptionTemplate}"
2026-01-02 17:30:30 +08:00
Focusable="False"
Grid.Row="2" />
2025-07-31 20:12:01 +08:00
<!-- Code -->
<ContentControl
Content="{TemplateBinding Code}"
ContentTemplate="{TemplateBinding CodeTemplate}"
Focusable="False"
2026-01-02 17:30:30 +08:00
Grid.Row="3"
Visibility="Collapsed"
x:Name="Code" />
2025-07-31 20:12:01 +08:00
</Grid>
<ControlTemplate.Triggers>
2026-01-02 17:30:30 +08:00
<Trigger Property="IsChecked" SourceName="CodeSwitch" Value="True">
<Setter Property="ToolTip" TargetName="CodeSwitch" Value="Hide Code" />
<Setter Property="Symbol" TargetName="CodeSwitchPath" Value="Code" />
<Setter Property="Visibility" TargetName="Code" 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
2026-01-02 17:30:30 +08:00
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
BorderThickness="0,1,0,0"
2025-07-31 20:12:01 +08:00
Canvas.Left="0"
Canvas.Top="0"
2026-01-02 17:30:30 +08:00
Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}" />
2025-07-31 20:12:01 +08:00
<TextBlock
2026-01-02 17:30:30 +08:00
Background="{DynamicResource ControlBackgroundNormalBrush}"
2025-07-31 20:12:01 +08:00
Canvas.Left="32"
Canvas.Top="-10"
2026-01-02 17:30:30 +08:00
FontWeight="Medium"
2025-07-31 20:12:01 +08:00
Padding="8,1"
Panel.ZIndex="1"
Text="{TemplateBinding Content}" />
</Canvas>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="DescriptionTemplate">
<Setter.Value>
<DataTemplate>
<ContentPresenter
2025-12-23 21:35:54 +08:00
Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:StringToMarkDownConverter.Instance}}"
2026-01-02 17:30:30 +08:00
Margin="32,18"
2025-07-31 20:12:01 +08:00
TextBlock.LineHeight="28" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="CodeTemplate">
<Setter.Value>
<DataTemplate>
<Border
2025-12-23 21:35:54 +08:00
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}"
2026-01-02 17:30:30 +08:00
BorderThickness="0,1,0,0"
Padding="32,16"
Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type controls:CodeBox}}}">
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>