Browse Source

PDFAnnotation(windows) - Shape

liuaoran 1 year ago
parent
commit
5f9486f3dd
20 changed files with 256 additions and 228 deletions
  1. 0 18
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml
  2. 0 28
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml.cs
  3. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml
  4. 31 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml.cs
  5. 34 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs
  6. 17 4
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs
  7. 4 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs
  8. 7 6
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml
  9. 87 9
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs
  10. 2 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Style/RadioButtonStyle.xaml
  11. 3 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml
  12. 10 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml.cs
  13. 21 27
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml
  14. 0 12
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthControlControl.xaml
  15. 0 28
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthControlControl.xaml.cs
  16. 0 17
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthUI.xaml
  17. 0 52
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthUI.xaml.cs
  18. 3 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpacityControl.xaml.cs
  19. 8 7
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpactiyUI.xaml.cs
  20. 28 10
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

+ 0 - 18
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml

@@ -1,18 +0,0 @@
-<UserControl x:Class="compdfkit_tools.PDFControl.CPDFArrowControlControl"
-             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:cpdftoolsui="clr-namespace:compdfkit_tools.PDFControlUI"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:compdfkit_tools.PDFControl"
-             mc:Ignorable="d" 
-             d:DesignHeight="75" d:DesignWidth="300">
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition></ColumnDefinition>
-            <ColumnDefinition></ColumnDefinition>
-        </Grid.ColumnDefinitions>
-        <cpdftoolsui:CPDFArrowUI></cpdftoolsui:CPDFArrowUI>
-        <cpdftoolsui:CPDFArrowUI Grid.Column="1"></cpdftoolsui:CPDFArrowUI>
-    </Grid>
-</UserControl>

+ 0 - 28
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml.cs

@@ -1,28 +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
-{
-    /// <summary>
-    /// CPDFArrowControlControl.xaml 的交互逻辑
-    /// </summary>
-    public partial class CPDFArrowControlControl : UserControl
-    {
-        public CPDFArrowControlControl()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml

@@ -84,7 +84,7 @@
     </UserControl.Resources>
     <Grid>
         <Border BorderBrush="#E2E3E6" BorderThickness="0"  Width="115" Height="32">
-            <ComboBox x:Name="StartArrowBox" Background="Transparent" BorderThickness="1" BorderBrush="#FFE2E3E6" IsReadOnly="True" MaxDropDownHeight="200">
+            <ComboBox x:Name="ArrowBox" Background="Transparent" BorderThickness="1" BorderBrush="#FFE2E3E6" IsReadOnly="True" MaxDropDownHeight="200" SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}">
                 <ComboBox.ItemContainerStyle>
                     <Style TargetType="{x:Type ComboBoxItem}">
                         <Setter Property="Padding" Value="25 0 0 0"></Setter>

+ 31 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -18,11 +19,40 @@ namespace compdfkit_tools.PDFControlUI
     /// <summary>
     /// CPDFArrowControl.xaml 的交互逻辑
     /// </summary>
-    public partial class CPDFArrowUI : UserControl
+    public partial class CPDFArrowUI : UserControl, INotifyPropertyChanged
     {
+        public event EventHandler ArrowChanged;
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        private int _selectedIndex = 1;
+        public int SelectedIndex
+        {
+            get
+            {
+                return _selectedIndex;
+            }
+            set
+            {
+                _selectedIndex = value;
+                OnPropertyChanged(nameof(SelectedIndex));
+                OnArrowChanged();
+            }
+        }
+
         public CPDFArrowUI()
         {
             InitializeComponent();
+            this.DataContext = this;  
+        }
+
+        private void OnArrowChanged()
+        {
+            ArrowChanged?.Invoke(this, EventArgs.Empty);
+        }
+
+        protected void OnPropertyChanged(string propertyName)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
     }
 }

+ 34 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -40,11 +40,40 @@ namespace compdfkit_tools.Data
             { "Line", AnnotationType.Line },
             { "Arrow", AnnotationType.Arrow }
         };
+
+        public static Dictionary<int, C_LINE_TYPE> GetLineTypeFromIndex = new Dictionary<int, C_LINE_TYPE>()
+        {
+            { 0, C_LINE_TYPE.LINETYPE_NONE },
+            { 1, C_LINE_TYPE.LINETYPE_ARROW },
+            { 2, C_LINE_TYPE.LINETYPE_CLOSEDARROW },
+            { 3, C_LINE_TYPE.LINETYPE_SQUARE },
+            { 4, C_LINE_TYPE.LINETYPE_CIRCLE },
+            { 5, C_LINE_TYPE.LINETYPE_DIAMOND },
+            { 6, C_LINE_TYPE.LINETYPE_BUTT },
+            { 7, C_LINE_TYPE.LINETYPE_ROPENARROW },
+            { 8, C_LINE_TYPE.LINETYPE_RCLOSEDARROW },
+            { 9, C_LINE_TYPE.LINETYPE_SLASH }
+        };
+    }
+
+    public class LineType
+    {
+        public C_LINE_TYPE HeadType;
+        public C_LINE_TYPE TailType;
+    }
+
+    /// <summary>
+    /// 用于换算的dash
+    /// </summary>
+    public class CPDFDash
+    {
+        public bool IsSolid = true;
+        public int DashSpacing = 1;
     }
 
     public abstract class CPDFAnnotationData
     {
-        public AnnotationType AnnotationProperties;
+        public AnnotationType AnnotationType;
         public string Note = string.Empty;
         public string Author = "ComPDFKit";
         public bool IsLocked = false;
@@ -62,7 +91,8 @@ namespace compdfkit_tools.Data
         public Color FillColor = Color.FromRgb(255, 255, 255);
         public double Opacity = 1;
         public double Thickness = 1;
-        public int DashSpacing = 1;
+        public DashStyle DashStyle = DashStyles.Solid;
+        public LineType LineType = new LineType() { HeadType = C_LINE_TYPE.LINETYPE_NONE, TailType = C_LINE_TYPE.LINETYPE_NONE};
     }
 
     public class CPDFLineShapeData : CPDFAnnotationData
@@ -72,6 +102,7 @@ namespace compdfkit_tools.Data
         public C_LINE_TYPE TailLineType = C_LINE_TYPE.LINETYPE_NONE;
         public double Opacity = 1;
         public double Thickness = 1;
-        public int DashSpacing = 1;
+        public DashStyle DashStyle = DashStyles.Solid;
+        public LineType LineType = new LineType() { HeadType = C_LINE_TYPE.LINETYPE_NONE, TailType = C_LINE_TYPE.LINETYPE_NONE };
     }
 }

+ 17 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -64,7 +64,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
             AnnotationPanelContainer.Visibility = Visibility.Visible;
         }
 
-        private void GetAnnotationData()
+        private void ChangeAnnotationData()
         {
             switch (currentAnnotationType)
             {
@@ -77,6 +77,11 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     break;
 
                 case AnnotationType.Square:
+                case AnnotationType.Circle:
+                case AnnotationType.Line:
+                case AnnotationType.Arrow:
+                    (annotationPanel as CPDFShapeUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
+                    SetAnnotationProperty((annotationPanel as CPDFShapeUI).GetShapeData());
                     break;
                 default:
                     break;
@@ -85,10 +90,10 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
 
         private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData)
         {
-            AnnotationType annotationProperties = pdfAnnotationData.AnnotationProperties;
+            AnnotationType annotationType = pdfAnnotationData.AnnotationType;
             AnnotHandlerEventArgs annotHandlerEventArgs = null;
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
-            switch (annotationProperties)
+            switch (annotationType)
             {
                 case AnnotationType.Highlight:
                     CPDFMarkupData highlightData = pdfAnnotationData as CPDFMarkupData;
@@ -131,7 +136,15 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     break;
 
                 case AnnotationType.Square:
+                    CPDFShapeData squareData = pdfAnnotationData as CPDFShapeData;
                     annotHandlerEventArgs = new SquareAnnotArgs();
+                    (annotHandlerEventArgs as SquareAnnotArgs).LineColor = squareData.BorderColor;
+                    (annotHandlerEventArgs as SquareAnnotArgs).BgColor = squareData.FillColor;
+                    (annotHandlerEventArgs as SquareAnnotArgs).LineWidth = squareData.Thickness;
+                    (annotHandlerEventArgs as SquareAnnotArgs).Transparency = squareData.Opacity;
+                    (annotHandlerEventArgs as SquareAnnotArgs).LineDash = squareData.DashStyle;
+                    (annotHandlerEventArgs as SquareAnnotArgs).Author = squareData.Author;
+                    (annotHandlerEventArgs as SquareAnnotArgs).Content = squareData.Note;
                     break;
                 case AnnotationType.Circle:
                     annotHandlerEventArgs = new CircleAnnotArgs();
@@ -188,7 +201,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
             }
             SetAnnotationPanel(annotationPanel);
             ExpandPanel();
-            GetAnnotationData();
+            ChangeAnnotationData();
         }
     }
 }

+ 4 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs

@@ -23,9 +23,10 @@ namespace compdfkit_tools.PDFControlUI
     /// </summary>
     public partial class CPDFMarkupUI : UserControl
     {
-        public event EventHandler<CPDFAnnotationData> PropertyChanged;
         private AnnotationType currentAnnotationType;
 
+        public event EventHandler<CPDFAnnotationData> PropertyChanged;
+
         public CPDFMarkupUI()
         {
             InitializeComponent();
@@ -51,9 +52,10 @@ namespace compdfkit_tools.PDFControlUI
         public CPDFMarkupData GetMarkupData()
         {
             CPDFMarkupData pdfMarkupData = new CPDFMarkupData();
-            pdfMarkupData.AnnotationProperties = currentAnnotationType;
+            pdfMarkupData.AnnotationType = currentAnnotationType;
             pdfMarkupData.Color = ((SolidColorBrush)ColorPickerControl.Brush).Color;
             pdfMarkupData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
+            pdfMarkupData.Note = NoteTextBox.Text;
             return pdfMarkupData;
         }
 

+ 7 - 6
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml

@@ -28,15 +28,16 @@
                 <cpdfcommon:CPDFOpacityControl x:Name="CPDFOpacityControl"></cpdfcommon:CPDFOpacityControl>
             </StackPanel>
             <StackPanel Height="75" Margin="5">
-                <TextBlock Text="Border Width"></TextBlock>
-                <cpdfcommon:CPDFBorderWidthUI x:Name="CPDFBorderWidthControl"></cpdfcommon:CPDFBorderWidthUI>
+                <TextBlock Text="Thickness"></TextBlock>
+                <cpdfcommon:CPDFThicknessControl x:Name="CPDFThicknessControl"></cpdfcommon:CPDFThicknessControl>
             </StackPanel>
-            <StackPanel Height="75" Margin="5">
-                <TextBlock Text="Dotted Line"></TextBlock>
-                <cpdfcommon:CPDFOpacityControl x:Name="DottedLineControl"></cpdfcommon:CPDFOpacityControl>
+            <StackPanel x:Name="LineStyleStackPanel" Height="75" Margin="5">
+                <TextBlock Text="Line Style"></TextBlock>
+                <cpdfcommon:CPDFLineStyleControl x:Name="CPDFLineStyleControl"></cpdfcommon:CPDFLineStyleControl>
             </StackPanel>
             <StackPanel x:Name="ArrowStackPanel" Visibility="Visible" Height="75">
-                <cpdftools:CPDFArrowControlControl></cpdftools:CPDFArrowControlControl>
+                <TextBlock Text="Start and End"></TextBlock>
+                <cpdftools:CPDFArrowControl x:Name="CPDFArrowControl"></cpdftools:CPDFArrowControl>
             </StackPanel>
             <StackPanel Height="200" Margin="5">
                 <TextBlock Text="Note"></TextBlock>

+ 87 - 9
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -24,47 +24,125 @@ namespace compdfkit_tools.PDFControlUI
     {
         private AnnotationType currentAnnotationType;
 
+        public event EventHandler<CPDFAnnotationData> PropertyChanged;
+
         public CPDFShapeUI()
         {
             InitializeComponent();
+            BorderColorPickerControl.ColorChanged += BorderColorPickerControl_ColorChanged;
+            CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged;
+            CPDFThicknessControl.ThicknessChanged += CPDFThicknessControl_ThicknessChanged;
+        }
+
+        private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetShapeData());
+        }
+
+        private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetShapeData());
+        }
+
+        private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetShapeData());
+        }
+
+        private void FillColorPickerControl_ColorChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetShapeData());
+        }
+
+        private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(PropertyChanged, GetShapeData());
         }
 
-        public CPDFShapeData GetShapeData()
+        public DashStyle CalculateDashStyle(CPDFDash pdfDash, int Thickness )
         {
-            CPDFShapeData pdfShapeData = new CPDFShapeData();
+            DashStyle dashStyle = new DashStyle();
+            if (pdfDash.IsSolid)
+            {
+                dashStyle = DashStyles.Solid;
+                return dashStyle;
+            }
+            else
+            {
+                dashStyle.Dashes.Add(pdfDash.DashSpacing / Thickness);
+                dashStyle.Dashes.Add(pdfDash.DashSpacing / Thickness);
+                return dashStyle;
+            }
+        }
 
-            return pdfShapeData;
+        public CPDFAnnotationData GetShapeData()
+        {
+            if (currentAnnotationType == AnnotationType.Circle || currentAnnotationType == AnnotationType.Square)
+            {
+                CPDFShapeData pdfShapeData = new CPDFShapeData();
+                pdfShapeData.AnnotationType = currentAnnotationType;
+                pdfShapeData.BorderColor = ((SolidColorBrush)BorderColorPickerControl.Brush).Color;
+                pdfShapeData.FillColor = ((SolidColorBrush)FillColorPickerControl.Brush).Color;
+                pdfShapeData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                pdfShapeData.Thickness = CPDFThicknessControl.Thickness;
+                pdfShapeData.DashStyle = CalculateDashStyle(CPDFLineStyleControl.CPDFDash, CPDFThicknessControl.Thickness);
+                pdfShapeData.LineType = CPDFArrowControl.LineType;
+                pdfShapeData.Note = NoteTextBox.Text;
+                return pdfShapeData;
+            }
+            else
+            {
+                CPDFLineShapeData pdfLineShapeData = new CPDFLineShapeData();
+                pdfLineShapeData.AnnotationType = currentAnnotationType;
+                pdfLineShapeData.BorderColor = ((SolidColorBrush)BorderColorPickerControl.Brush).Color;
+                pdfLineShapeData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                pdfLineShapeData.LineType = CPDFArrowControl.LineType;
+                pdfLineShapeData.Thickness = CPDFThicknessControl.Thickness;
+                pdfLineShapeData.DashStyle = CalculateDashStyle(CPDFLineStyleControl.CPDFDash, CPDFThicknessControl.Thickness);
+                pdfLineShapeData.Note = NoteTextBox.Text;
+                return pdfLineShapeData;
+            }
         }
 
-        public void SetUIWhenRectAndRound()
+        public void InitWhenRectAndRound()
         {
+            FillColorStackPanel.Visibility = Visibility.Visible;
+            ArrowStackPanel.Visibility = Visibility.Collapsed;
 
+            FillColorPickerControl.ColorChanged += FillColorPickerControl_ColorChanged;
+            CPDFArrowControl.ArrowChanged -= CPDFArrowControl_ArrowChanged;
         }
 
-        public void SetUIWhenArrowAndLine()
+        public void InitWhenArrowAndLine()
         {
+            FillColorStackPanel.Visibility = Visibility.Collapsed;
+            ArrowStackPanel.Visibility = Visibility.Visible;
 
+            CPDFArrowControl.ArrowChanged += CPDFArrowControl_ArrowChanged;
+            FillColorPickerControl.ColorChanged -= FillColorPickerControl_ColorChanged;
         }
 
+
+
         public void InitWithAnnotationType(AnnotationType annotationType)
         {
             switch (annotationType)
             {
                 case AnnotationType.Square:
                     TitleTextBlock.Text = "Square";
-                    SetUIWhenRectAndRound();
+                    InitWhenRectAndRound();
                     break;
                 case AnnotationType.Circle:
                     TitleTextBlock.Text = "Circle";
-                    SetUIWhenRectAndRound();
+                    InitWhenRectAndRound();
                     break;
                 case AnnotationType.Arrow:
                     TitleTextBlock.Text = "Arrow";
-                    SetUIWhenArrowAndLine();
+                    InitWhenArrowAndLine();
                     break;
                 case AnnotationType.Line:
                     TitleTextBlock.Text = "Line";
-                    SetUIWhenArrowAndLine();
+                    InitWhenArrowAndLine();
                     break;
                 default:
                     throw new ArgumentException("Not Excepted Argument");

+ 2 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Style/RadioButtonStyle.xaml

@@ -30,4 +30,6 @@
         </Setter>
     </Style>
 
+    
+    
 </ResourceDictionary>

+ 3 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml

@@ -32,7 +32,7 @@
                 </Setter.Value>
             </Setter>
         </Style>
-        <Style x:Key="NumericUpDown" TargetType="{x:Type TextBox}">
+        <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}}"/>
@@ -50,7 +50,7 @@
                             <Grid>
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition></ColumnDefinition>
-                                    <ColumnDefinition Width="30"></ColumnDefinition>
+                                    <ColumnDefinition Width="20"></ColumnDefinition>
                                     <ColumnDefinition Width="20"></ColumnDefinition>
                                 </Grid.ColumnDefinitions>
                                 <ScrollViewer Grid.Column="0" x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
@@ -87,7 +87,7 @@
         </Style>
     </UserControl.Resources>
     <Grid>
-        <TextBox x:Name="TextBox" Text="{Binding Text}" Style="{StaticResource NumericUpDown}" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="TextBox_PreviewTextInput" PreviewKeyDown="TextBox_PreviewKeyDown" TextChanged="TextBox_TextChanged"></TextBox>
+        <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>
     </Grid>
 </UserControl>
 

+ 10 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml.cs

@@ -33,6 +33,7 @@ namespace compdfkit_tools.Common
             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
@@ -41,6 +42,15 @@ namespace compdfkit_tools.Common
             set { SetValue(MaxiumProperty, 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());
+        public string Text
+        {
+            get { return (string)GetValue(TextProperty); }
+            set { SetValue(TextProperty, value); }
+        }
+
         public static readonly DependencyProperty MinimumProperty =
     DependencyProperty.Register("Minimum", typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata());
         public int Minimum

+ 21 - 27
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml

@@ -7,40 +7,34 @@
              d:DesignHeight="40" d:DesignWidth="220">
     <UserControl.Resources>
         <Style x:Key="CommonColorRadioButton" TargetType="{x:Type RadioButton}">
-            <Setter Property="HorizontalAlignment" Value="Center"></Setter>
-            <Setter Property="VerticalAlignment" Value="Center"></Setter>
-            <Setter Property="Height" Value="30"></Setter>
-            <Setter Property="Width" Value="30"></Setter>
+            <Setter Property="HorizontalAlignment" Value="Center" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Setter Property="Height" Value="30" />
+            <Setter Property="Width" Value="30" />
             <Setter Property="Template">
                 <Setter.Value>
                     <ControlTemplate TargetType="{x:Type RadioButton}">
-                        <Grid Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
-                            <Border x:Name="BorderOver" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" Margin="1"></Border>
-                            <Border x:Name="BorderChecked" Visibility="Collapsed" BorderBrush="#88000000" BorderThickness="1"></Border>
+                        <Grid>
+                            <Ellipse x:Name="BackgroundEllipse"
+                             Fill="{TemplateBinding Background}"
+                             Stroke="{TemplateBinding BorderBrush}"
+                             StrokeThickness="{TemplateBinding BorderThickness}"
+                             Height="{TemplateBinding Height}"
+                             Width="{TemplateBinding Width}" />
+                            <Ellipse x:Name="CheckedEllipse"
+                             Fill="{TemplateBinding Background}"
+                             Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
+                             StrokeThickness="2"
+                             Visibility="Collapsed"
+                             Height="{TemplateBinding Height}"
+                             Width="{TemplateBinding Width}" />
                         </Grid>
-
                         <ControlTemplate.Triggers>
-                            <Trigger Property="HasContent" Value="True">
-                                <Setter Property="FocusVisualStyle">
-                                    <Setter.Value>
-                                        <Style>
-                                            <Setter Property="Control.Template">
-                                                <Setter.Value>
-                                                    <ControlTemplate>
-                                                        <Rectangle Margin="14,0,0,0" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
-                                                    </ControlTemplate>
-                                                </Setter.Value>
-                                            </Setter>
-                                        </Style>
-                                    </Setter.Value>
-                                </Setter>
+                            <Trigger Property="IsChecked" Value="True">
+                                <Setter TargetName="CheckedEllipse" Property="Visibility" Value="Visible" />
                             </Trigger>
                             <Trigger Property="IsMouseOver" Value="True">
-                                <Setter Property="BorderBrush" TargetName="BorderOver" Value="White"/>
-                            </Trigger>
-                            <Trigger Property="IsChecked" Value="True">
-                                <Setter Property="BorderBrush" TargetName="BorderOver" Value="White"/>
-                                <Setter Property="Visibility" TargetName="BorderChecked" Value="Visible"/>
+                                <Setter TargetName="BackgroundEllipse" Property="Stroke" Value="White" />
                             </Trigger>
                         </ControlTemplate.Triggers>
                     </ControlTemplate>

+ 0 - 12
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthControlControl.xaml

@@ -1,12 +0,0 @@
-<UserControl x:Class="compdfkit_tools.Common.PropertyControl.PDFBorderWidth.CPDFBorderWidthControlControl"
-             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.PropertyControl.PDFBorderWidth"
-             mc:Ignorable="d" 
-             d:DesignHeight="40" d:DesignWidth="300">
-    <Grid>
-            
-    </Grid>
-</UserControl>

+ 0 - 28
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthControlControl.xaml.cs

@@ -1,28 +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.Common.PropertyControl.PDFBorderWidth
-{
-    /// <summary>
-    /// CPDFBorderWidthControlControl.xaml 的交互逻辑
-    /// </summary>
-    public partial class CPDFBorderWidthControlControl : UserControl
-    {
-        public CPDFBorderWidthControlControl()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 0 - 17
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthUI.xaml

@@ -1,17 +0,0 @@
-<UserControl x:Class="compdfkit_tools.Common.CPDFBorderWidthUI"
-             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"
-             mc:Ignorable="d" 
-             d:DesignHeight="40" d:DesignWidth="300">
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition></ColumnDefinition>
-            <ColumnDefinition Width="80"></ColumnDefinition>
-        </Grid.ColumnDefinitions>
-        <Slider MinHeight="40" VerticalAlignment="Center" Maximum="10" Minimum="0" TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding BorderWidthValue, Mode=TwoWay}" Margin="10,0,10,0"></Slider>
-        <local:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl"  Grid.Column="1" Unit="pt" Maxium="10" Minimum="0" Text="{Binding BorderWidth,Mode=TwoWay}"></local:DropDownNumberBoxControl>
-    </Grid>
-</UserControl>

+ 0 - 52
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFBorderWidth/CPDFBorderWidthUI.xaml.cs

@@ -1,52 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-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.Common
-{
-    /// <summary>
-    /// CPDFBorderWidthUI.xaml 的交互逻辑
-    /// </summary>
-    public partial class CPDFBorderWidthUI : UserControl, INotifyPropertyChanged
-    {
-        public event PropertyChangedEventHandler PropertyChanged;
-
-        public event EventHandler BorderWidthChanged;
-
-        private int _borderWidth = 1;
-        public int BorderWidth
-        {
-            get
-            {
-                return _borderWidth;
-            }
-            set
-            {
-                _borderWidth = value;
-
-            }
-        }
-
-        public CPDFBorderWidthUI()
-        {
-            InitializeComponent();
-        }
-        protected void OnPropertyChanged(string propertyName)
-        {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
-        }
-
-    }
-}

+ 3 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpacityControl.xaml.cs

@@ -22,6 +22,9 @@ namespace compdfkit_tools.Common
     {
         public event EventHandler OpacityChanged;
 
+        /// <summary>
+        /// Opacity重名会引起问题
+        /// </summary>
         public int OpacityValue
         {
             get=> CPDFOpacityUI.OpacityValue;

+ 8 - 7
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpactiyUI.xaml.cs

@@ -21,13 +21,6 @@ namespace compdfkit_tools.Common
     /// </summary>
     public partial class CPDFOpacityUI : UserControl, INotifyPropertyChanged
     {
-        //public event EventHandler<string> SetCustomOpacityEvent;
-        //public event EventHandler<string> SetPresetOpacityEvent;
-        //public event EventHandler<int> SliderValueChangedEvent;
-        //public event EventHandler<int> SliderDragCompleted;
-        public event EventHandler OpacityChanged;
-
-        public event PropertyChangedEventHandler PropertyChanged;
 
 
         private int _opacityValue = 100;
@@ -46,6 +39,14 @@ namespace compdfkit_tools.Common
             }
         }
 
+        //public event EventHandler<string> SetCustomOpacityEvent;
+        //public event EventHandler<string> SetPresetOpacityEvent;
+        //public event EventHandler<int> SliderValueChangedEvent;
+        //public event EventHandler<int> SliderDragCompleted;
+        public event EventHandler OpacityChanged;
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
         public CPDFOpacityUI()
         {
             InitializeComponent();

+ 28 - 10
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -65,8 +65,8 @@
     <Reference Include="PresentationFramework" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Annotation\ArrowControl\CPDFArrowControlControl.xaml.cs">
-      <DependentUpon>CPDFArrowControlControl.xaml</DependentUpon>
+    <Compile Include="Annotation\ArrowControl\CPDFArrowControl.xaml.cs">
+      <DependentUpon>CPDFArrowControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Annotation\ArrowControl\CPDFArrowUI.xaml.cs">
       <DependentUpon>CPDFArrowUI.xaml</DependentUpon>
@@ -112,11 +112,17 @@
     <Compile Include="Common\BaseControl\DropDownNumberBoxControl.xaml.cs">
       <DependentUpon>DropDownNumberBoxControl.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Common\PropertyControl\PDFBorderWidth\CPDFBorderWidthControlControl.xaml.cs">
-      <DependentUpon>CPDFBorderWidthControlControl.xaml</DependentUpon>
+    <Compile Include="Common\PropertyControl\PDFThickness\CPDFThicknessControl.xaml.cs">
+      <DependentUpon>CPDFThicknessControl.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Common\PropertyControl\PDFBorderWidth\CPDFBorderWidthUI.xaml.cs">
-      <DependentUpon>CPDFBorderWidthUI.xaml</DependentUpon>
+    <Compile Include="Common\PropertyControl\PDFThickness\CPDThicknessUI.xaml.cs">
+      <DependentUpon>CPDThicknessUI.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\PropertyControl\PDFLineStyle\CPDFLineStyleControl.xaml.cs">
+      <DependentUpon>CPDFLineStyleControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\PropertyControl\PDFLineStyle\CPDFLineStyleUI.xaml.cs">
+      <DependentUpon>CPDFLineStyleUI.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\PropertyControl\PDFOpacity\CPDFOpacityControl.xaml.cs">
       <DependentUpon>CPDFOpacityControl.xaml</DependentUpon>
@@ -241,7 +247,7 @@
     <Resource Include="Asset\Resource\Annotation\Rect.png" />
   </ItemGroup>
   <ItemGroup>
-    <Page Include="Annotation\ArrowControl\CPDFArrowControlControl.xaml">
+    <Page Include="Annotation\ArrowControl\CPDFArrowControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -305,11 +311,19 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Common\PropertyControl\PDFBorderWidth\CPDFBorderWidthControlControl.xaml">
+    <Page Include="Common\PropertyControl\PDFThickness\CPDFThicknessControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Common\PropertyControl\PDFThickness\CPDThicknessUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Common\PropertyControl\PDFBorderWidth\CPDFBorderWidthUI.xaml">
+    <Page Include="Common\PropertyControl\PDFLineStyle\CPDFLineStyleControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Common\PropertyControl\PDFLineStyle\CPDFLineStyleUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -489,6 +503,10 @@
   <ItemGroup>
     <Resource Include="Asset\Resource\Annotation\Arrow.png" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <PackageReference Include="System.ValueTuple">
+      <Version>4.5.0</Version>
+    </PackageReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>