Jelajahi Sumber

compdfkit demo windows - 可下拉可修改的textbox控件

LiuAoran 1 tahun lalu
induk
melakukan
d4ffeb1b29
26 mengubah file dengan 698 tambahan dan 85 penghapusan
  1. 8 4
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml
  2. 22 4
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs
  3. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Freetext.png
  4. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Highlight.png
  5. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Line.png
  6. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Link.png
  7. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Note.png
  8. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Sharp.png
  9. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Signature.png
  10. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Sound.png
  11. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Squiggly.png
  12. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Stamp.png
  13. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Strikeout.png
  14. TEMPAT SAMPAH
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Underline.png
  15. 5 4
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/PDFAnnotationBarControl.xaml
  16. 168 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/CPDFAnnotationBarControl.xaml.cs
  17. 0 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/CPDFBOTABarControl.xaml.cs
  18. 0 51
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/PDFAnnotationBarControl.xaml.cs
  19. 121 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/BoolToVisibilityConvert.cs
  20. 140 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/DropDownNumberBoxControl.xaml
  21. 129 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/DropDownNumberBoxControl.xaml.cs
  22. 2 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFDisplaySettings/PDFDisplaySettingsControl/CPDFDrawModeControl.xaml.cs
  23. 21 5
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs
  24. 2 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml
  25. 29 7
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml.cs
  26. 51 4
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

+ 8 - 4
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml

@@ -11,14 +11,18 @@
         <Grid.RowDefinitions>
             <RowDefinition Height="40"></RowDefinition>
             <RowDefinition Height="50"></RowDefinition>
+            <RowDefinition Height="40"></RowDefinition>
             <RowDefinition></RowDefinition>
             <RowDefinition Height="40"></RowDefinition>
         </Grid.RowDefinitions>
         <cpdftools:TitleBarControl x:Name="TitleBarControl"></cpdftools:TitleBarControl>
         <Grid Grid.Row="1">
-            <cpdftools:ModeSelectorBarControl x:Name="modeSelectorBarControl"></cpdftools:ModeSelectorBarControl>
+            <cpdftools:ModeSelectorBarControl x:Name="ModeSelectorBarControl"></cpdftools:ModeSelectorBarControl>
+        </Grid>
+        <Grid Grid.Row="2">
+            <cpdftools:CPDFAnnotationBarControl Name="AnnotationBarControl"></cpdftools:CPDFAnnotationBarControl>
         </Grid>
-        <Grid x:Name="BodyGrid" Grid.Row="2">
+        <Grid x:Name="BodyGrid" Grid.Row="3">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="0"></ColumnDefinition>
                 <ColumnDefinition Width="auto"></ColumnDefinition>
@@ -51,7 +55,7 @@
 
 
         </Grid>
-        <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center">
+        <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                 <Rectangle Width="1" Fill="#AAAAAA" Margin="5,0,5,0"></Rectangle>
                 <cpdftools:CPDFPageTurningControl x:Name="CPDFPageTurningControl"/>
@@ -60,7 +64,7 @@
                 <Rectangle Width="1" Fill="#AAAAAA" Margin="5,0,5,0"></Rectangle>
                 <cpdftools:CPDFViewModeControl x:Name="CPDFViewModeControl"/>
                 <Rectangle Width="1" Fill="#AAAAAA" Margin="5,0,5,0"></Rectangle>
-                <cpdftools:CPDFColorModeControl x:Name="CPDFColorModeControl"/>
+                <cpdftools:CPDFDrawModeControl x:Name="CPDFDrawModeControl"/>
                 <Rectangle Width="1" Fill="#AAAAAA" Margin="5,0,5,0"></Rectangle>
                 <Button x:Name="PDFInfoButton" Height="30" Width="60">
                     <TextBlock Text="文档属性"></TextBlock>

+ 22 - 4
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs

@@ -28,12 +28,30 @@ namespace annotation_ctrl_demo
         {
             InitializeComponent();
             TitleBarControl.Loaded += TitleBarControl_Loaded;
-            modeSelectorBarControl.Loaded += ModrSelectorBarControl_Loaded;
+            ModeSelectorBarControl.Loaded += ModeSelectorBarControl_Loaded;
+            AnnotationBarControl.Loaded += AnnotationBarControl_Loaded;
         }
 
-        private void ModrSelectorBarControl_Loaded(object sender, RoutedEventArgs e)
+        private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
         {
-            modeSelectorBarControl.ShowBOTAEvent += ModrSelectorBarControl_ShowBOTAEvent;
+            AnnotationProperties[] annotationProperties = { AnnotationProperties.Highlight,AnnotationProperties.Underline, AnnotationProperties.Strikeout, AnnotationProperties.Squiggly, AnnotationProperties.Freetext, AnnotationProperties.Note,  AnnotationProperties.Sharp, AnnotationProperties.Line, AnnotationProperties.Stamp, AnnotationProperties.Signature, AnnotationProperties.Link, AnnotationProperties.Sound};
+            AnnotationBarControl.InitAnnotationBar(annotationProperties);
+            AnnotationBarControl.AnnotationPropertiesChanged += AnnotationBarControl_AnnotationPropertiesChanged;
+            AnnotationBarControl.AnnotationPropertiesCancel += AnnotationBarControl_AnnotationPropertiesCancel;
+        }
+
+        private void AnnotationBarControl_AnnotationPropertiesCancel(object sender, EventArgs e)
+        {
+        }
+
+        private void AnnotationBarControl_AnnotationPropertiesChanged(object sender, string e)
+        {
+            
+        }
+
+        private void ModeSelectorBarControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            ModeSelectorBarControl.ShowBOTAEvent += ModrSelectorBarControl_ShowBOTAEvent;
         }
 
         private void ModrSelectorBarControl_ShowBOTAEvent(object sender, EventArgs e)
@@ -49,7 +67,7 @@ namespace annotation_ctrl_demo
                 }
                 SetBotaTool(pdfBOTABarControl);
             }
-            ExpandTool(modeSelectorBarControl.BOTABarIsShowing == true);
+            ExpandTool(ModeSelectorBarControl.BOTABarIsShowing == true);
         }
 
         private void LoadDocument()

TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Freetext.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Highlight.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Line.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Link.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Note.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Sharp.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Signature.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Sound.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Squiggly.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Stamp.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Strikeout.png


TEMPAT SAMPAH
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Underline.png


+ 5 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/PDFAnnotationBarControl.xaml

@@ -1,11 +1,12 @@
-<UserControl x:Class="compdfkit_tools.PDFControl.PDFAnnotationBarControl"
+<UserControl x:Class="compdfkit_tools.PDFControl.CPDFAnnotationBarControl"
              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" 
              mc:Ignorable="d" 
              d:DesignHeight="40" d:DesignWidth="1280">
-    <Grid>
-            
-    </Grid>
+    <UserControl.Resources>
+        <ResourceDictionary Source="../../Asset/Theme/LightMode.xaml"></ResourceDictionary>
+    </UserControl.Resources>
+    <Grid  Name="AnnotationGrid" Width="0"></Grid>
 </UserControl>

+ 168 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/CPDFAnnotationBarControl.xaml.cs

@@ -0,0 +1,168 @@
+using ComPDFKitViewer.AnnotEvent;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace compdfkit_tools.PDFControl
+{
+    public enum AnnotationProperties
+    {
+        Highlight,
+        Underline,
+        Strikeout,
+        Squiggly,
+        Freetext,
+        Note,
+        Sharp,
+        Line,
+        Stamp,
+        Signature,
+        Link,
+        Sound
+    }
+
+    /// <summary>
+    /// PDFAnnotationBarControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFAnnotationBarControl : UserControl
+    {
+        private int annotationCounter = 0;
+        private Brush brush = null;
+
+        public event EventHandler<string> AnnotationPropertiesChanged;
+        public event EventHandler AnnotationPropertiesCancel;
+
+        public CPDFAnnotationBarControl()
+        {
+            InitializeComponent();
+        }
+
+        private void CreateAnnotationButton(ToggleButton toggleButton)
+        {
+
+            toggleButton.Width = 50;
+            toggleButton.Background = brush;
+            Geometry annotationGeometry = Geometry.Parse(""); ;
+
+            ImageBrush imageBrush = new ImageBrush();
+            string path = string.Empty;
+            if (toggleButton.Tag.ToString() == AnnotationProperties.Highlight.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Highlight.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Underline.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Underline.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Strikeout.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Strikeout.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Squiggly.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Squiggly.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Freetext.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Freetext.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Note.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Note.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Sharp.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Sharp.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Line.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Line.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Stamp.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Stamp.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Signature.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Signature.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Link.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Link.png";
+            }
+            else if (toggleButton.Tag.ToString() == AnnotationProperties.Sound.ToString())
+            {
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Sound.png";
+
+            }
+            if (path != string.Empty)
+            {
+                BitmapImage bitmapImage = new BitmapImage(new Uri(path, UriKind.Absolute));
+                Image image = new Image();
+                image.Source = bitmapImage;
+                imageBrush.ImageSource = bitmapImage;
+                Grid grid = new Grid();
+                grid.Height = 20;
+                grid.Width = 20;
+                grid.Children.Add(image);
+
+                toggleButton.Content = grid;
+                toggleButton.Click += ToggleButton_Click;
+
+                Grid.SetColumn(toggleButton, annotationCounter++);
+                AnnotationGrid.Children.Add(toggleButton);
+            }
+        }
+
+        private void ClearToolState(UIElement sender)
+        {
+            foreach (UIElement child in AnnotationGrid.Children)
+            {
+                if(child is ToggleButton toggle && (child as ToggleButton) != (sender as ToggleButton))
+                {
+                    toggle.IsChecked = false;
+                }
+            }
+        }
+
+        private void ToggleButton_Click(object sender, RoutedEventArgs e)
+        {
+            ClearToolState(sender as ToggleButton);
+            if ((bool)(sender as ToggleButton).IsChecked)
+            {
+                AnnotationPropertiesChanged?.Invoke(sender, (sender as ToggleButton).Tag.ToString());
+            }
+            else
+            {
+                AnnotationPropertiesCancel?.Invoke(sender, null);
+            }
+        }
+
+        public void InitAnnotationBar(AnnotationProperties[] annotationProperties)
+        {
+            brush = (Brush)FindResource("btn.bg.bota");
+
+            for (int i = 0; i < annotationProperties.Length; i++)
+            {
+                AnnotationGrid.ColumnDefinitions.Add(new ColumnDefinition());
+                AnnotationProperties annotation = annotationProperties[i];
+                ToggleButton toggleButton = new ToggleButton();
+                toggleButton.Tag = annotation.ToString();
+                CreateAnnotationButton(toggleButton);
+                AnnotationGrid.Width += 50;
+            }
+        }
+    }
+}

+ 0 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/CPDFBOTABarControl.xaml.cs

@@ -35,7 +35,6 @@ namespace compdfkit_tools.PDFControl
         private CPDFViewer pdfViewer;
 
         private ToggleButton bookmarkButton;
-
         private ToggleButton outlineButton;
         private ToggleButton thumbnailButton;
         private ToggleButton annotButton;

+ 0 - 51
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Bar/PDFAnnotationBarControl.xaml.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace compdfkit_tools.PDFControl
-{
-    public enum AnnotationProperties
-    {
-        Markup,
-        FreeText,
-        Note,
-        Sharp,
-        Line,
-        Stamp,
-        Signature,
-        Link,
-        Sound
-    }
-
-    /// <summary>
-    /// PDFAnnotationBarControl.xaml 的交互逻辑
-    /// </summary>
-    public partial class PDFAnnotationBarControl : UserControl
-    {
-        public PDFAnnotationBarControl(AnnotationProperties[] annotationProperties)
-        {
-            InitializeComponent();
-            InitAnnotationBar(annotationProperties);
-        }
-
-        private void InitAnnotationBar(AnnotationProperties[] annotationProperties)
-        {
-            for(int i = 0; i < annotationProperties.Length; i++)
-            {
-                AnnotationProperties annotation = annotationProperties[i];
-
-            }
-        }
-    }
-}

+ 121 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Convert/BoolToVisibilityConvert.cs

@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows;
+
+namespace compdfkit_tools.Common
+{
+    /// <summary>
+    /// Value converter between bool and Visibility
+    /// </summary>
+    [ValueConversion(typeof(bool), typeof(Visibility))]
+    public class BoolToVisibleConverter : IValueConverter
+    {
+        #region IValueConverter Members
+        /// <summary>
+        /// Converts a value.
+        /// </summary>
+        /// <param name="value">The value produced by the binding source.</param>
+        /// <param name="targetType">The type of the binding target property.</param>
+        /// <param name="parameter">The converter parameter to use.</param>
+        /// <param name="culture">The culture to use in the converter.</param>
+        /// <returns>
+        /// A converted value. If the method returns null, the valid null value is used.
+        /// </returns>
+        public object Convert(
+            object value,
+            Type targetType,
+            object parameter,
+            CultureInfo culture)
+        {
+            if ((bool)value)
+            {
+                return Visibility.Visible;
+            }
+            else
+            {
+                return Visibility.Collapsed;
+            }
+        }
+
+        /// <summary>
+        /// Converts a value back.
+        /// </summary>
+        /// <param name="value">The value that is produced by the binding target.</param>
+        /// <param name="targetType">The type to convert to.</param>
+        /// <param name="parameter">The converter parameter to use.</param>
+        /// <param name="culture">The culture to use in the converter.</param>
+        /// <returns>
+        /// A converted value. If the method returns null, the valid null value is used.
+        /// </returns>
+        public object ConvertBack(
+            object value,
+            Type targetType,
+            object parameter,
+            CultureInfo culture)
+        {
+            return (Visibility)value == Visibility.Visible;
+        }
+        #endregion IValueConverter Members
+    }
+
+    /// <summary>
+    /// Value converter between bool and Visibility
+    /// </summary>
+    [ValueConversion(typeof(bool), typeof(Visibility))]
+    public class BoolToCollapsedConverter : IValueConverter
+    {
+        #region IValueConverter Members
+        /// <summary>
+        /// Converts a value.
+        /// </summary>
+        /// <param name="value">The value produced by the binding source.</param>
+        /// <param name="targetType">The type of the binding target property.</param>
+        /// <param name="parameter">The converter parameter to use.</param>
+        /// <param name="culture">The culture to use in the converter.</param>
+        /// <returns>
+        /// A converted value. If the method returns null, the valid null value is used.
+        /// </returns>
+        public object Convert(
+            object value,
+            Type targetType,
+            object parameter,
+            CultureInfo culture)
+        {
+            if ((bool)value)
+            {
+                return Visibility.Collapsed;
+
+            }
+            else
+            {
+                return Visibility.Visible;
+
+            }
+        }
+
+        /// <summary>
+        /// Converts a value back.
+        /// </summary>
+        /// <param name="value">The value that is produced by the binding target.</param>
+        /// <param name="targetType">The type to convert to.</param>
+        /// <param name="parameter">The converter parameter to use.</param>
+        /// <param name="culture">The culture to use in the converter.</param>
+        /// <returns>
+        /// A converted value. If the method returns null, the valid null value is used.
+        /// </returns>
+        public object ConvertBack(
+            object value,
+            Type targetType,
+            object parameter,
+            CultureInfo culture)
+        {
+            return null;
+        }
+        #endregion IValueConverter Members
+    }
+}

File diff ditekan karena terlalu besar
+ 140 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/DropDownNumberBoxControl.xaml


+ 129 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/DropDownNumberBoxControl.xaml.cs

@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace compdfkit_tools.Common
+{
+    /// <summary>
+    /// NumberBoxDropDownControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class DropDownNumberBoxControl : UserControl
+    {
+        private string regixString = "[^0-9]+";
+
+        // The dependency property which will be accessible on the UserControl
+        public static readonly DependencyProperty UnitProperty =
+            DependencyProperty.Register("Unit", typeof(string), typeof(DropDownNumberBoxControl), new UIPropertyMetadata());
+
+        public string Unit
+        {
+            get { return (string)GetValue(UnitProperty); }
+            set { SetValue(UnitProperty, value); }
+        }
+
+        // The dependency property which will be accessible on the UserControl
+        public static readonly DependencyProperty TextProperty =
+            DependencyProperty.Register("Text", typeof(string), typeof(DropDownNumberBoxControl), new UIPropertyMetadata());
+
+        public string Text
+        {
+            get { return (string)GetValue(TextProperty); }
+            set { SetValue(TextProperty, value); }
+        }
+
+        public static readonly DependencyProperty MaxiumProperty =
+            DependencyProperty.Register("Maxium", typeof(int), typeof(DropDownNumberBoxControl), new UIPropertyMetadata());
+
+        public int Maxium
+        {
+            get { return (int)GetValue(MaxiumProperty); }
+            set { SetValue(MaxiumProperty, value); }
+        }
+
+        public static readonly DependencyProperty MinimumProperty =
+    DependencyProperty.Register("Minimum", typeof(int), typeof(DropDownNumberBoxControl), new UIPropertyMetadata());
+
+        public int Minimum
+        {
+            get { return (int)GetValue(MinimumProperty); }
+            set { SetValue(MinimumProperty, value); }
+        }
+
+        public event EventHandler<string> InputEnterEvent;
+        public event EventHandler<string> SetPresetEvent;
+
+        public DropDownNumberBoxControl()
+        {
+            InitializeComponent();
+        }
+
+
+        public void InitPresetNumberArray(List<int> presetNumber)
+        {
+          
+            List<string> array = new List<string>();
+            for (int i = 0; i < presetNumber.Count; i++)
+            {
+                array.Add(presetNumber[i].ToString());
+            }
+            ComboBox.ItemsSource = array;
+            ComboBox.SelectedIndex = 0;
+        }
+
+        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+            e.Handled = new Regex(regixString).IsMatch(e.Text);
+        }
+
+        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Enter)
+            {
+                InputEnterEvent?.Invoke(sender, Text);
+            }
+            if ((e.KeyStates == Keyboard.GetKeyStates(Key.LeftCtrl) || e.KeyStates == Keyboard.GetKeyStates(Key.RightCtrl)) && e.KeyStates == Keyboard.GetKeyStates(Key.V))
+                e.Handled = true;
+            else
+                e.Handled = false;
+        }
+
+        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (!string.IsNullOrEmpty(TextBox.Text))
+            {
+                if (int.Parse(TextBox.Text) > Maxium)
+                {
+                    TextBox.Text = Maxium.ToString();
+                }
+
+                if (int.Parse(TextBox.Text) < Minimum)
+                {
+                    TextBox.Text = Minimum.ToString();
+                }
+            }
+        }
+
+        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if ((sender as ComboBox).SelectedItem != null)
+            {
+                // 处理空引用异常的代码
+                TextBox.Text = (sender as ComboBox).SelectedItem.ToString();
+                SetPresetEvent?.Invoke(sender, TextBox.Text);
+            }
+        }
+    }
+}
+

+ 2 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFDisplaySettings/PDFDisplaySettingsControl/CPDFDrawModeControl.xaml.cs

@@ -40,10 +40,10 @@ namespace compdfkit_tools.PDFControl
             GetDrawMode.Add("Dark", DrawModes.Draw_Mode_Dark);
             GetDrawMode.Add("Green", DrawModes.Draw_Mode_Green);
             GetDrawMode.Add("Custom", DrawModes.Draw_Mode_Custom);
-            CPDFDrawModeUI.SetDrawModeEvent += CPDFDrawModeUI_SetColorModeEvent;
+            CPDFDrawModeUI.SetDrawModeEvent += CPDFDrawModeUI_SetDrawModeEvent;
         }
 
-        private void CPDFDrawModeUI_SetColorModeEvent(object sender, string e)
+        private void CPDFDrawModeUI_SetDrawModeEvent(object sender, string e)
         {
             pdfViewer.SetDrawMode(GetDrawMode[(sender as RadioButton).Tag as string]);
         }

+ 21 - 5
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer.PdfViewer;
+using compdfkit_tools.Common;
+using ComPDFKitViewer.PdfViewer;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -26,7 +27,7 @@ namespace compdfkit_tools.PDFControl
         public CPDFScalingControl()
         {
             InitializeComponent();
-            CPDFScalingUI.Loaded += PDFScalingControl_Loaded; ;
+            CPDFScalingUI.Loaded += PDFScalingControl_Loaded;
         }
 
         public void InitWithPDFViewer(CPDFViewer pdfViewer)
@@ -39,8 +40,10 @@ namespace compdfkit_tools.PDFControl
             CPDFScalingUI.SetScaleEvent += PDFScalingControl_SetScaleEvent;
             CPDFScalingUI.ScaleIncreaseEvent += PDFScalingControl_ScaleIncreaseEvent;
             CPDFScalingUI.ScaleDecreaseEvent += PDFScalingControl_ScaleDecreaseEvent;
+            CPDFScalingUI.SetPresetScaleEvent += CPDFScalingUI_SetPresetScaleEvent;
         }
-         
+
+
         private void PDFScalingControl_ScaleDecreaseEvent(object sender, EventArgs e)
         {
             if (pdfViewer == null || pdfViewer.Document == null)
@@ -61,13 +64,26 @@ namespace compdfkit_tools.PDFControl
             pdfViewer.Zoom((double)(CPDFScalingUI.Scale) / 100);
         }
 
-        private void PDFScalingControl_SetScaleEvent(object sender, int e)
+        private void PDFScalingControl_SetScaleEvent(object sender, string e)
+        {
+            if (pdfViewer == null || pdfViewer.Document == null)
+            {
+                return;
+            }
+            if (!string.IsNullOrEmpty(e))
+            {
+                pdfViewer.Zoom(double.Parse(e) / 100);
+            }
+        }
+
+
+        private void CPDFScalingUI_SetPresetScaleEvent(object sender, string e)
         {
             if (pdfViewer == null || pdfViewer.Document == null)
             {
                 return;
             }
-            pdfViewer.Zoom((double)e / 100);
+            pdfViewer.Zoom(double.Parse(e) / 100);
         }
     }
 }

+ 2 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.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.PDFControlUI"
+             xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
              d:DesignHeight="30" d:DesignWidth="150">
     <Grid Height="30" Width="150" >
@@ -12,9 +13,7 @@
             <ColumnDefinition Width="4*"></ColumnDefinition>
         </Grid.ColumnDefinitions>
         <StackPanel Orientation="Horizontal" Height="30">
-            <TextBox Width="30" x:Name="ScaleTextBox" Text="{Binding Scale, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" KeyDown="ScaleTextBox_KeyDown"></TextBox>
-            <TextBlock Text="%" VerticalAlignment="Center"></TextBlock>
-            <Button Height="30" Width="30"></Button>
+            <cpdfcommon:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl" Height="30" Width=" 85" Unit="%" Maxium="1600" Minimum="0" Text="{Binding Scale,Mode=TwoWay}"></cpdfcommon:DropDownNumberBoxControl>
         </StackPanel>
         <StackPanel Grid.Column="1" Orientation="Horizontal">
             <Button x:Name="ScaleDecreaseButton" Height="30" Width="30" Click="ScaleDecreaseButton_Click"></Button>

+ 29 - 7
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer.PdfViewer;
+using compdfkit_tools.Common;
+using ComPDFKitViewer.PdfViewer;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -39,22 +40,43 @@ namespace compdfkit_tools.PDFControlUI
             }
         }
 
-        public event EventHandler<int> SetScaleEvent;
+
+        public event EventHandler<string> SetScaleEvent;
+        public event EventHandler<string> SetPresetScaleEvent;
         public event EventHandler ScaleIncreaseEvent;
         public event EventHandler ScaleDecreaseEvent;
 
+
         public CPDFScalingUI()
         {
             InitializeComponent();
             DataContext = this;
+            DropDownNumberBoxControl.InputEnterEvent += DropDownNumberBoxControl_InputEnterEvent;
+            DropDownNumberBoxControl.SetPresetEvent += DropDownNumberBoxControl_SetPresetEvent;
+            InitPresetNumberArray();
         }
 
-        private void ScaleTextBox_KeyDown(object sender, KeyEventArgs e)
+        private void DropDownNumberBoxControl_SetPresetEvent(object sender, string e)
         {
-            if (e.Key == Key.Enter)
-            {
-                SetScaleEvent?.Invoke(this, Scale);
-            }
+            SetPresetScaleEvent?.Invoke(this, e);
+        }
+
+        public void InitPresetNumberArray()
+        {
+            List<int> list = new List<int>();
+            list.Add(25);
+            list.Add(50);
+            list.Add(100);
+            list.Add(200);
+            list.Add(400);
+            list.Add(800);
+            list.Add(1600);
+            DropDownNumberBoxControl.InitPresetNumberArray(list);
+        }
+
+        private void DropDownNumberBoxControl_InputEnterEvent(object sender, string e)
+        {
+            SetScaleEvent?.Invoke(this,e);
         }
 
         private void ScaleDecreaseButton_Click(object sender, RoutedEventArgs e)

+ 51 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -68,13 +68,17 @@
     <Compile Include="Common\Bar\ModeSelectorBarControl.xaml.cs">
       <DependentUpon>ModeSelectorBarControl.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Common\Bar\PDFAnnotationBarControl.xaml.cs">
-      <DependentUpon>PDFAnnotationBarControl.xaml</DependentUpon>
+    <Compile Include="Common\Bar\CPDFAnnotationBarControl.xaml.cs">
+      <DependentUpon>CPDFAnnotationBarControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\Bar\TitleBarControl.xaml.cs">
       <DependentUpon>TitleBarControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\Convert\BoolToVisibilityConvert.cs" />
     <Compile Include="Common\Convert\ListViewWidthConvert.cs" />
+    <Compile Include="Common\DropDownNumberBoxControl.xaml.cs">
+      <DependentUpon>DropDownNumberBoxControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Helper\CommonHelper.cs" />
     <Compile Include="PDFView\PDFBookmark\PDFBookmarkControl\CPDFBookmarkControl.xaml.cs">
       <DependentUpon>CPDFBookmarkControl.xaml</DependentUpon>
@@ -166,7 +170,8 @@
     </None>
   </ItemGroup>
   <ItemGroup>
-    <Folder Include="Annotation\PDFAnnotationList\" />
+    <Folder Include="Annotation\PDFMarkup\PDFHighlight\PDFHighlightControl\" />
+    <Folder Include="Annotation\PDFMarkup\PDFHighlight\PDFHighlightUI\" />
   </ItemGroup>
   <ItemGroup>
     <Page Include="Asset\Style\MenuItemStyle.xaml">
@@ -185,7 +190,7 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Common\Bar\PDFAnnotationBarControl.xaml">
+    <Page Include="Common\Bar\CPDFAnnotationBarControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -193,6 +198,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Common\DropDownNumberBoxControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="PDFView\PDFBookmark\PDFBookmarkControl\CPDFBookmarkControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -290,5 +299,43 @@
       <Generator>MSBuild:Compile</Generator>
     </Page>
   </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Highlight.png">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Resource>
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Underline.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Strikeout.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Squiggly.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Note.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Sharp.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Freetext.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Stamp.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Signature.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Line.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Link.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Asset\Resource\Annotation\Sound.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>