diff --git a/ColorTools/ColorControlPanel.xaml b/ColorTools/ColorControlPanel.xaml index 00f7d97..1911b62 100644 --- a/ColorTools/ColorControlPanel.xaml +++ b/ColorTools/ColorControlPanel.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:ColorTools" mc:Ignorable="d" - d:DesignHeight="160" d:DesignWidth="400"> + d:DesignHeight="160" d:DesignWidth="400" FontFamily="Segoe UI"> @@ -349,7 +349,7 @@ - + @@ -369,11 +369,11 @@ - - - - + DockPanel.Dock="Right" VerticalAlignment="Bottom" Background="{Binding Background, ElementName=txtRvalue, Mode=TwoWay}" Foreground="{Binding Foreground, ElementName=txtRvalue}" FontSize="14" BorderBrush="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="95" Height="27" Padding="0" PreviewTextInput="ColorCode_PreviewTextInput"/> @@ -443,5 +443,5 @@ - + diff --git a/ColorTools/ColorControlPanel.xaml.cs b/ColorTools/ColorControlPanel.xaml.cs index 7fd6bdf..586f161 100644 --- a/ColorTools/ColorControlPanel.xaml.cs +++ b/ColorTools/ColorControlPanel.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Text.RegularExpressions; namespace ColorTools { @@ -834,6 +835,18 @@ private static void IniColorChanged(DependencyObject d, DependencyPropertyChange new FrameworkPropertyMetadata(new SolidColorBrush(Color.FromRgb(85, 85, 85)), new PropertyChangedCallback(SelectedColorChanged))); + private void TextBoxPreviewTextInput(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + e.Handled = regex.IsMatch(e.Text); + } + + private void ColorCode_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("^([A-Fa-f0-9]{2}){8,9}$"); + e.Handled = regex.IsMatch(e.Text); + } + public SolidColorBrush SelectedColorBrush { get { return (SolidColorBrush)GetValue(SelectedColorBrushProperty); } diff --git a/TEST_ColorPanel/TEST_ColorPanel.csproj b/TEST_ColorPanel/TEST_ColorPanel.csproj index 94a7e79..500ee06 100644 --- a/TEST_ColorPanel/TEST_ColorPanel.csproj +++ b/TEST_ColorPanel/TEST_ColorPanel.csproj @@ -37,7 +37,7 @@ False - ..\ColorTools\bin\Release\ColorTools.dll + ..\ColorTools\bin\Debug\ColorTools.dll