Prechádzať zdrojové kódy

PDFAnnotation - FreeText Freehand Note 进入与设置

liuaoran 1 rok pred
rodič
commit
d72efb0754
17 zmenil súbory, kde vykonal 420 pridanie a 40 odobranie
  1. 1 1
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs
  2. 21 5
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs
  3. 51 10
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs
  4. 35 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml
  5. 36 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs
  6. 34 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreehandUI.xaml
  7. 65 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreehandUI.xaml.cs
  8. 27 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml
  9. 47 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml.cs
  10. 1 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml
  11. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Freehand.png
  12. 3 4
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BarControl/CPDFAnnotationBarControl.xaml.cs
  13. 4 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml
  14. 21 14
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml.cs
  15. 17 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFTextStyle/CPDFTextStyleUI.xaml
  16. 28 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFTextStyle/CPDFTextStyleUI.xaml.cs
  17. 29 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

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

@@ -40,7 +40,7 @@ namespace annotation_ctrl_demo
 
         private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
         {
-            AnnotationType[] annotationProperties = { AnnotationType.Highlight, AnnotationType.Underline, AnnotationType.Strikeout, AnnotationType.Squiggly, AnnotationType.Freetext, AnnotationType.Note, AnnotationType.Circle, AnnotationType.Square, AnnotationType.Arrow, AnnotationType.Line, AnnotationType.Stamp, AnnotationType.Signature, AnnotationType.Link, AnnotationType.Sound };
+            AnnotationType[] annotationProperties = { AnnotationType.Highlight, AnnotationType.Underline, AnnotationType.Strikeout, AnnotationType.Squiggly, AnnotationType.Freehand,AnnotationType.FreeText, AnnotationType.Note, AnnotationType.Circle, AnnotationType.Square, AnnotationType.Arrow, AnnotationType.Line, AnnotationType.Stamp, AnnotationType.Signature, AnnotationType.Link, AnnotationType.Sound };
             AnnotationBarControl.InitAnnotationBar(annotationProperties);
             AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
             AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;

+ 21 - 5
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Markup;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 
@@ -18,7 +19,8 @@ namespace compdfkit_tools.Data
         Underline,
         Strikeout,
         Squiggly,
-        Freetext,
+        FreeText,
+        Freehand,
         Note,
         Circle,
         Square,
@@ -40,8 +42,11 @@ namespace compdfkit_tools.Data
             { "Square", AnnotationType.Square },
             { "Circle", AnnotationType.Circle },
             { "Line", AnnotationType.Line },
-            { "Stamp", AnnotationType.Stamp },
-            { "Arrow", AnnotationType.Arrow }
+            { "Arrow", AnnotationType.Arrow },
+            { "Freehand", AnnotationType.Freehand },
+            { "FreeText", AnnotationType.FreeText },
+            { "Note", AnnotationType.Note },
+            { "Stamp", AnnotationType.Stamp }
         };
 
         public static Dictionary<int, C_LINE_TYPE> GetLineTypeFromIndex = new Dictionary<int, C_LINE_TYPE>()
@@ -93,7 +98,7 @@ namespace compdfkit_tools.Data
         public Color BorderColor = Color.FromRgb(255, 0, 0);
         public Color FillColor = Color.FromRgb(255, 255, 255);
         public double Opacity = 1;
-        public double Thickness = 1;
+        public int Thickness = 1;
         public DashStyle DashStyle = DashStyles.Solid;
     }
 
@@ -101,10 +106,21 @@ namespace compdfkit_tools.Data
     {
         public Color BorderColor = Color.FromRgb(255, 0, 0);
         public double Opacity = 1;
-        public double Thickness = 1;
+        public int Thickness = 1;
         public DashStyle DashStyle = DashStyles.Solid;
         public LineType LineType = new LineType() { HeadLineType = C_LINE_TYPE.LINETYPE_NONE, TailLineType = C_LINE_TYPE.LINETYPE_NONE };
     }
+
+    public class CPDFFreehandData : CPDFAnnotationData { 
+        public Color BorderColor = Color.FromRgb(255, 0, 0);
+        public double Opacity = 1;
+        public int Thickness = 1;
+    }
+
+    public class CPDFNoteData : CPDFAnnotationData
+    {
+        public Color BorderColor = Color.FromRgb(255, 0, 0);
+    }
     public class CPDFStampData : CPDFAnnotationData
     {
         public string StampText = "";

+ 51 - 10
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -84,12 +84,23 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     (annotationPanel as CPDFShapeUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
                     SetAnnotationProperty((annotationPanel as CPDFShapeUI).GetShapeData());
                     break;
+                case AnnotationType.Note:
+                    (annotationPanel as CPDFNoteUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
+                    SetAnnotationProperty((annotationPanel as CPDFNoteUI).GetNoteData());
+                    break;
+                case AnnotationType.Freehand:
+                    (annotationPanel as CPDFFreehandUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
+                    SetAnnotationProperty((annotationPanel as CPDFFreehandUI).GetFreehandData());
+                    break;
+                case AnnotationType.FreeText:
+                    SetAnnotationProperty((annotationPanel as CPDFFreeTextUI).GetFreeTextData());
+                    break;
                 default:
                     break;
             }
         }
 
-        private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData)
+        private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null)
         {
             AnnotationType annotationType = pdfAnnotationData.AnnotationType;
             AnnotHandlerEventArgs annotHandlerEventArgs = null;
@@ -171,14 +182,35 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     (annotHandlerEventArgs as LineAnnotArgs).Author = lineData.Author;
                     (annotHandlerEventArgs as LineAnnotArgs).Content = lineData.Note;
                     break;
-                case AnnotationType.Stamp:
-                    CPDFStampData stampData = pdfAnnotationData as CPDFStampData;
-                    if (stampData != null)
-                    {
-                        annotHandlerEventArgs = new StampAnnotArgs();
-                        StampAnnotArgs args = annotHandlerEventArgs as StampAnnotArgs;
-                        SetStamp(ref args, stampData);
-                    }
+                case AnnotationType.Note:
+                    CPDFNoteData noteData = pdfAnnotationData as CPDFNoteData;
+                    annotHandlerEventArgs = new StickyAnnotArgs();
+                    (annotHandlerEventArgs as StickyAnnotArgs).Color = noteData.BorderColor;
+                    (annotHandlerEventArgs as StickyAnnotArgs).StickyNote = noteData.Note;
+                    (annotHandlerEventArgs as StickyAnnotArgs).Transparency = 1;
+                    (annotHandlerEventArgs as StickyAnnotArgs).Author = noteData.Author;
+                    break;
+                case AnnotationType.Freehand:
+                    CPDFFreehandData freehandData = pdfAnnotationData as CPDFFreehandData;
+                    annotHandlerEventArgs = new FreehandAnnotArgs();
+                    (annotHandlerEventArgs as FreehandAnnotArgs).InkColor = freehandData.BorderColor;
+                    (annotHandlerEventArgs as FreehandAnnotArgs).LineWidth = freehandData.Thickness;
+                    (annotHandlerEventArgs as FreehandAnnotArgs).Transparency = freehandData.Opacity;
+                    (annotHandlerEventArgs as FreehandAnnotArgs).Content = freehandData.Note;
+                    (annotHandlerEventArgs as StickyAnnotArgs).Author = freehandData.Author;
+                    break;
+                case AnnotationType.FreeText:
+                    annotHandlerEventArgs = new FreeTextAnnotArgs();
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).BgColor = Colors.AliceBlue;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).Transparency = 1;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).LineWidth = 1;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).FontName = "Helvetica";
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).FontColor = Colors.Black;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).IsBold = true;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).IsItalic = true;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).Align = TextAlignment.Left;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).Content = "";
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).Author = "au";
                     break;
                 case AnnotationType.None:
                 default:
@@ -257,6 +289,15 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     annotationPanel = new CPDFShapeUI();
                     (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
                     break;
+                case AnnotationType.Freehand:
+                    annotationPanel = new CPDFFreehandUI();
+                    break;
+                case AnnotationType.FreeText:
+                    annotationPanel = new CPDFFreeTextUI();
+                    break;
+                case AnnotationType.Note:
+                    annotationPanel = new CPDFNoteUI();
+                    break;
                 case AnnotationType.Stamp:
                     annotationPanel = new CPDFStampUI();
                     (annotationPanel as CPDFStampUI).InitWithAnnotationType(annotationType);
@@ -266,7 +307,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
             }
             SetAnnotationPanel(annotationPanel);
             ExpandPanel();
-            ChangeAnnotationData();
+            //ChangeAnnotationData();
         }
     }
 }

+ 35 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml

@@ -0,0 +1,35 @@
+<UserControl x:Class="compdfkit_tools.PDFControlUI.CPDFFreeTextUI"
+             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.PDFControlUI"
+             xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
+             mc:Ignorable="d" 
+             d:DesignHeight="800" d:DesignWidth="300">
+    <Grid>
+        <StackPanel Orientation="Vertical">
+            <StackPanel Orientation="Vertical" Height="150">
+                <TextBlock x:Name="TitileTextBlock" HorizontalAlignment="Center"></TextBlock>
+                <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Border Color"></TextBlock>
+                <cpdfcommon:ColorPickerControl x:Name="ColorPickerControl"></cpdfcommon:ColorPickerControl>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Opacity"></TextBlock>
+                <cpdfcommon:CPDFOpacityControl x:Name="CPDFOpacityControl"></cpdfcommon:CPDFOpacityControl>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Thickness"></TextBlock>
+                <cpdfcommon:CPDFThicknessControl x:Name="CPDFThicknessControl"></cpdfcommon:CPDFThicknessControl>
+            </StackPanel>
+            <StackPanel Height="200" Margin="5">
+                <TextBlock Text="Note"></TextBlock>
+                <TextBox Height="150"  x:Name="NoteTextBox"></TextBox>
+            </StackPanel>
+        </StackPanel>
+    </Grid>
+</UserControl>
+

+ 36 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs

@@ -0,0 +1,36 @@
+using compdfkit_tools.Data;
+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.PDFControlUI
+{
+    /// <summary>
+    /// CPDFFreeTextUI.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFFreeTextUI : UserControl
+    {
+        public CPDFFreeTextUI()
+        {
+            InitializeComponent();
+        }
+
+        public CPDFFreehandData GetFreeTextData()
+        {
+            CPDFFreehandData cPDFFreehandData = new CPDFFreehandData();
+            cPDFFreehandData.AnnotationType = AnnotationType.FreeText;
+            return cPDFFreehandData;
+        }
+    }
+}

+ 34 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreehandUI.xaml

@@ -0,0 +1,34 @@
+<UserControl x:Class="compdfkit_tools.PDFControlUI.CPDFFreehandUI"
+             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.PDFControlUI"
+             xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
+             mc:Ignorable="d" 
+             d:DesignHeight="800" d:DesignWidth="300">
+    <Grid>
+        <StackPanel Orientation="Vertical">
+            <StackPanel Orientation="Vertical" Height="150">
+                <TextBlock x:Name="TitileTextBlock" Text="Freehand" HorizontalAlignment="Center"></TextBlock>
+                <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Border Color"></TextBlock>
+                <cpdfcommon:ColorPickerControl x:Name="ColorPickerControl"></cpdfcommon:ColorPickerControl>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Opacity"></TextBlock>
+                <cpdfcommon:CPDFOpacityControl x:Name="CPDFOpacityControl"></cpdfcommon:CPDFOpacityControl>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Thickness"></TextBlock>
+                <cpdfcommon:CPDFThicknessControl x:Name="CPDFThicknessControl"></cpdfcommon:CPDFThicknessControl>
+            </StackPanel>
+            <StackPanel Height="200" Margin="5">
+                <TextBlock Text="Note"></TextBlock>
+                <TextBox Height="150"  x:Name="NoteTextBox" TextChanged="NoteTextBox_TextChanged"></TextBox>
+            </StackPanel>
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 65 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreehandUI.xaml.cs

@@ -0,0 +1,65 @@
+using compdfkit_tools.Data;
+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.PDFControlUI
+{
+    /// <summary>
+    /// CPDFFreeHandUI.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFFreehandUI : UserControl
+    {
+        public event EventHandler<CPDFAnnotationData> PropertyChanged;
+
+        public CPDFFreehandUI()
+        {
+            InitializeComponent();
+            ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
+            CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged;
+            CPDFThicknessControl.ThicknessChanged += CPDFThicknessControl_ThicknessChanged;
+        }
+
+        private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetFreehandData());
+        }
+
+        private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetFreehandData());
+        }
+
+        private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetFreehandData());
+        }
+
+        private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetFreehandData());
+        }
+
+        public CPDFFreehandData GetFreehandData()
+        {
+            CPDFFreehandData pdfFreehandData = new CPDFFreehandData();
+            pdfFreehandData.AnnotationType = AnnotationType.Freehand;
+            pdfFreehandData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
+            pdfFreehandData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
+            pdfFreehandData.Thickness = CPDFThicknessControl.Thickness;
+            pdfFreehandData.Note = NoteTextBox.Text;
+            return pdfFreehandData;
+        }
+    }
+}

+ 27 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml

@@ -0,0 +1,27 @@
+<UserControl x:Class="compdfkit_tools.PDFControlUI.CPDFNoteUI"
+             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.PDFControlUI"
+             xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
+             mc:Ignorable="d" 
+             d:DesignHeight="800" d:DesignWidth="300">
+    <Grid>
+        <StackPanel Orientation="Vertical">
+            <StackPanel Orientation="Vertical" Height="150">
+                <TextBlock x:Name="TitileTextBlock" HorizontalAlignment="Center"></TextBlock>
+                <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
+            </StackPanel>
+            <StackPanel Height="75" Margin="5">
+                <TextBlock Text="Border Color"></TextBlock>
+                <cpdfcommon:ColorPickerControl x:Name="ColorPickerControl"></cpdfcommon:ColorPickerControl>
+            </StackPanel>
+            <StackPanel Height="200" Margin="5">
+                <TextBlock Text="Note"></TextBlock>
+                <TextBox Height="150"  x:Name="NoteTextBox"></TextBox>
+            </StackPanel>
+        </StackPanel>
+    </Grid>
+</UserControl>
+

+ 47 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml.cs

@@ -0,0 +1,47 @@
+using compdfkit_tools.Common;
+using compdfkit_tools.Data;
+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.PDFControlUI
+{
+    /// <summary>
+    /// CPDFNoteUI.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFNoteUI : UserControl
+    {
+        public event EventHandler<CPDFAnnotationData> PropertyChanged;
+
+        public CPDFNoteUI()
+        {
+            InitializeComponent();
+            ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
+        }
+
+        private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
+        {
+            PropertyChanged?.Invoke(this, GetNoteData());
+        }
+
+        public CPDFNoteData GetNoteData()
+        {
+            CPDFNoteData pdfNoteData = new CPDFNoteData();
+            pdfNoteData.AnnotationType = AnnotationType.Note;
+            pdfNoteData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
+            pdfNoteData.Note = NoteTextBox.Text;
+            return  pdfNoteData;
+        }
+    }
+}

+ 1 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml

@@ -10,14 +10,13 @@
              d:DesignHeight="800" d:DesignWidth="300">
     <Grid>
         <StackPanel Orientation="Vertical">
-
             <StackPanel Orientation="Vertical" Height="150">
                 <TextBlock x:Name="TitleTextBlock" HorizontalAlignment="Center"></TextBlock>
                 <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
             </StackPanel>
             <StackPanel Height="75" Margin="5">
                 <TextBlock Text="Border Color"></TextBlock>
-                <cpdfcommon:ColorPickerControl x:Name="BorderColorPickerControl"></cpdfcommon:ColorPickerControl>
+                <cpdfcommon:ColorPickerControl x:Name="BorderColorPickerControl" Brush="Green"></cpdfcommon:ColorPickerControl>
             </StackPanel>
             <StackPanel x:Name="FillColorStackPanel" Height="75" Margin="5">
                 <TextBlock Text="Fill Color"></TextBlock>

compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Line.png → compdfkit_demo_windows/compdfkit/compdfkit-tools/Asset/Resource/Annotation/Freehand.png


+ 3 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BarControl/CPDFAnnotationBarControl.xaml.cs

@@ -56,7 +56,7 @@ namespace compdfkit_tools.PDFControl
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Squiggly.png";
             }
-            else if (toggleButton.Tag.ToString() == AnnotationType.Freetext.ToString())
+            else if (toggleButton.Tag.ToString() == AnnotationType.FreeText.ToString())
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Freetext.png";
             }
@@ -80,9 +80,9 @@ namespace compdfkit_tools.PDFControl
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/StraightLine.png";
             }
-            else if (toggleButton.Tag.ToString() == AnnotationType.Line.ToString())
+            else if (toggleButton.Tag.ToString() == AnnotationType.Freehand.ToString())
             {
-                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Line.png";
+                path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Freehand.png";
             }
             else if (toggleButton.Tag.ToString() == AnnotationType.Stamp.ToString())
             {
@@ -132,7 +132,6 @@ namespace compdfkit_tools.PDFControl
 
         private void ToggleButton_Click(object sender, RoutedEventArgs e)
         {
-
             ClearToolState(sender as ToggleButton);
             if((bool)(sender as ToggleButton).IsChecked)
             {

+ 4 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml

@@ -4,6 +4,7 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              mc:Ignorable="d" 
+             xmlns:local="clr-namespace:compdfkit_tools.Common" 
              d:DesignHeight="40" d:DesignWidth="220">
     <UserControl.Resources>
         <Style x:Key="CommonColorRadioButton" TargetType="{x:Type RadioButton}">
@@ -74,7 +75,6 @@
                                     </Rectangle.Fill>
                                 </Rectangle>
                             </Grid>
-
                         </Grid>
                         <ControlTemplate.Triggers>
                             <Trigger Property="IsMouseOver" Value="True">
@@ -96,11 +96,12 @@
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition Width="2*"></ColumnDefinition>
+
         </Grid.ColumnDefinitions>
-        <RadioButton Background="#FF0000" Style="{StaticResource CommonColorRadioButton}" Tag="Red" Click="ColorRadioButton_Click"></RadioButton>
+        <RadioButton Background="#FF0000" Style="{StaticResource CommonColorRadioButton}" Tag="Red" Click="ColorRadioButton_Click" Visibility="Visible"></RadioButton>
         <RadioButton Background="#000000" Grid.Column="1" Style="{StaticResource CommonColorRadioButton}" Tag="Black" Click="ColorRadioButton_Click"></RadioButton>
         <RadioButton Background="#00FF00" Grid.Column="2" Style="{StaticResource CommonColorRadioButton}" Tag="Green"  Click="ColorRadioButton_Click"></RadioButton>
         <RadioButton Background="#0000FF" Grid.Column="3" Style="{StaticResource CommonColorRadioButton}" Tag="Blue" Click="ColorRadioButton_Click"></RadioButton>
-        <RadioButton x:Name="CustomColorRadioButton" Background="{Binding Brush}" Grid.Column="4" Style="{StaticResource CustomColorRadioButton}" GroupName="Color" Click="CustomColorRadioButton_Click"></RadioButton>
+        <RadioButton x:Name="CustomColorRadioButton" Background="{Binding Brush, RelativeSource={RelativeSource AncestorType={x:Type local:ColorPickerControl}}}" Grid.Column="4" Style="{StaticResource CustomColorRadioButton}" GroupName="Color" Click="CustomColorRadioButton_Click"></RadioButton>
     </Grid>
 </UserControl>

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

@@ -22,21 +22,29 @@ namespace compdfkit_tools.Common
     /// <summary>
     /// ColorSelectorControl.xaml 的交互逻辑
     /// </summary>
-    public partial class ColorPickerControl : UserControl, INotifyPropertyChanged
+    public partial class ColorPickerControl : UserControl
     {
         public event PropertyChangedEventHandler PropertyChanged;
         public event EventHandler ColorChanged;
 
-        private Brush _brush = Brushes.Red;
+        /// <summary>
+        /// 设置允许为空
+        /// </summary>
+        public static readonly DependencyProperty CanNoneProperty = DependencyProperty.Register("CanNone", typeof(bool), typeof(ColorPickerControl), new PropertyMetadata(false));
+        public bool CanNone
+        {
+            get { return (bool)GetValue(CanNoneProperty); }
+            set { SetValue(CanNoneProperty, value); }
+        }
+
+        /// <summary>
+        /// 设置颜色
+        /// </summary>
+        public static readonly DependencyProperty BrushProperty = DependencyProperty.Register("Brush", typeof(Brush), typeof(ColorPickerControl), new PropertyMetadata(Brushes.Red));
         public Brush Brush
         {
-            get => _brush;
-            set
-            {
-                _brush = value;
-                OnPropertyChanged(nameof(Brush));
-                OnColorChanged();
-            }
+            get { return (Brush)GetValue(BrushProperty); }
+            set { SetValue(BrushProperty, value); OnColorChanged(); }
         }
 
         public ColorPickerControl()
@@ -66,16 +74,15 @@ namespace compdfkit_tools.Common
             ColorChanged?.Invoke(this, null);
         }
 
-        private void OnPropertyChanged(string propertyName)
-        {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
-        }
-
         private void ColorRadioButton_Click(object sender, RoutedEventArgs e)
         {
             var radioButton = sender as RadioButton;
             if (radioButton != null)
             {
+                if (radioButton.Tag.ToString() == "None")
+                {
+                    Brush = Brushes.Transparent;
+                }
                 if (radioButton.Tag.ToString() == "Red")
                 {
                     Brush = Brushes.Red;

+ 17 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFTextStyle/CPDFTextStyleUI.xaml

@@ -0,0 +1,17 @@
+<UserControl x:Class="compdfkit_tools.Common.CPDFTextStyleUI"
+             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="80" d:DesignWidth="300">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <ComboBox></ComboBox>
+    </Grid>
+</UserControl>

+ 28 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFTextStyle/CPDFTextStyleUI.xaml.cs

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

+ 29 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -65,6 +65,15 @@
     <Reference Include="PresentationFramework" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFFreehandUI.xaml.cs">
+      <DependentUpon>CPDFFreehandUI.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFFreeTextUI.xaml.cs">
+      <DependentUpon>CPDFFreeTextUI.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFNoteUI.xaml.cs">
+      <DependentUpon>CPDFNoteUI.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Common\PropertyControl\PDFArrow\CPDFArrowControl.xaml.cs">
       <DependentUpon>CPDFArrowControl.xaml</DependentUpon>
     </Compile>
@@ -122,6 +131,9 @@
     <Compile Include="Common\BaseControl\DropDownNumberBoxControl.xaml.cs">
       <DependentUpon>DropDownNumberBoxControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\PropertyControl\PDFTextStyle\CPDFTextStyleUI.xaml.cs">
+      <DependentUpon>CPDFTextStyleUI.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Common\PropertyControl\PDFThickness\CPDFThicknessControl.xaml.cs">
       <DependentUpon>CPDFThicknessControl.xaml</DependentUpon>
     </Compile>
@@ -257,6 +269,18 @@
     <Resource Include="Asset\Resource\Annotation\Rect.png" />
   </ItemGroup>
   <ItemGroup>
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFFreehandUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFFreeTextUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFNoteUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Common\PropertyControl\PDFArrow\CPDFArrowControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -333,6 +357,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Common\PropertyControl\PDFTextStyle\CPDFTextStyleUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Common\PropertyControl\PDFThickness\CPDFThicknessControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -508,7 +536,7 @@
     <Resource Include="Asset\Resource\Annotation\Signature.png" />
   </ItemGroup>
   <ItemGroup>
-    <Resource Include="Asset\Resource\Annotation\Line.png" />
+    <Resource Include="Asset\Resource\Annotation\Freehand.png" />
   </ItemGroup>
   <ItemGroup>
     <Resource Include="Asset\Resource\Annotation\Link.png" />