2026-03-30 17:09:29 +09:00

217 lines
14 KiB
XML

<base:UCKeyValueNumber x:Class="AuroraUIComponent.UserControls.UCNumericUpDown"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AuroraUIComponent.UserControls"
xmlns:base="clr-namespace:AuroraUIComponent.UserControls.KeyValueBase"
xmlns:mahControl="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="200" MinHeight="40" MaxHeight="100"
FontSize="12">
<UserControl.Resources>
<local:PaddingConverter x:Key="convPadding"/>
<!-- For RepeatButton -->
<Style x:Key="MahApps.Styles.RButton.VisualStudio" TargetType="{x:Type RepeatButton}">
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Background.Normal}" />
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.Border.Normal}" />
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Foreground}" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Value="{DynamicResource MahApps.Brushes.BackgroundHighlighted}" Property="Background" />
<Setter Value="{DynamicResource MahApps.Brushes.Border.Highlighted}" Property="BorderBrush" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Value="{DynamicResource MahApps.Brushes.BackgroundSelected}" Property="Background" />
<Setter Value="{DynamicResource MahApps.Brushes.Border.Selected}" Property="BorderBrush" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
<!-- Remove: CornerRadius="{TemplateBinding CornerRadius}" -->
<mahControl:ClipBorder Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" SnapsToDevicePixels="True">
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</mahControl:ClipBorder>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style x:Key="RButton" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource MahApps.Styles.RButton.VisualStudio}">
<Style.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.BackgroundSelected}" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.SemiTransparent}" />
<Setter Property="FontFamily" Value="{DynamicResource MahApps.Fonts.Family.Button}" />
<Setter Property="FontSize" Value="{DynamicResource MahApps.Font.Size.Button}" />
<Setter Property="Height" Value="Auto" />
<!--
<Setter Property="FocusBorderBrush" Value="{DynamicResource MahApps.Brushes.Border.Selected}" />
<Setter Property="MouseOverBorderBrush" Value="{DynamicResource MahApps.Brushes.Border.Highlighted}" />
<Setter Property="DisabledBackgroundBrush" Value="{DynamicResource MahApps.Brushes.ThemeBackground}" />
<Setter Property="DisabledForegroundBrush" Value="{DynamicResource MahApps.Brushes.IdealForegroundDisabled}" />
<Setter Property="HoverBackgroundBrush" Value="{DynamicResource MahApps.Brushes.BackgroundHighlighted}" />
<Setter Property="SelectedBackgroundBrush" Value="{DynamicResource MahApps.Brushes.BackgroundSelected}" />
<Setter Property="SelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.Selected.Foreground}" />
-->
</Style>
<Style
x:Key="St▲RButton" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource RButton}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="Uniform">
<Polygon x:Name="arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
Points="0,6 3,0 6,6"
StrokeThickness="0" Fill="{TemplateBinding Foreground}"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="St▼RButton" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource RButton}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="Uniform">
<Polygon x:Name="arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
Points="0,0 3,6 6,0"
StrokeThickness="0" Fill="{TemplateBinding Foreground}"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="St▲RButtonFill" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource RButton}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="fill">
<Polygon x:Name="arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
Points="0,1.73 1,0 2,1.73"
StrokeThickness="0" Fill="{TemplateBinding Foreground}"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="St▼RButtonFill" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource RButton}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="fill" >
<Polygon x:Name="arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
Points="0,0 1,1.73 2,0"
StrokeThickness="0" Fill="{TemplateBinding Foreground}"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- End: RepeatButton -->
</UserControl.Resources>
<Grid x:Name="GridParent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding KeyTextWidth, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<ColumnDefinition Width="{Binding ValueTextWidth, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
</Grid.ColumnDefinitions>
<Border Background="{Binding KeyTextBgColor, RelativeSource={RelativeSource AncestorType=UserControl}}" Margin="2">
<TextBlock x:Name="TextKey" Grid.Column="0" Margin="5 0" FontWeight="Bold"
Text="{Binding KeyText, RelativeSource={RelativeSource AncestorType=UserControl}}"
FontSize="{Binding KeyTextSize, RelativeSource={RelativeSource AncestorType=UserControl}}"
Foreground="{Binding KeyTextFgColor, RelativeSource={RelativeSource AncestorType=UserControl}}"
HorizontalAlignment="{Binding KeyHorizontalAlignment, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
</Border>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Name="TextValue" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
Margin="0 4 0 4"
FontSize="{Binding ValueTextSize, RelativeSource={RelativeSource AncestorType=UserControl}}"
Padding="{Binding Unit, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource convPadding}}"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="{Binding ValueHorizontalAlignment, RelativeSource={RelativeSource AncestorType=UserControl}}"
KeyDown="TextBox_KeyDown"
PreviewKeyDown="TextBox_PreviewKeyDown"/>
<TextBlock FontSize="11" HorizontalAlignment="Right" Margin="0 0 6 0" Foreground="#c0c0c0"
Text="{Binding Unit, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<!-- repeat 버튼으로 나중에 변경하자 -->
<Grid Grid.Column="1" IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource inverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--
<Button Grid.Row="0" Margin="0.5 2 1 0.5"
Style="{StaticResource St▲Button}"
Click="UpButtonClick"/>
<Button Grid.Row="1" Margin="0.5 0.5 1 2"
Style="{StaticResource St▼Button}"
Click="DownButtonClick"/>
-->
<RepeatButton Grid.Row="0" Margin="0.5 2 1 0.5"
Name="IncreaseButton"
Style="{StaticResource St▲RButton}"
Command="{Binding CMD_UpButtonClick, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<RepeatButton Grid.Row="1" Margin="0.5 0.5 1 2"
Name="DecreaseButton"
Style="{StaticResource St▼RButton}"
Command="{Binding CMD_DownButtonClick, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
</Grid>
<!--
<Button Name="ButtonMouse" Grid.Column="1" Click="Button_Click" Margin="0 2">
<Image Source="{DynamicResource Electronics_MouseDrawingImage}"/>
</Button>
-->
</Grid>
</Grid>
</base:UCKeyValueNumber>