Files
ShrlAlgoToolkit/Melskin/Controls/NumberBox.xaml

306 lines
19 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:35 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-12 21:29:00 +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"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
2026-02-12 21:29:00 +08:00
xmlns:internal="clr-namespace:Melskin.Converters.Internal">
2025-08-20 12:10:35 +08:00
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Controls/Button.xaml" />
2025-08-20 12:10:35 +08:00
</ResourceDictionary.MergedDictionaries>
2026-02-12 21:29:00 +08:00
<Style x:Key="SlotNumberBoxStyle" TargetType="{x:Type controls:NumberBox}">
2025-08-20 12:10:35 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
2025-12-28 11:47:54 +08:00
<Setter Property="BorderThickness" Value="0" />
2026-02-12 21:29:00 +08:00
<Setter Property="Padding" Value="3" />
2025-08-20 12:10:35 +08:00
<Setter Property="Focusable" Value="False" />
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:35 +08:00
<Setter Property="VerticalContentAlignment" Value="Center" />
2025-12-28 11:47:54 +08:00
<Setter Property="VerticalAlignment" Value="Center" />
2025-08-20 12:10:35 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:NumberBox}">
2025-08-20 12:10:35 +08:00
<decorations:SlotBorder
2026-02-12 21:29:00 +08:00
x:Name="slot"
Padding="{TemplateBinding Padding}"
2025-08-20 12:10:35 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-02-12 21:29:00 +08:00
Intensity="0.2">
2025-08-20 12:10:35 +08:00
<Grid>
<Grid.ColumnDefinitions>
<!-- 前缀 -->
<ColumnDefinition Width="Auto" />
<!-- 输入框 -->
<ColumnDefinition Width="*" />
<!-- 后缀 -->
<ColumnDefinition Width="Auto" />
2025-12-23 21:35:54 +08:00
<ColumnDefinition Width="Auto" />
2025-08-20 12:10:35 +08:00
</Grid.ColumnDefinitions>
<ContentPresenter
2026-02-12 21:29:00 +08:00
x:Name="Prefix"
2025-08-20 12:10:35 +08:00
Grid.Column="0"
Margin="1,0,5,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Content="{TemplateBinding assists:InputAssist.Prefix}"
Focusable="False" />
2025-08-20 12:10:35 +08:00
<TextBox
2026-02-12 21:29:00 +08:00
x:Name="PART_TextBox"
2025-08-20 12:10:35 +08:00
Grid.Column="1"
2026-01-02 17:30:30 +08:00
Padding="0"
2026-02-12 21:29:00 +08:00
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-08-20 12:10:35 +08:00
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Background="Transparent"
Style="{DynamicResource FlattenTextBoxStyle}">
2025-08-20 12:10:35 +08:00
<!--<TextBox.Text>
<MultiBinding Converter="{StaticResource PrecisionConverter}" UpdateSourceTrigger="PropertyChanged">
<Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Precision" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</TextBox.Text>-->
</TextBox>
2025-12-23 21:35:54 +08:00
<!-- Suffix -->
<ContentPresenter
2026-02-12 21:29:00 +08:00
x:Name="Suffix"
2025-12-23 21:35:54 +08:00
Grid.Column="2"
Margin="5,0,1,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Content="{TemplateBinding assists:InputAssist.Suffix}"
Focusable="False" />
2025-08-20 12:10:35 +08:00
<Border
2026-02-12 21:29:00 +08:00
x:Name="border"
2026-01-02 17:30:30 +08:00
Grid.Column="3"
2026-02-12 21:29:00 +08:00
Margin="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static internal:NegativeConverter.Instance}}"
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Right"
2026-02-12 21:29:00 +08:00
Background="Transparent"
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1,0,0,0">
2025-12-28 11:47:54 +08:00
<Grid Width="15">
2025-08-20 12:10:35 +08:00
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="1" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button
2026-02-12 21:29:00 +08:00
x:Name="PART_IncreaseButton"
2025-08-20 12:10:35 +08:00
Grid.Row="0"
2025-12-28 11:47:54 +08:00
Padding="-3"
2025-08-20 12:10:35 +08:00
assists:ControlAssist.CornerRadius="0,4,0,0"
2026-02-12 21:29:00 +08:00
FontSize="4"
IsTabStop="False"
Style="{DynamicResource FlattenButtonStyle}">
<controls:IconElement
2026-02-12 21:29:00 +08:00
x:Name="arrowUp"
Foreground="{DynamicResource TextPrimaryBrush}"
RenderTransformOrigin="0.5,0.5"
SnapsToDevicePixels="false"
2026-02-12 21:29:00 +08:00
Symbol="KeyboardArrowUp">
<controls:IconElement.RenderTransform>
<RotateTransform Angle="0" />
</controls:IconElement.RenderTransform>
</controls:IconElement>
</Button>
2025-08-20 12:10:35 +08:00
<Rectangle
Grid.Row="1"
2026-02-12 21:29:00 +08:00
Height="1"
Fill="{DynamicResource BorderNormalBrush}" />
2025-08-20 12:10:35 +08:00
<Button
2026-02-12 21:29:00 +08:00
x:Name="PART_DecreaseButton"
2025-08-20 12:10:35 +08:00
Grid.Row="2"
2025-12-28 11:47:54 +08:00
Padding="-3"
2025-08-20 12:10:35 +08:00
assists:ControlAssist.CornerRadius="0,0,4,0"
2026-02-12 21:29:00 +08:00
FontSize="4"
IsTabStop="False"
Style="{DynamicResource FlattenButtonStyle}">
<controls:IconElement
2026-02-12 21:29:00 +08:00
x:Name="arrowDown"
Foreground="{DynamicResource TextPrimaryBrush}"
RenderTransformOrigin="0.5,0.5"
SnapsToDevicePixels="false"
2026-02-12 21:29:00 +08:00
Symbol="KeyboardArrowDown">
<controls:IconElement.RenderTransform>
<RotateTransform Angle="0" />
</controls:IconElement.RenderTransform>
</controls:IconElement>
</Button>
2025-08-20 12:10:35 +08:00
</Grid>
</Border>
2025-12-23 21:35:54 +08:00
2025-08-20 12:10:35 +08:00
</Grid>
</decorations:SlotBorder>
<ControlTemplate.Triggers>
<!-- Prefix & Suffix -->
2026-02-12 21:29:00 +08:00
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:35 +08:00
</Trigger>
2026-02-12 21:29:00 +08:00
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:35 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource BorderCornerLightedGradientBrush}" />
2025-08-20 12:10:35 +08:00
<!--<Setter TargetName="border" Property="Visibility" Value="Visible"/>-->
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-08-20 12:10:35 +08:00
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2026-02-12 21:29:00 +08:00
<Setter TargetName="slot" Property="ShaderEnabled" Value="False" />
2025-12-23 21:35:54 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:NumberBox}">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Focusable" Value="False" />
2026-02-12 21:29:00 +08:00
<Setter Property="BorderThickness" Value="0" />
2026-02-20 15:31:44 +08:00
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="3" />
2025-12-23 21:35:54 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
2025-12-28 11:47:54 +08:00
<Setter Property="VerticalAlignment" Value="Center" />
2025-12-23 21:35:54 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:NumberBox}">
<Border
2026-02-12 21:29:00 +08:00
x:Name="Border"
Padding="{TemplateBinding Padding}"
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-02-12 21:29:00 +08:00
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}">
2025-12-23 21:35:54 +08:00
<Grid>
<Grid.ColumnDefinitions>
<!-- 前缀 -->
<ColumnDefinition Width="Auto" />
<!-- 输入框 -->
<ColumnDefinition Width="*" />
<!-- 后缀 -->
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
2026-02-12 21:29:00 +08:00
x:Name="Prefix"
2025-12-23 21:35:54 +08:00
Grid.Column="0"
Margin="1,0,5,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Content="{TemplateBinding assists:InputAssist.Prefix}"
Focusable="False" />
2025-12-23 21:35:54 +08:00
<TextBox
2026-02-12 21:29:00 +08:00
x:Name="PART_TextBox"
2025-12-23 21:35:54 +08:00
Grid.Column="1"
2026-02-20 15:31:44 +08:00
Margin="5"
2026-01-02 17:30:30 +08:00
Padding="0"
2026-02-12 21:29:00 +08:00
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-12-23 21:35:54 +08:00
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Background="Transparent"
Style="{DynamicResource FlattenTextBoxStyle}">
2025-12-23 21:35:54 +08:00
<!--<TextBox.Text>
<MultiBinding Converter="{StaticResource PrecisionConverter}" UpdateSourceTrigger="PropertyChanged">
<Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="Precision" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</TextBox.Text>-->
</TextBox>
<ContentPresenter
2026-02-12 21:29:00 +08:00
x:Name="Suffix"
2025-12-23 21:35:54 +08:00
Grid.Column="2"
Margin="5,0,1,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-12 21:29:00 +08:00
Content="{TemplateBinding assists:InputAssist.Suffix}"
Focusable="False" />
2025-12-23 21:35:54 +08:00
<Border
2026-02-12 21:29:00 +08:00
x:Name="border"
2025-12-23 21:35:54 +08:00
Grid.Column="3"
2026-01-02 17:30:30 +08:00
Margin="-2"
2026-02-12 21:29:00 +08:00
HorizontalAlignment="Right"
BorderBrush="{DynamicResource BorderNormalBrush}">
<Grid Width="15" Margin="2">
2025-12-23 21:35:54 +08:00
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button
2026-02-12 21:29:00 +08:00
x:Name="PART_IncreaseButton"
Grid.Row="0"
Padding="-4"
assists:ControlAssist.CornerRadius="2,2,0,0"
2025-12-23 21:35:54 +08:00
Background="{DynamicResource BackgroundFloatingBrush}"
FontSize="4"
IsTabStop="False"
Style="{DynamicResource FlattenButtonStyle}"
2026-02-12 21:29:00 +08:00
Visibility="Collapsed">
2025-12-23 21:35:54 +08:00
<controls:IconElement
2026-02-12 21:29:00 +08:00
x:Name="arrowUp"
2025-12-23 21:35:54 +08:00
Foreground="{DynamicResource TextPrimaryBrush}"
RenderTransformOrigin="0.5,0.5"
SnapsToDevicePixels="false"
2026-02-12 21:29:00 +08:00
Symbol="KeyboardArrowUp">
2025-12-23 21:35:54 +08:00
<controls:IconElement.RenderTransform>
<RotateTransform Angle="0" />
</controls:IconElement.RenderTransform>
</controls:IconElement>
</Button>
<Button
2026-02-12 21:29:00 +08:00
x:Name="PART_DecreaseButton"
Grid.Row="1"
Padding="-4"
assists:ControlAssist.CornerRadius="0,0,2,2"
2025-12-23 21:35:54 +08:00
Background="{DynamicResource BackgroundFloatingBrush}"
FontSize="4"
IsTabStop="False"
Style="{DynamicResource FlattenButtonStyle}"
2026-02-12 21:29:00 +08:00
Visibility="Collapsed">
2025-12-23 21:35:54 +08:00
<controls:IconElement
2026-02-12 21:29:00 +08:00
x:Name="arrowDown"
2025-12-23 21:35:54 +08:00
Foreground="{DynamicResource TextPrimaryBrush}"
RenderTransformOrigin="0.5,0.5"
SnapsToDevicePixels="false"
2026-02-12 21:29:00 +08:00
Symbol="KeyboardArrowDown">
2025-12-23 21:35:54 +08:00
<controls:IconElement.RenderTransform>
<RotateTransform Angle="0" />
</controls:IconElement.RenderTransform>
</controls:IconElement>
</Button>
</Grid>
</Border>
</Grid>
</Border>
<ControlTemplate.Triggers>
<!-- Prefix & Suffix -->
2026-02-12 21:29:00 +08:00
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
2025-12-23 21:35:54 +08:00
</Trigger>
2026-02-12 21:29:00 +08:00
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
2026-02-12 21:29:00 +08:00
<Setter TargetName="PART_IncreaseButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_DecreaseButton" Property="Visibility" Value="Visible" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="Cursor" Value="None" />
2025-08-20 12:10:35 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>