123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <UserControl x:Class="Compdfkit_Tools.Common.NumericUpDownControl"
- 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:Compdfkit_Tools.Common"
- x:Name="UserControl"
- mc:Ignorable="d"
- d:DesignHeight="30" d:DesignWidth="100">
- <UserControl.Resources>
- <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
- <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
- <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
- <Style x:Key="ClearButton" TargetType="{x:Type Button}">
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="BorderBrush" Value="Transparent"></Setter>
- <Setter Property="BorderThickness" Value="0"></Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="Button">
- <Border Name="border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="#F0F0F0" />
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter Property="Background" Value="#AAAAAA" />
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Opacity" Value="0.5" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="NumericUpDownStyle" TargetType="{x:Type TextBox}">
- <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="HorizontalContentAlignment" Value="Left"/>
- <Setter Property="VerticalContentAlignment" Value="Center"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="AllowDrop" Value="true"/>
- <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
- <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TextBox}">
- <Border BorderThickness="1" BorderBrush="{StaticResource TextBox.Static.Border}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition></ColumnDefinition>
- <ColumnDefinition Width="30"></ColumnDefinition>
- <ColumnDefinition Width="20"></ColumnDefinition>
- </Grid.ColumnDefinitions>
- <ScrollViewer Grid.Column="0" x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
- <TextBlock Grid.Column="1" Text="{Binding Unit, RelativeSource={RelativeSource AncestorType=UserControl}}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
- <Grid Grid.Column="2">
- <Grid.RowDefinitions>
- <RowDefinition></RowDefinition>
- <RowDefinition></RowDefinition>
- </Grid.RowDefinitions>
- <Button x:Name="UpButton" Style="{StaticResource ClearButton}" Click="UpButton_Click">
- <Button.Content>
- <Path Fill="#CDCDCD" Grid.Column="1" Stroke="#A0A2AE" Height="4.8" Width="7.38" Stretch="Fill">
- <Path.Data>
- <PathGeometry Figures="M511.99386 361.932146L130.652665 743.283574c-14.944364 14.95869-39.187511 14.95869-54.14313 0-14.95869-14.95562-14.95869-39.187511 0-54.143131l408.411736-408.426063c14.95869-14.95562 39.187511-14.95562 54.144155 0l408.426063 408.426063c7.478322 7.478322 11.217483 17.275455 11.217482 27.072589 0 9.79611-3.739161 19.59222-11.217482 27.070542-14.95562 14.95869-39.187511 14.95869-54.143131 0L511.99386 361.932146z" ></PathGeometry>
- </Path.Data>
- </Path>
- </Button.Content>
- </Button>
- <Button x:Name="DownButton" Style="{StaticResource ClearButton}" Grid.Row="1" Click="DownButton_Click">
- <Button.Content>
- <Path Fill="#CDCDCD" Grid.Column="1" Stroke="#A0A2AE" Height="4.8" Width="7.38" Stretch="Fill">
- <Path.Data>
- <PathGeometry Figures="M917.284001 297.722752c-5.406127-5.437849-13.06762-8.396227-21.479197-8.396227-9.611915 0-18.953677 3.844561-25.713638 10.543124L511.980046 659.992589 153.873018 299.91672c-6.729262-6.745634-16.072047-10.619872-25.654286-10.619872-8.470929 0-16.131399 2.989077-21.598924 8.457626-12.301164 12.435217-11.32493 33.69031 2.192945 47.312562l376.764969 378.821815c6.758937 6.788613 15.860223 10.723226 25.052582 10.8143l3.425006 0c8.981559-0.301875 17.814738-4.205788 24.423249-10.8143l376.733247-378.852514C928.728658 331.382363 929.690566 310.113967 917.284001 297.722752" ></PathGeometry>
- </Path.Data>
- </Path>
- </Button.Content>
- </Button>
- </Grid>
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Opacity" Value="0.5" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </UserControl.Resources>
- <Grid>
- <TextBox x:Name="TextBox"
- Style="{StaticResource NumericUpDownStyle}"
- InputMethod.IsInputMethodEnabled="False"
- PreviewTextInput="TextBox_PreviewTextInput"
- PreviewKeyDown="TextBox_PreviewKeyDown"
- TextChanged="TextBox_TextChanged">
- <TextBox.Text>
- <Binding Path="Text" RelativeSource="{RelativeSource AncestorType=UserControl}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
- <Binding.ValidationRules>
- <local:CustomValidationRule x:Name="Validator"/>
- </Binding.ValidationRules>
- </Binding>
- </TextBox.Text>
- </TextBox>
- </Grid>
- </UserControl>
|