Преглед изворни кода

compdfkit(win) - 优化数字输入框

weixiangjie пре 1 година
родитељ
комит
da58b00770
15 измењених фајлова са 169 додато и 50 уклоњено
  1. 15 1
      Demo/Examples/Compdfkit_Tools/Common/BaseControl/NumericUpDownControl.xaml
  2. 103 25
      Demo/Examples/Compdfkit_Tools/Common/BaseControl/NumericUpDownControl.xaml.cs
  3. 17 0
      Demo/Examples/Compdfkit_Tools/Common/Convert/AndMultiBoolValueConverter.cs
  4. 1 1
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml
  5. 2 2
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFLocationControl.xaml
  6. 4 4
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFLocationControl.xaml.cs
  7. 1 1
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFRotationControl.xaml
  8. 2 2
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFRotationControl.xaml.cs
  9. 2 2
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFTileControl.xaml
  10. 4 4
      Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFTileControl.xaml.cs
  11. 12 2
      Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml
  12. 2 2
      Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs
  13. 1 1
      Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkDialog.xaml
  14. 2 2
      Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkDialog.xaml.cs
  15. 1 1
      Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkListDialog.xaml.cs

+ 15 - 1
Demo/Examples/Compdfkit_Tools/Common/BaseControl/NumericUpDownControl.xaml

@@ -4,6 +4,7 @@
              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>
@@ -95,7 +96,20 @@
         </Style>
     </UserControl.Resources>
     <Grid>
-        <TextBox x:Name="TextBox" Text="{Binding Text, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource NumericUpDownStyle}" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="TextBox_PreviewTextInput" PreviewKeyDown="TextBox_PreviewKeyDown" TextChanged="TextBox_TextChanged"></TextBox>
+        <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>
 

+ 103 - 25
Demo/Examples/Compdfkit_Tools/Common/BaseControl/NumericUpDownControl.xaml.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Globalization;
 using System.Text.RegularExpressions;
 using System.Windows;
 using System.Windows.Controls;
@@ -13,39 +14,61 @@ namespace Compdfkit_Tools.Common
 
         // The dependency property which will be accessible on the UserControl
         public static readonly DependencyProperty UnitProperty =
-            DependencyProperty.Register("Unit", typeof(string), typeof(NumericUpDownControl), new UIPropertyMetadata());
+            DependencyProperty.Register(nameof(Unit), typeof(string), typeof(NumericUpDownControl), new UIPropertyMetadata());
 
         public string Unit
         {
-            get { return (string)GetValue(UnitProperty); }
-            set { SetValue(UnitProperty, value); }
+            get => (string)GetValue(UnitProperty);
+            set => SetValue(UnitProperty, value);
         }
 
         // The dependency property which will be accessible on the UserControl
-        public static readonly DependencyProperty MaxiumProperty =
-           DependencyProperty.Register("Maxium", typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata());
-        public int Maxium
+        public static readonly DependencyProperty MaximumProperty =
+            DependencyProperty.Register(nameof(Maximum), typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata(HandleMaxValueChanged));
+        public int Maximum
         {
-            get { return (int)GetValue(MaxiumProperty); }
-            set { SetValue(MaxiumProperty, value); }
+            get => (int)GetValue(MaximumProperty);
+            set => SetValue(MaximumProperty, value);
         }
 
         // The dependency property which will be accessible on the UserControl
         public static readonly DependencyProperty TextProperty =
-            DependencyProperty.Register("Text", typeof(string), typeof(NumericUpDownControl), new UIPropertyMetadata());
+            DependencyProperty.Register(nameof(Text), typeof(string), typeof(NumericUpDownControl), new UIPropertyMetadata());
         public string Text
         {
-            get { return (string)GetValue(TextProperty); }
-            set { SetValue(TextProperty, value); }
+            get => (string)GetValue(TextProperty);
+            set => SetValue(TextProperty, value);
         }
 
         public static readonly DependencyProperty MinimumProperty =
-    DependencyProperty.Register("Minimum", typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata());
+            DependencyProperty.Register(nameof(Minimum), typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata(HandleMinValueChanged));
         public int Minimum
         {
-            get { return (int)GetValue(MinimumProperty); }
-            set { SetValue(MinimumProperty, value); }
+            get => (int)GetValue(MinimumProperty);
+            set => SetValue(MinimumProperty, value);
         }
+        
+        // The dependency property which will be accessible on the UserControl
+        public static readonly DependencyProperty IsValueValidProperty =
+            DependencyProperty.Register(nameof(IsValueValid), typeof(bool), typeof(NumericUpDownControl), new UIPropertyMetadata());
+        public bool IsValueValid
+        {
+            get => (bool)GetValue(IsValueValidProperty);
+            set => SetValue(IsValueValidProperty, value);
+        }
+        
+        private static void HandleMinValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            NumericUpDownControl source = (NumericUpDownControl) d;
+            source.Validator.MinValue = (int) e.NewValue;
+        }
+        
+        private static void HandleMaxValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            NumericUpDownControl source = (NumericUpDownControl) d;
+            source.Validator.MaxValue = (int) e.NewValue;
+        }
+        
         public NumericUpDownControl()
         {
             InitializeComponent();
@@ -85,39 +108,94 @@ namespace Compdfkit_Tools.Common
 
         private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
         {
-            if (!string.IsNullOrEmpty(TextBox.Text))
+            if(int.TryParse(TextBox.Text, out int num))
             {
-                if (int.Parse(TextBox.Text) > Maxium)
+                if (num <= Maximum && num >= Minimum)
                 {
-                    TextBox.Text = Maxium.ToString();
+                    IsValueValid = true;
+                    return;
                 }
+            }
+            IsValueValid = false;
+        }
 
-                if (int.Parse(TextBox.Text) < Minimum)
+        private void UpButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (int.TryParse(TextBox.Text, out int num))
+            {
+                int newNum = num + 1;
+                if (newNum > Maximum)
+                {
+                    TextBox.Text = Maximum.ToString();
+                }
+                else if(newNum < Minimum)
                 {
                     TextBox.Text = Minimum.ToString();
                 }
+                else
+                {
+                    TextBox.Text = newNum.ToString();
+                }
             }
             else
             {
-                TextBox.Text = GetMinAbsoluteValue(Minimum, Maxium).ToString();
+                TextBox.Text = Minimum.ToString();
             }
         }
 
-        private void UpButton_Click(object sender, RoutedEventArgs e)
+        private void DownButton_Click(object sender, RoutedEventArgs e)
         {
             if (int.TryParse(TextBox.Text, out int num))
             {
-                TextBox.Text = (++num).ToString();
+                int newNum = num - 1;
+                if (newNum > Maximum)
+                {
+                    TextBox.Text = Maximum.ToString();
+                }
+                else if (newNum < Minimum)
+                {
+                    TextBox.Text = Minimum.ToString();
+                }
+                else
+                {
+                    TextBox.Text = newNum.ToString();
+                }
+            }
+            else
+            {
+                TextBox.Text = Minimum.ToString();
             }
         }
-
-        private void DownButton_Click(object sender, RoutedEventArgs e)
+    }
+    
+    public class CustomValidationRule : ValidationRule
+    {
+        public int MaxValue { get; set; }
+        public int MinValue { get; set; }
+        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
         {
-            if (int.TryParse(TextBox.Text, out int num))
+            if (value == null)
             {
-                TextBox.Text = (--num).ToString();
+                return new ValidationResult(false, "Value cannot be empty.");
+            }
+
+            if (int.TryParse(value.ToString(), out int num))
+            {
+                if (num <= MaxValue && num >= MinValue)
+                {
+                    return new ValidationResult(true, null);
+                }
+                else
+                {
+                    return new ValidationResult(false, $"Value must be between {MinValue} and {MaxValue}.");
+                }
+            }
+            else
+            {
+                return new ValidationResult(false, "Value must be an integer.");
             }
         }
     }
+
 }
 

+ 17 - 0
Demo/Examples/Compdfkit_Tools/Common/Convert/AndMultiBoolValueConverter.cs

@@ -22,4 +22,21 @@ namespace Compdfkit_Tools.Common
             return Enumerable.Repeat(DependencyProperty.UnsetValue, targetTypes.Length).ToArray();
         }
     }
+    
+    public class OrMultiBoolValueConverter : IMultiValueConverter
+    {
+        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (values != null && values.All(v => v is bool boolValue))
+            {
+                return values.Cast<bool>().Any(v => v);
+            }
+            return DependencyProperty.UnsetValue; 
+        }
+
+        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+        {
+            return Enumerable.Repeat(DependencyProperty.UnsetValue, targetTypes.Length).ToArray();
+        }
+    }
 }

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml

@@ -60,7 +60,7 @@
                     <Line Name="DashLineControl" Margin="10,0,0,0" Grid.Row="1" Grid.Column="1" Stroke="#000000" StrokeThickness="2" X1="0" Y1="0" X2="112" Y2="0" VerticalAlignment="Center" StrokeDashArray="0,1,1"></Line>
                 </RadioButton>
             </StackPanel>
-            <local:NumericUpDownControl x:Name="NumericUpDownControl" VerticalAlignment="Bottom" Text="{Binding DashSpacing, Mode=TwoWay}" Grid.Column="1" Width="72" Height="28" Unit="pt" Minimum="1" Maxium="10" IsEnabled="{Binding ElementName=DashRadioButton, Path=IsChecked}"></local:NumericUpDownControl>
+            <local:NumericUpDownControl x:Name="NumericUpDownControl" VerticalAlignment="Bottom" Text="{Binding DashSpacing, Mode=TwoWay}" Grid.Column="1" Width="72" Height="28" Unit="pt" Minimum="1" Maximum="10" IsEnabled="{Binding ElementName=DashRadioButton, Path=IsChecked}"></local:NumericUpDownControl>
         </Grid>
     </Grid>
 

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFLocationControl.xaml

@@ -20,11 +20,11 @@
             </Grid.RowDefinitions>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="4">
                 <TextBlock Text="X" VerticalAlignment="Center" Margin="0,0,8,0"></TextBlock>
-                <local:NumericUpDownControl x:Name="XNumericControl" Height="32" Width="90" Unit="mm" Text="{Binding HorizOffsetValue, Mode=TwoWay}"  Minimum="0" Maxium="99"></local:NumericUpDownControl>
+                <local:NumericUpDownControl x:Name="XNumericControl" Height="32" Width="90" Unit="mm" Text="{Binding HorizOffsetValue, Mode=TwoWay}"  Minimum="0" Maximum="99"></local:NumericUpDownControl>
             </StackPanel>
             <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4">
                 <TextBlock Text="Y" VerticalAlignment="Center" Margin="0,0,8,0"></TextBlock>
-                <local:NumericUpDownControl x:Name="YNumericControl" Height="32" Width="90" Unit="mm"  Text="{Binding VertOffsetValue, Mode=TwoWay}"  Minimum="0" Maxium="99"></local:NumericUpDownControl>
+                <local:NumericUpDownControl x:Name="YNumericControl" Height="32" Width="90" Unit="mm"  Text="{Binding VertOffsetValue, Mode=TwoWay}"  Minimum="0" Maximum="99"></local:NumericUpDownControl>
             </StackPanel>
         </Grid>
     </Grid>

+ 4 - 4
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFLocationControl.xaml.cs

@@ -56,9 +56,9 @@ namespace Compdfkit_Tools.Common
                 {
                     return;
                 }
-                if (int.Parse(value) > XNumericControl.Maxium)
+                if (int.Parse(value) > XNumericControl.Maximum)
                 {
-                    value = XNumericControl.Maxium.ToString();
+                    value = XNumericControl.Maximum.ToString();
                 }
                 if (int.Parse(value) < XNumericControl.Minimum)
                 {
@@ -81,9 +81,9 @@ namespace Compdfkit_Tools.Common
                 {
                     return;
                 }
-                if (int.Parse(value) > YNumericControl.Maxium)
+                if (int.Parse(value) > YNumericControl.Maximum)
                 {
-                    value = YNumericControl.Maxium.ToString();
+                    value = YNumericControl.Maximum.ToString();
                 }
                 if (int.Parse(value) < YNumericControl.Minimum)
                 {

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFRotationControl.xaml

@@ -35,7 +35,7 @@
             <ColumnDefinition Width="auto"></ColumnDefinition>
             <ColumnDefinition  Width="auto"></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <local:NumericUpDownControl x:Name="NumericUpDownControl" Width="82" Minimum="-360" Maxium="360" Text="{Binding RotationText, Mode=TwoWay}"></local:NumericUpDownControl>
+        <local:NumericUpDownControl x:Name="NumericUpDownControl" Width="82" Minimum="-360" Maximum="360" Text="{Binding RotationText, Mode=TwoWay}"></local:NumericUpDownControl>
         <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="8,0,0,0">
             <Button x:Name="CounterclockwiseBtn"  Style="{StaticResource TransparentButtonStyle}" Click="RotationBtn_Click">
                 <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="M14.5,0H1.5V16H14.5V0ZM13.5,1V15H2.5V1H13.5ZM6.58579,3.75736L3.75736,6.58579L9.41421,12.2426L12.2426,9.41421L6.58579,3.75736Z" Fill="#001A4E" />

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFRotationControl.xaml.cs

@@ -38,9 +38,9 @@ namespace Compdfkit_Tools.Common
 
                 if (int.TryParse(value, out result))
                 {
-                    if (result > NumericUpDownControl.Maxium)
+                    if (result > NumericUpDownControl.Maximum)
                     {
-                        value = NumericUpDownControl.Maxium.ToString();
+                        value = NumericUpDownControl.Maximum.ToString();
                     }
                     if (result < NumericUpDownControl.Minimum)
                     {

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFTileControl.xaml

@@ -32,13 +32,13 @@
                 <Canvas Width="16" Height="16" Margin="0,0,4,0">
                     <Path Fill="Black" Data="M1,4H2V12H1V4ZM4.70703,7.5H11.2952L10.0278,6.23223L10.7349,5.52513L13.2097,8L10.7349,10.4749L10.0278,9.76777L11.2952,8.5H4.70703L5.97487,9.76777L5.26777,10.4749L2.79289,8L5.26777,5.52513L5.97487,6.23223L4.70703,7.5ZM15,4H14V12H15V4Z"/>
                 </Canvas>
-                <local:NumericUpDownControl x:Name="HorizontalNumericControl" Height="32" Width="90"  Margin="0,0,4,0" Minimum="0" Maxium="99" Text="{Binding HorizontalSpacingValue, Mode=TwoWay}" Unit="mm"></local:NumericUpDownControl>
+                <local:NumericUpDownControl x:Name="HorizontalNumericControl" Height="32" Width="90"  Margin="0,0,4,0" Minimum="0" Maximum="99" Text="{Binding HorizontalSpacingValue, Mode=TwoWay}" Unit="mm"></local:NumericUpDownControl>
             </StackPanel>
             <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                 <Canvas Width="16" Height="16"  Margin="0,0,4,0">
                     <Path Fill="Black" Data="M12,1V2L4,2V1L12,1ZM8.5,4.70703V11.2952L9.76777,10.0278L10.4749,10.7349L8,13.2097L5.52513,10.7349L6.23223,10.0278L7.5,11.2952L7.5,4.70703L6.23223,5.97487L5.52513,5.26777L8,2.79289L10.4749,5.26777L9.76777,5.97487L8.5,4.70703ZM12,15V14H4V15H12Z"/>
                 </Canvas>
-                <local:NumericUpDownControl  x:Name="VerticalNumericControl" Height="32" Width="90"  Margin="0,0,4,0"  Minimum="0" Maxium="99" Text="{Binding VerticalSpacingValue, Mode=TwoWay}" Unit="mm"></local:NumericUpDownControl>
+                <local:NumericUpDownControl  x:Name="VerticalNumericControl" Height="32" Width="90"  Margin="0,0,4,0"  Minimum="0" Maximum="99" Text="{Binding VerticalSpacingValue, Mode=TwoWay}" Unit="mm"></local:NumericUpDownControl>
             </StackPanel>
 
 

+ 4 - 4
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFLocation/CPDFTileControl.xaml.cs

@@ -45,9 +45,9 @@ namespace Compdfkit_Tools.Common
                 {
                     return;
                 }
-                if (int.Parse(value) > VerticalNumericControl.Maxium)
+                if (int.Parse(value) > VerticalNumericControl.Maximum)
                 {
-                    value = VerticalNumericControl.Maxium.ToString();
+                    value = VerticalNumericControl.Maximum.ToString();
                 }
                 if (int.Parse(value) < VerticalNumericControl.Minimum)
                 {
@@ -70,9 +70,9 @@ namespace Compdfkit_Tools.Common
                 {
                     return;
                 }
-                if (int.Parse(value) > HorizontalNumericControl.Maxium)
+                if (int.Parse(value) > HorizontalNumericControl.Maximum)
                 {
-                    value = VerticalNumericControl.Maxium.ToString();
+                    value = VerticalNumericControl.Maximum.ToString();
                 }
                 if (int.Parse(value) < HorizontalNumericControl.Minimum)
                 {

+ 12 - 2
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml

@@ -16,6 +16,7 @@
             <cpdfcommon:BoolToVisibleConverter x:Key="BoolToVisibleConverter"></cpdfcommon:BoolToVisibleConverter>
             <cpdfcommon:ReverseVisibilityConverter x:Key="ReverseVisibilityConverter"></cpdfcommon:ReverseVisibilityConverter>
             <cpdfcommon:DocEditorResourceConverter x:Key="DocEditorResourceConverter"></cpdfcommon:DocEditorResourceConverter>
+            <cpdfcommon:OrMultiBoolValueConverter x:Key="AndMultiBoolValueConverter"></cpdfcommon:OrMultiBoolValueConverter>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
@@ -87,7 +88,7 @@
                             <RadioButton GroupName="PageLocation" Name="CustomPageRadioButton" Tag="CustomPage" VerticalAlignment="Center" Click="PageInsertLocation_Click">
                                 <TextBlock Text="{Binding Converter={StaticResource DocEditorResourceConverter},ConverterParameter=Option_Page}"/>
                             </RadioButton>
-                            <cpdfcommon:NumericUpDownControl x:Name="PageTextBox" Maxium="{Binding MaxIndex, Mode=OneWay}" Minimum="1" Text="{Binding CustomPageIndex, Mode=TwoWay}" Height="32" Width="175" Margin="12,0,0,0" IsEnabled="{Binding ElementName=CustomPageRadioButton, Path= IsChecked}"/>
+                            <cpdfcommon:NumericUpDownControl x:Name="PageTextBox" Maximum="{Binding MaxIndex, Mode=OneWay}" Minimum="1" Text="{Binding CustomPageIndex, Mode=TwoWay}" Height="32" Width="175" Margin="12,0,0,0" IsEnabled="{Binding ElementName=CustomPageRadioButton, Path= IsChecked}"/>
                             <TextBlock Text="/"  VerticalAlignment="Center"  Margin="8,0,0,0" ></TextBlock>
                             <TextBlock x:Name="MaxPageTextBox" Text="10000"  VerticalAlignment="Center" ></TextBlock>
                         </StackPanel>
@@ -105,7 +106,16 @@
                 <TextBlock Text="{Binding Converter={StaticResource DocEditorResourceConverter},ConverterParameter=Button_Cancel}"></TextBlock>
             </Button>
             <Button x:Name="InsertButton" Height="32" Width="112"  Margin="8,0,0,0" Click="InsertButton_Click">
-                <TextBlock Text="{Binding Converter={StaticResource DocEditorResourceConverter},ConverterParameter=Button_Insert}"></TextBlock>
+                <Button.Content>
+                    <TextBlock Text="{Binding Converter={StaticResource DocEditorResourceConverter},ConverterParameter=Button_Insert}"></TextBlock>
+                </Button.Content>
+                <Button.IsEnabled>
+                    <MultiBinding Converter="{StaticResource AndMultiBoolValueConverter}">
+                        <Binding ElementName="HomePageRadioButton" Path="IsChecked"></Binding>
+                        <Binding ElementName="GastricPageRadioButton" Path="IsChecked"></Binding>
+                        <Binding ElementName="PageTextBox" Path="IsValueValid"></Binding>
+                    </MultiBinding>
+                </Button.IsEnabled>
             </Button>
         </StackPanel>
     </Grid>

+ 2 - 2
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs

@@ -20,7 +20,7 @@ namespace Compdfkit_Tools.PDFControlUI
             set
             {
                 _maxIndex = value;
-                PageTextBox.Maxium = _maxIndex;
+                PageTextBox.Maximum = _maxIndex;
                 MaxPageTextBox.Text = _maxIndex.ToString();
             }
         }
@@ -153,7 +153,7 @@ namespace Compdfkit_Tools.PDFControlUI
         {
             if (index == -2 && PageTextBox.Text != null)
             {
-                index = int.Parse(PageTextBox.Text);
+                int.TryParse(PageTextBox.Text,out index);
             }
             if (PageTextBox.Text != string.Empty)
             {

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkDialog.xaml

@@ -100,7 +100,7 @@
                                     </Grid>
                                 </Button>
                                 <TextBlock Text="{Binding Converter={StaticResource SecurityResourceConverter}, ConverterParameter=Text_Watermark}" VerticalAlignment="Center" Margin="0,0,8,0"></TextBlock>
-                                <common:NumericUpDownControl x:Name="ScaleNumericControl" Width="80" Text="{Binding ImageScale, Mode=TwoWay}" Maxium="500" Minimum="10" Unit="%"  IsEnabled="{Binding Path=IsChecked, ElementName=ImageRdo}"></common:NumericUpDownControl>
+                                <common:NumericUpDownControl x:Name="ScaleNumericControl" Width="80" Text="{Binding ImageScale, Mode=TwoWay}" Maximum="500" Minimum="10" Unit="%"  IsEnabled="{Binding Path=IsChecked, ElementName=ImageRdo}"></common:NumericUpDownControl>
                             </StackPanel>
                         </Grid>
                     </Grid>

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkDialog.xaml.cs

@@ -113,9 +113,9 @@ namespace Compdfkit_Tools.PDFControl
                 {
                     return;
                 }
-                if (int.Parse(value) > ScaleNumericControl.Maxium)
+                if (int.Parse(value) > ScaleNumericControl.Maximum)
                 {
-                    value = ScaleNumericControl.Maxium.ToString();
+                    value = ScaleNumericControl.Maximum.ToString();
                 }
                 if (int.Parse(value) < ScaleNumericControl.Minimum)
                 {

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkListDialog.xaml.cs

@@ -82,7 +82,7 @@ namespace Compdfkit_Tools.PDFControl
                             return;
                         }
                         string savePath = Path.Combine(path, Path.GetFileNameWithoutExtension(fileInfo.Document.FileName) + "_" 
-                            + LanguageHelper.SecurityManager.GetString("FileName_Watermark"));
+                            + LanguageHelper.SecurityManager.GetString("FileName_Watermark")) + ".pdf";
                         fileInfo.Document.WriteToFilePath(savePath);
                     }
                     System.Diagnostics.Process.Start("explorer.exe", "/select," + path + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(FileGridListWithPageRangeControl.FileInfoDataList[0].Document.FileName) + "_Watermark.pdf");