Browse Source

Merge branch 'compdfkit_demo_windows' of http://git.kdan.cc:8865/Others/kmpdfkit_demo into compdfkit_demo_windows

# Conflicts:
#	compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml
zhuyi 1 year ago
parent
commit
fa8f388765
35 changed files with 2310 additions and 413 deletions
  1. 1 0
      .gitignore
  2. 1 0
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml
  3. 0 1
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs
  4. 3 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/CPDFAnnotationPreviewerControl.xaml
  5. 17 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/CPDFAnnotationPreviewerControl.xaml.cs
  6. 1 8
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs
  7. 8 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs
  8. 3 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml
  9. 52 5
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs
  10. 0 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml.cs
  11. 3 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml
  12. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs
  13. 24 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFTempStampUI.xaml
  14. 51 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFTempStampUI.xaml.cs
  15. 7 7
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/DropDownNumberBoxControl.xaml
  16. 5 5
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml
  17. 616 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Helper/CommonHelper.cs
  18. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml
  19. 14 12
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml.cs
  20. 152 11
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml
  21. 35 32
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs
  22. 13 14
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml
  23. 18 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml.cs
  24. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpactiyUI.xaml
  25. 9 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFThickness/CPDThicknessUI.xaml
  26. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml
  27. 2 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextAlignUI.xaml
  28. 7 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj
  29. 409 72
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml
  30. 483 86
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml.cs
  31. 61 0
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/PasswordDialog.xaml
  32. 64 0
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/PasswordDialog.xaml.cs
  33. 7 0
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/edit-ctrl-demo.csproj
  34. 128 136
      compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml
  35. 112 0
      compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml.cs

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 compdfkit_demo_windows/compdfkit/.vs/
 compdfkit_demo_windows/compdfkit/*/obj/
 compdfkit_demo_windows/compdfkit/*/bin/
+compdfkit_demo_windows/compdfkit/*.htm
 .vs/

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

@@ -227,6 +227,7 @@
                     <RowDefinition Height="*"/>
                 </Grid.RowDefinitions>
                 <!--工具栏展开-->
+                
                 <Grid Grid.RowSpan="2" Name="ExpandToolContainer" Visibility="Collapsed">
                     <Grid.RowDefinitions>
                         <RowDefinition Height="auto"></RowDefinition>

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

@@ -304,7 +304,6 @@ namespace viewer_ctrl_demo
             }
             ExpandBotaTool(OutlineToolButton.IsChecked == true);
             ClearToolState(OutlineToolButton);
-
         }
         /// <summary>
         /// 设置Bota工具内容

+ 3 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/CPDFAnnotationPreviewerControl.xaml

@@ -55,9 +55,6 @@
                 <Rectangle x:Name="Rectangle" Width="100" Height="50" Stroke="Red" StrokeThickness="2" Fill="Transparent" Visibility="Collapsed"/>
                 <Ellipse x:Name="Ellipse" Width="70" Height="70" Stroke="Red" StrokeThickness="2" Fill="Transparent" StrokeDashArray="" Visibility="Collapsed"/>
                 <Path x:Name="Line" Stroke="Black" StrokeThickness="2" Width="70" Height="70" Visibility="Collapsed">
-                    <Path.Data>
-                        <LineGeometry StartPoint="10,60" EndPoint="60,10"/>
-                    </Path.Data>
                 </Path>
             </Grid>
             <Grid x:Name="NoteGrid"  Visibility="Collapsed">
@@ -67,6 +64,9 @@
                     </Path.Data>
                 </Path>
             </Grid>
+            <Grid x:Name="StampGrid" Visibility="Collapsed">
+                <Image Margin="10" x:Name="StampImage"></Image>
+            </Grid>
         </Grid>
     </Border>
 </UserControl>

+ 17 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/CPDFAnnotationPreviewerControl.xaml.cs

@@ -16,6 +16,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using static compdfkit_tools.Helper.CommonHelper;
 
 namespace compdfkit_tools.PDFControl
 {
@@ -43,6 +44,7 @@ namespace compdfkit_tools.PDFControl
             Rectangle.Visibility = Visibility.Collapsed;
             Line.Visibility = Visibility.Collapsed;
             NoteGrid.Visibility = Visibility.Collapsed;
+            StampGrid.Visibility = Visibility.Collapsed;
         }
 
         public void DrawMarkUpPreview(CPDFAnnotationData annotationData)
@@ -120,12 +122,17 @@ namespace compdfkit_tools.PDFControl
                     CPDFLineShapeData lineShapeData = annotationData as CPDFLineShapeData;
                     ShapeGrid.Visibility = Visibility.Visible;
                     Line.Visibility = Visibility.Visible;
-
+                    ArrowHelper arrowLine = new ArrowHelper();
+                    arrowLine.ArrowLength = 8;
+                    arrowLine.LineStart = new Point(20, 50);
+                    arrowLine.LineEnd = new Point(50, 20);
+                    arrowLine.StartSharp = lineShapeData.LineType.HeadLineType;
+                    arrowLine.EndSharp = lineShapeData.LineType.TailLineType;
                     Line.Stroke = new SolidColorBrush(lineShapeData.BorderColor);
                     Line.StrokeThickness = lineShapeData.Thickness;
                     Line.Opacity = lineShapeData.Opacity;
-
-
+                    Line.Data = arrowLine.BuildArrowBody();
+                    Line.StrokeDashArray = lineShapeData.DashStyle.Dashes;
                     break;
             }
         }
@@ -149,6 +156,13 @@ namespace compdfkit_tools.PDFControl
             NotePath.Fill = new SolidColorBrush(noteData.BorderColor);
         }
 
+        public void DrawStampPreview(WriteableBitmap writeableBitmap)
+        {
+            CollapsedAll();
+            StampGrid.Visibility = Visibility.Visible;
+            StampImage.Source = writeableBitmap;
+        }
+
         public void InitWithAnnotationData(CPDFAnnotationData annotationData)
         {
             CollapsedAll();

+ 1 - 8
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -164,14 +164,7 @@ namespace compdfkit_tools.Data
     {
         public Color BorderColor = Color.FromRgb(255, 0, 0);
         public double Opacity = 1;
-        public CPDFFontData Font = new CPDFFontData()
-        {
-            FontFamily = "Helvetica",
-            FontSize = 12,
-            IsBold = false,
-            IsItalic = false,
-            TextAlignment = TextAlignment.Left
-        };
+        public CPDFFontData Font = new CPDFFontData();
     }
 
     public class CPDFNoteData : CPDFAnnotationData

+ 8 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -289,7 +289,7 @@ namespace compdfkit_tools.PDFControl
                     CPDFFreeTextData freeTextData = pdfAnnotationData as CPDFFreeTextData;
                     annotHandlerEventArgs = new FreeTextAnnotArgs();
                     (annotHandlerEventArgs as FreeTextAnnotArgs).Transparency = freeTextData.Opacity;
-                    (annotHandlerEventArgs as FreeTextAnnotArgs).FontName = freeTextData.Font.FontFamily;
+                    (annotHandlerEventArgs as FreeTextAnnotArgs).FontName = freeTextData.Font.FontFamily.ToString();
                     (annotHandlerEventArgs as FreeTextAnnotArgs).FontColor = freeTextData.BorderColor;
                     (annotHandlerEventArgs as FreeTextAnnotArgs).IsBold = freeTextData.Font.IsBold;
                     (annotHandlerEventArgs as FreeTextAnnotArgs).IsItalic = freeTextData.Font.IsItalic;
@@ -586,16 +586,22 @@ namespace compdfkit_tools.PDFControl
                     tempAnnotationPanel = new CPDFFreehandUI();
                     (tempAnnotationPanel as CPDFFreehandUI).SetPresentAnnotAttrib(annotAttribEvent);
                     break;
+
                 case AnnotArgsType.AnnotFreeText:
                     tempAnnotationPanel = new CPDFFreeTextUI();
+                    (tempAnnotationPanel as CPDFFreeTextUI).SetPresentAnnotAttrib(annotAttribEvent);
                     break;
+                
                 case AnnotArgsType.AnnotSticky:
                     tempAnnotationPanel = new CPDFNoteUI();
                     (tempAnnotationPanel as CPDFNoteUI).SetPresentAnnotAttrib(annotAttribEvent);
                     break;
+                
                 case AnnotArgsType.AnnotStamp:
-                    tempAnnotationPanel = new CPDFStampUI();
+                    tempAnnotationPanel = new CPDFTempStampUI();
+                    (tempAnnotationPanel as CPDFTempStampUI).SetPresentAnnotAttrib(annotAttribEvent);
                     break;
+                
                 default:
                     break;
             }

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

@@ -22,13 +22,13 @@
                 <TextBlock Text="Opacity"></TextBlock>
                 <cpdfcommon:CPDFOpacityControl x:Name="CPDFOpacityControl"></cpdfcommon:CPDFOpacityControl>
             </StackPanel>
-            <StackPanel Height="100" Margin="5">
+            <StackPanel Height="120" Margin="5">
                 <TextBlock Text="Font Style"></TextBlock>
-                <cpdfcommon:CPDFFontControl x:Name="CPDFFontControl"></cpdfcommon:CPDFFontControl>
+                <cpdfcommon:CPDFFontControl x:Name="CPDFFontControl" Width="228"></cpdfcommon:CPDFFontControl>
             </StackPanel>
             <StackPanel Height="200" Margin="5">
                 <TextBlock Text="Note"></TextBlock>
-                <TextBox Height="150"  x:Name="NoteTextBox"></TextBox>
+                <TextBox Height="150"  x:Name="NoteTextBox" TextChanged="NoteTextBox_TextChanged"></TextBox>
             </StackPanel>
         </StackPanel>
     </Grid>

+ 52 - 5
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs

@@ -38,28 +38,75 @@ namespace compdfkit_tools.PDFControlUI
 
         private void CPDFFontControl_FontChanged(object sender, EventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetFreeTextData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetFreeTextData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.FontName, CPDFFontControl.CPDFFontData.FontFamily);
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.FontSize, CPDFFontControl.CPDFFontData.FontSize);
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.TextAlign, CPDFFontControl.CPDFFontData.TextAlignment);
+            }
         }
 
 
         private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetFreeTextData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetFreeTextData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100.0);
+                annotAttribEvent.UpdateAnnot();
+            }
         }
 
         private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetFreeTextData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetFreeTextData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.FontColor, ((SolidColorBrush)ColorPickerControl.Brush).Color);
+                annotAttribEvent.UpdateAnnot();
+            }
+        }
+
+        private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetFreeTextData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
+                annotAttribEvent.UpdateAnnot();
+            }
         }
 
         public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
         {
             this.annotAttribEvent = null;
-            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.FontColor]);
             CPDFOpacityControl.OpacityValue = (int)((double)annotAttribEvent.Attribs[AnnotAttrib.Transparency] * 100);
+            CPDFFontData pdfFontData = new CPDFFontData();
+
+            pdfFontData.FontFamily = (string)annotAttribEvent.Attribs[AnnotAttrib.FontName];
+            pdfFontData.FontSize = Convert.ToInt16(annotAttribEvent.Attribs[AnnotAttrib.FontSize]);
+            pdfFontData.IsItalic = (bool)annotAttribEvent.Attribs[AnnotAttrib.IsItalic];
+            pdfFontData.IsBold = (bool)annotAttribEvent.Attribs[AnnotAttrib.IsBold];
+            pdfFontData.TextAlignment = (TextAlignment)annotAttribEvent.Attribs[AnnotAttrib.TextAlign];
+
+            CPDFFontControl.CPDFFontData = pdfFontData;
+
             NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
             this.annotAttribEvent = annotAttribEvent;
-
         }
 
         public CPDFFreeTextData GetFreeTextData()

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

@@ -77,7 +77,5 @@ namespace compdfkit_tools.PDFControlUI
             pdfNoteData.Note = NoteTextBox.Text;
             return  pdfNoteData;
         }
-
-
     }
 }

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

@@ -30,7 +30,7 @@
                 <TextBlock Text="Thickness"></TextBlock>
                 <cpdfcommon:CPDFThicknessControl x:Name="CPDFThicknessControl"></cpdfcommon:CPDFThicknessControl>
             </StackPanel>
-            <StackPanel x:Name="LineStyleStackPanel" Height="75" Margin="5">
+            <StackPanel x:Name="LineStyleStackPanel" Height="80" Margin="5">
                 <TextBlock Text="Line Style"></TextBlock>
                 <cpdfcommon:CPDFLineStyleControl x:Name="CPDFLineStyleControl"></cpdfcommon:CPDFLineStyleControl>
             </StackPanel>
@@ -38,9 +38,9 @@
                 <TextBlock Text="Start and End"></TextBlock>
                 <cpdfcommon:CPDFArrowControl x:Name="CPDFArrowControl"></cpdfcommon:CPDFArrowControl>
             </StackPanel>
-            <StackPanel Height="200" Margin="5">
+            <StackPanel Height="160" Margin="5">
                 <TextBlock Text="Note"></TextBlock>
-                <TextBox Height="150"  x:Name="NoteTextBox"  TextChanged="NoteTextBox_TextChanged"></TextBox>
+                <TextBox Height="100"  x:Name="NoteTextBox"  TextChanged="NoteTextBox_TextChanged"></TextBox>
             </StackPanel>
         </StackPanel>
     </Grid>

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

@@ -190,7 +190,7 @@ namespace compdfkit_tools.PDFControlUI
                 LineType lineType = new LineType()
                 {
                     HeadLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineStart],
-                    TailLineType = (C_LINE_TYPE)(C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineEnd]
+                    TailLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineEnd]
                 };
 
                 CPDFArrowControl.LineType = lineType;

+ 24 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFTempStampUI.xaml

@@ -0,0 +1,24 @@
+<UserControl x:Class="compdfkit_tools.PDFControlUI.CPDFTempStampUI"
+             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:cpdftools="clr-namespace:compdfkit_tools.PDFControl"
+             xmlns:local="clr-namespace:compdfkit_tools.PDFControlUI"
+             mc:Ignorable="d" 
+             d:DesignHeight="800" d:DesignWidth="300">
+    <Grid>
+        <StackPanel Orientation="Vertical">
+            <StackPanel Orientation="Vertical" Height="150">
+                <TextBlock x:Name="TitileTextBlock" Text="Stamp" HorizontalAlignment="Center"></TextBlock>
+                <cpdftools:CPDFAnnotationPreviewerControl x:Name="CPDFAnnotationPreviewerControl" Height="100" Margin="16">
+                </cpdftools:CPDFAnnotationPreviewerControl>
+            </StackPanel>
+            
+            <StackPanel Height="200" Margin="5">
+                <TextBlock Text="Note"></TextBlock>
+                <TextBox Height="150"  x:Name="NoteTextBox" TextChanged="NoteTextBox_TextChanged"></TextBox>
+            </StackPanel>
+        </StackPanel>   
+    </Grid>
+</UserControl>

+ 51 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFTempStampUI.xaml.cs

@@ -0,0 +1,51 @@
+using compdfkit_tools.Common;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer;
+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>
+    /// CPDFImageUI.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFTempStampUI : UserControl
+    {
+        private AnnotAttribEvent annotAttribEvent;
+
+        public CPDFTempStampUI()
+        {
+            InitializeComponent();
+        }
+
+        public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
+        {
+            this.annotAttribEvent = null;
+            NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
+            this.annotAttribEvent = annotAttribEvent;
+            WriteableBitmap writeableBitmap = (annotAttribEvent.GetAnnotHandlerEventArgs(AnnotArgsType.AnnotStamp)[0] as StampAnnotArgs).GetStampDrawing();
+            CPDFAnnotationPreviewerControl.DrawStampPreview(writeableBitmap);
+        }
+
+        private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if(annotAttribEvent != null)
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
+                annotAttribEvent.UpdateAnnot();
+            }
+        }
+    }
+}

File diff suppressed because it is too large
+ 7 - 7
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/DropDownNumberBoxControl.xaml


File diff suppressed because it is too large
+ 5 - 5
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml


+ 616 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/Helper/CommonHelper.cs

@@ -1,10 +1,12 @@
-using Microsoft.Win32;
+using ComPDFKit.PDFAnnotation;
+using Microsoft.Win32;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Media;
 
 namespace compdfkit_tools.Helper
@@ -73,5 +75,618 @@ namespace compdfkit_tools.Helper
             }
             return selectedFilePath;
         }
+
+        public class ArrowHelper
+        {
+            /// <summary>
+            /// 是否有开始箭头
+            /// </summary>
+            public bool HasStartArrow
+            {
+                get
+                {
+                    if (StartSharp != C_LINE_TYPE.LINETYPE_UNKNOWN && StartSharp != C_LINE_TYPE.LINETYPE_NONE)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            /// <summary>
+            /// 开始箭头是否封闭
+            /// </summary>
+            public bool IsStartClosed
+            {
+                get
+                {
+                    if (StartSharp == C_LINE_TYPE.LINETYPE_CLOSEDARROW || StartSharp == C_LINE_TYPE.LINETYPE_RCLOSEDARROW || StartSharp == C_LINE_TYPE.LINETYPE_DIAMOND)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            /// <summary>
+            /// 是否有结束箭头
+            /// </summary>
+            public bool HasEndArrow
+            {
+                get
+                {
+                    if (EndSharp != C_LINE_TYPE.LINETYPE_UNKNOWN && EndSharp != C_LINE_TYPE.LINETYPE_NONE)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            /// <summary>
+            /// 结束箭头是否封闭
+            /// </summary>
+            public bool IsEndClosed
+            {
+                get
+                {
+                    if (EndSharp == C_LINE_TYPE.LINETYPE_CLOSEDARROW || EndSharp == C_LINE_TYPE.LINETYPE_RCLOSEDARROW || EndSharp == C_LINE_TYPE.LINETYPE_DIAMOND)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+            }
+            /// <summary>
+            /// 箭头角度
+            /// </summary>
+            public uint ArrowAngle { get; set; }
+            /// <summary>
+            /// 箭头长度
+            /// </summary>
+            public uint ArrowLength { get; set; }
+            /// <summary>
+            /// 起始点
+            /// </summary>
+            public Point? LineStart { get; set; }
+            /// <summary>
+            /// 结束点
+            /// </summary>
+            public Point? LineEnd { get; set; }
+            /// <summary>
+            /// 线段路径
+            /// </summary>
+            public PathGeometry Body { get; set; }
+            /// <summary>
+            /// 开始箭头形状
+            /// </summary>
+            public C_LINE_TYPE StartSharp { get; set; }
+            /// <summary>
+            /// 结束箭头形状
+            /// </summary>
+            public C_LINE_TYPE EndSharp { get; set; }
+            /// <summary>
+            /// 箭头帮助类
+            /// </summary>
+            public ArrowHelper()
+            {
+                Body = new PathGeometry();
+                ArrowLength = 12;
+                ArrowAngle = 60;
+            }
+            protected PathFigure CreateLineBody()
+            {
+                if (LineStart != null && LineEnd != null)
+                {
+                    PathFigure lineFigure = new PathFigure();
+                    // lineFigure.IsClosed = true;
+                    lineFigure.StartPoint = (Point)LineStart;
+                    LineSegment linePath = new LineSegment();
+                    linePath.Point = (Point)LineEnd;
+                    //linePath.IsSmoothJoin = true;
+                    //linePath.IsStroked = true;
+                    lineFigure.Segments.Add(linePath);
+                    return lineFigure;
+                }
+                return null;
+            }
+            protected PathFigure CreateStartArrow()
+            {
+                switch (StartSharp)
+                {
+                    case C_LINE_TYPE.LINETYPE_NONE:
+                    case C_LINE_TYPE.LINETYPE_UNKNOWN:
+                        break;
+                    case C_LINE_TYPE.LINETYPE_ARROW:
+                    case C_LINE_TYPE.LINETYPE_CLOSEDARROW:
+                        return CreateStartOpenArrow();
+                    case C_LINE_TYPE.LINETYPE_ROPENARROW:
+                    case C_LINE_TYPE.LINETYPE_RCLOSEDARROW:
+                        return CreateStartReverseArrow();
+                    case C_LINE_TYPE.LINETYPE_BUTT:
+                        return CreateStartButtArrow();
+                    case C_LINE_TYPE.LINETYPE_DIAMOND:
+                        return CreateStartDiamondArrow();
+                    case C_LINE_TYPE.LINETYPE_CIRCLE:
+                        return CreateStartRoundArrow();
+                    case C_LINE_TYPE.LINETYPE_SQUARE:
+                        return CreateStartSquareArrow();
+                    case C_LINE_TYPE.LINETYPE_SLASH:
+                        return CreateStartSlashArrow();
+                    default:
+                        break;
+                }
+                return null;
+            }
+            protected virtual PathFigure CreateEndArrow()
+            {
+                switch (EndSharp)
+                {
+                    case C_LINE_TYPE.LINETYPE_NONE:
+                    case C_LINE_TYPE.LINETYPE_UNKNOWN:
+                        break;
+                    case C_LINE_TYPE.LINETYPE_ARROW:
+                    case C_LINE_TYPE.LINETYPE_CLOSEDARROW:
+                        return CreateEndOpenArrow();
+                    case C_LINE_TYPE.LINETYPE_ROPENARROW:
+                    case C_LINE_TYPE.LINETYPE_RCLOSEDARROW:
+                        return CreateEndReverseArrow();
+                    case C_LINE_TYPE.LINETYPE_BUTT:
+                        return CreateEndButtArrow();
+                    case C_LINE_TYPE.LINETYPE_DIAMOND:
+                        return CreateEndDiamondArrow();
+                    case C_LINE_TYPE.LINETYPE_CIRCLE:
+                        return CreateEndRoundArrow();
+                    case C_LINE_TYPE.LINETYPE_SQUARE:
+                        return CreateEndSquareArrow();
+                    case C_LINE_TYPE.LINETYPE_SLASH:
+                        return CreateEndSlashArrow();
+                    default:
+                        break;
+                }
+                return null;
+            }
+            /// <summary>
+            /// 创建箭头路径
+            /// </summary>
+            /// <returns></returns>
+            public PathGeometry BuildArrowBody()
+            {
+                Body.Figures.Clear();
+                PathFigure lineBody = CreateLineBody();
+                if (lineBody != null)
+                {
+                    Body.Figures.Add(lineBody);
+                    PathFigure arrowFigure = CreateStartArrow();
+                    if (arrowFigure != null)
+                    {
+                        Body.Figures.Add(arrowFigure);
+                    }
+                    arrowFigure = CreateEndArrow();
+                    if (arrowFigure != null)
+                    {
+                        Body.Figures.Add(arrowFigure);
+                    }
+                }
+                return Body;
+            }
+
+            /// <summary>
+            /// 绘制开始箭头
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartOpenArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null || ArrowAngle == 0)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(ArrowAngle / 2);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                arrowSegment.Points.Add((Point)LineStart);
+                rotateMatrix.Rotate(-ArrowAngle);
+                arrowSegment.Points.Add((Point)LineStart + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsStartClosed;
+                arrowFigure.IsFilled = IsStartClosed;
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束箭头
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndOpenArrow()
+            {
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null || ArrowAngle == 0)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(ArrowAngle / 2);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                arrowSegment.Points.Add((Point)LineEnd);
+                rotateMatrix.Rotate(-ArrowAngle);
+                arrowSegment.Points.Add((Point)LineEnd + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsEndClosed;
+                arrowFigure.IsFilled = IsEndClosed;
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制开始箭头(逆向)
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartReverseArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null || ArrowAngle == 0)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(ArrowAngle / 2);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                arrowSegment.Points.Add((Point)LineStart);
+                rotateMatrix.Rotate(-ArrowAngle);
+                arrowSegment.Points.Add((Point)LineStart + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsStartClosed;
+                arrowFigure.IsFilled = IsStartClosed;
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束箭头(逆向)
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndReverseArrow()
+            {
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null || ArrowAngle == 0)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(ArrowAngle / 2);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                arrowSegment.Points.Add((Point)LineEnd);
+                rotateMatrix.Rotate(-ArrowAngle);
+                arrowSegment.Points.Add((Point)LineEnd + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsEndClosed;
+                arrowFigure.IsFilled = IsEndClosed;
+                return arrowFigure;
+            }
+
+            /// <summary>
+            /// 绘制开始平头
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartButtArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                LineSegment buttSegment = new LineSegment();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                buttSegment.Point = ((Point)LineStart + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(buttSegment);
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束平头
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndButtArrow()
+            {
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                LineSegment buttSegment = new LineSegment();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                buttSegment.Point = ((Point)LineEnd + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(buttSegment);
+
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制开始菱形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartDiamondArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(45);
+
+                Point cornerTop = (Point)LineStart + (lineVector * rotateMatrix);
+
+                Vector turnVector = cornerTop - (Point)LineStart;
+                turnVector.Normalize();
+                turnVector *= ArrowLength;
+                Matrix turnMatrix = new Matrix();
+                turnMatrix.Rotate(-90);
+                Point awayPoint = cornerTop + (turnVector * turnMatrix);
+
+                rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(-45);
+                Point cornerDown = (Point)LineStart + (lineVector * rotateMatrix);
+
+                arrowFigure.StartPoint = (Point)LineStart;
+                arrowSegment.Points.Add(cornerTop);
+                arrowSegment.Points.Add(awayPoint);
+                arrowSegment.Points.Add(cornerDown);
+                arrowSegment.Points.Add((Point)LineStart);
+
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsStartClosed;
+                arrowFigure.IsFilled = IsStartClosed;
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束菱形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndDiamondArrow()
+            {
+
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment arrowSegment = new PolyLineSegment();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(45);
+
+                Point cornerTop = (Point)LineEnd + (lineVector * rotateMatrix);
+
+                Vector turnVector = cornerTop - (Point)LineEnd;
+                turnVector.Normalize();
+                turnVector *= ArrowLength;
+                Matrix turnMatrix = new Matrix();
+                turnMatrix.Rotate(-90);
+                Point awayPoint = cornerTop + (turnVector * turnMatrix);
+
+                rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(-45);
+                Point cornerDown = (Point)LineEnd + (lineVector * rotateMatrix);
+
+                arrowFigure.StartPoint = (Point)LineEnd;
+                arrowSegment.Points.Add(cornerTop);
+                arrowSegment.Points.Add(awayPoint);
+                arrowSegment.Points.Add(cornerDown);
+                arrowSegment.Points.Add((Point)LineEnd);
+
+                arrowFigure.Segments.Add(arrowSegment);
+                arrowFigure.IsClosed = IsEndClosed;
+                arrowFigure.IsFilled = IsEndClosed;
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制开始圆形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartRoundArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(180);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                ArcSegment circleSegment = new ArcSegment();
+                circleSegment.Point = (Point)LineStart;
+                circleSegment.Size = new Size(ArrowLength / 2, ArrowLength / 2);
+                arrowFigure.Segments.Add(circleSegment);
+                circleSegment = new ArcSegment();
+                circleSegment.Point = (Point)arrowFigure.StartPoint;
+                circleSegment.Size = new Size(ArrowLength / 2, ArrowLength / 2);
+
+                arrowFigure.Segments.Add(circleSegment);
+
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束圆形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndRoundArrow()
+            {
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(180);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                ArcSegment circleSegment = new ArcSegment();
+                circleSegment.Point = (Point)LineEnd;
+                circleSegment.Size = new Size(ArrowLength / 2, ArrowLength / 2);
+                arrowFigure.Segments.Add(circleSegment);
+                circleSegment = new ArcSegment();
+                circleSegment.Point = (Point)arrowFigure.StartPoint;
+                circleSegment.Size = new Size(ArrowLength / 2, ArrowLength / 2);
+
+                arrowFigure.Segments.Add(circleSegment);
+
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制开始方形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartSquareArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment squreSegment = new PolyLineSegment();
+
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= (ArrowLength / 2);
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                Point pointCorner = (Point)LineStart + (lineVector * rotateMatrix);
+                squreSegment.Points.Add(pointCorner);
+
+                Vector moveVector = arrowFigure.StartPoint - pointCorner;
+                moveVector.Normalize();
+                moveVector *= (ArrowLength);
+                rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+
+                squreSegment.Points.Add(pointCorner + (moveVector * rotateMatrix));
+                squreSegment.Points.Add(arrowFigure.StartPoint + (moveVector * rotateMatrix));
+                squreSegment.Points.Add(arrowFigure.StartPoint);
+                squreSegment.Points.Add((Point)LineStart);
+                arrowFigure.Segments.Add(squreSegment);
+
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束方形
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndSquareArrow()
+            {
+
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                PolyLineSegment squreSegment = new PolyLineSegment();
+
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= (ArrowLength / 2);
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                Point pointCorner = (Point)LineEnd + (lineVector * rotateMatrix);
+                squreSegment.Points.Add(pointCorner);
+
+                Vector moveVector = arrowFigure.StartPoint - pointCorner;
+                moveVector.Normalize();
+                moveVector *= (ArrowLength);
+                rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(90);
+
+                squreSegment.Points.Add(pointCorner + (moveVector * rotateMatrix));
+                squreSegment.Points.Add(arrowFigure.StartPoint + (moveVector * rotateMatrix));
+                squreSegment.Points.Add(arrowFigure.StartPoint);
+                squreSegment.Points.Add((Point)LineEnd);
+                arrowFigure.Segments.Add(squreSegment);
+
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制开始斜线
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateStartSlashArrow()
+            {
+                if (ArrowLength == 0 || !HasStartArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                LineSegment buttSegment = new LineSegment();
+                Vector lineVector = (Point)LineStart - (Point)LineEnd;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(45);
+                arrowFigure.StartPoint = (Point)LineStart + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                buttSegment.Point = ((Point)LineStart + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(buttSegment);
+                return arrowFigure;
+            }
+            /// <summary>
+            /// 绘制结束斜线
+            /// </summary>
+            /// <returns></returns>
+            private PathFigure CreateEndSlashArrow()
+            {
+                if (ArrowLength == 0 || !HasEndArrow || LineStart == null || LineEnd == null)
+                {
+                    return null;
+                }
+                PathFigure arrowFigure = new PathFigure();
+                LineSegment buttSegment = new LineSegment();
+                Vector lineVector = (Point)LineEnd - (Point)LineStart;
+                lineVector.Normalize();
+                lineVector *= ArrowLength;
+                Matrix rotateMatrix = new Matrix();
+                rotateMatrix.Rotate(45);
+                arrowFigure.StartPoint = (Point)LineEnd + (lineVector * rotateMatrix);
+                rotateMatrix.Rotate(-180);
+                buttSegment.Point = ((Point)LineEnd + (lineVector * rotateMatrix));
+                arrowFigure.Segments.Add(buttSegment);
+
+                return arrowFigure;
+            }
+        }
     }
 }

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml

@@ -5,7 +5,7 @@
              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">
+             d:DesignHeight="80" d:DesignWidth="228">
     <Grid>
         <local:CPDFFontUI x:Name="CPDFFontUI"></local:CPDFFontUI>
     </Grid>

+ 14 - 12
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml.cs

@@ -21,11 +21,15 @@ namespace compdfkit_tools.Common
     /// </summary>
     public partial class CPDFFontControl : UserControl
     {
+        private CPDFFontData _pdfFontData = new CPDFFontData();
         public CPDFFontData CPDFFontData
         {
-            get;
-           private set;
-        } = new CPDFFontData();
+            get => _pdfFontData;
+            set
+            {
+                _pdfFontData = value;
+            }
+        }
 
         public event EventHandler FontChanged;
         public CPDFFontControl()
@@ -36,15 +40,13 @@ namespace compdfkit_tools.Common
 
         private void CPDFFontUI_FontChanged(object sender, EventArgs e)
         {
-            FontChanged?.Invoke(this, EventArgs.Empty);
-            CPDFFontData = new CPDFFontData()
-            {
-                FontFamily = CPDFFontUI.FontFamilyValue,
-                FontSize = CPDFFontUI.FontSizeValue,
-                IsBold = CPDFFontUI.IsBold,
-                IsItalic = CPDFFontUI.IsItalic,
-                TextAlignment = CPDFFontUI.TextAlignment
-            };
+            CPDFFontData = new CPDFFontData();
+            CPDFFontData.FontFamily = CPDFFontUI.FontFamilyValue;
+            CPDFFontData.FontSize = CPDFFontUI.FontSizeValue;
+            CPDFFontData.IsBold = CPDFFontUI.IsBold;
+            CPDFFontData.IsItalic = CPDFFontUI.IsItalic;
+            CPDFFontData.TextAlignment = CPDFFontUI.TextAlignment;
+            FontChanged?.Invoke(this, EventArgs.Empty); 
         }
     }
 }

+ 152 - 11
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml

@@ -5,26 +5,167 @@
              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">
+             d:DesignHeight="120" d:DesignWidth="228">
+    <UserControl.Resources>
+        <Style x:Key="GreyBgRadioBtnStyle" TargetType="{x:Type RadioButton}">
+            <Setter Property="BorderThickness" Value="1" />
+            <Setter Property="Foreground" Value="#252629" />
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type RadioButton}">
+                        <Border
+                        x:Name="templateRoot"
+                        Background="{TemplateBinding Background}"
+                        SnapsToDevicePixels="True">
+                            <ContentPresenter
+                            x:Name="contentPresenter"
+                            Grid.Column="1"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsEnabled" Value="false">
+                                <Setter TargetName="templateRoot" Property="Opacity" Value="0.5" />
+                            </Trigger>
+                            <Trigger Property="IsMouseOver" Value="True">
+                                <Setter Property="Background" Value="#294982E6"></Setter>
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="true">
+                                <Setter Property="Background" Value="#604982E6"></Setter>
+                            </Trigger>
+                            <Trigger Property="IsChecked" Value="true">
+                                <Setter Property="Background" Value="#294982E6"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+    </UserControl.Resources>
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition></RowDefinition>
             <RowDefinition></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
-        <ComboBox x:Name="FontFamilyComboBox" SelectionChanged="FontFamilyComboBox_SelectionChanged"> </ComboBox>
-        <Grid Grid.Row="1">
+        <Grid>
+            <ComboBox x:Name="FontFamilyComboBox" SelectionChanged="FontFamilyComboBox_SelectionChanged" Width="228" Height="28" Margin="0,0,0,4"></ComboBox>
+            <TextBox x:Name="FontFamilyTextBox" IsHitTestVisible="False" Width="228" Height="28" VerticalContentAlignment="Center" IsReadOnly="True" Background="#FFFFFF" Padding="0,0,15,0" Margin="0,0,0,4">Helvetica</TextBox>
+            <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
+                <Path.Data>
+                    M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
+                </Path.Data>
+            </Path>
+        </Grid>
+        <Grid Grid.Row="1" Margin="0,4,0,0">
             <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="2*"></ColumnDefinition>
+                <ColumnDefinition Width="auto"></ColumnDefinition>
                 <ColumnDefinition></ColumnDefinition>
             </Grid.ColumnDefinitions>
-            <ComboBox x:Name="FontStyleComboBox" SelectionChanged="FontStyleComboBox_SelectionChanged"></ComboBox>
-            <local:DropDownNumberBoxControl x:Name="FontSizeComboBox" Maxium="100" Minimum="1" Grid.Column="1" Unit="pt" Text="{Binding FontSizeValue,Mode=TwoWay}"></local:DropDownNumberBoxControl>
+            <Grid Margin="0,0,8,0">
+                <ComboBox x:Name="FontStyleComboBox" SelectionChanged="FontStyleComboBox_SelectionChanged" Width="148" Height="28" BorderBrush="#1E000000" ></ComboBox>
+                <TextBox x:Name="FontStyleTextBox" IsHitTestVisible="False" Width="148" Height="28" VerticalContentAlignment="Center" IsReadOnly="True" Background="#FFFFFF" Padding="0,0,15,0" >Common</TextBox>
+                <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
+                    <Path.Data>
+                        M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
+                    </Path.Data>
+                </Path>
+            </Grid>
+
+            <local:DropDownNumberBoxControl x:Name="FontSizeComboBox" Maxium="100" Minimum="1" Grid.Column="1" Width="72" Height="28" Unit="pt" Text="{Binding FontSizeValue,Mode=TwoWay}"></local:DropDownNumberBoxControl>
         </Grid>
-        <StackPanel Orientation="Horizontal" Grid.Row="2">
-            <RadioButton x:Name="LeftAlignRadioButton" Content="Left" Tag="Left" IsChecked="True" Checked="AlignRadioButton_Checked"></RadioButton>
-            <RadioButton x:Name="CenterAlignRadioButton" Content="Center" Tag="Center" Checked="AlignRadioButton_Checked"></RadioButton>
-            <RadioButton x:Name="RightAlignRadioButton" Content="Right" Tag="Right" Checked="AlignRadioButton_Checked"></RadioButton>
-        </StackPanel>
+
+        <Border BorderBrush="#E2E3E6" BorderThickness="1"  Width="148"  Grid.Row="2"  HorizontalAlignment="Left" Margin="0,8,0,0">
+
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition></ColumnDefinition>
+                    <ColumnDefinition></ColumnDefinition>
+                    <ColumnDefinition></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+                <RadioButton x:Name="LeftAlignRadioButton" Tag="Left" Style="{StaticResource GreyBgRadioBtnStyle}" IsChecked="True" Checked="AlignRadioButton_Checked">
+                    <RadioButton.Content>
+                        <Grid Width="48" Height="30">
+                            <Canvas Margin="16,10,0,0">
+                                <Rectangle
+                               Width="13"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" />
+                                <Rectangle
+                               Canvas.Top="4"
+                               Width="16"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" />
+                                <Rectangle
+                               Canvas.Top="8"
+                               Width="12"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" />
+                            </Canvas>
+                        </Grid>
+                    </RadioButton.Content>
+                </RadioButton>
+                <RadioButton x:Name="CenterAlignRadioButton" Grid.Column="1" Style="{StaticResource GreyBgRadioBtnStyle}" Tag="Center" Checked="AlignRadioButton_Checked">
+                    <RadioButton.Content>
+                        <Grid Width="48" Height="30">
+                            <Canvas Margin="16,10,0,0">
+                                <Rectangle
+                               Width="16"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" />
+                                <Rectangle
+                               Canvas.Top="4"
+                               Width="10"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" 
+                                Margin="3,0,0,0"/>
+                                <Rectangle
+                               Canvas.Top="8"
+                               Width="16"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" />
+                            </Canvas>
+                        </Grid>
+                    </RadioButton.Content>
+                </RadioButton>
+                <RadioButton x:Name="RightAlignRadioButton" Grid.Column="2" Style="{StaticResource GreyBgRadioBtnStyle}" Tag="Right" Checked="AlignRadioButton_Checked">
+                    <RadioButton.Content >
+                        <Grid Width="48" Height="30">
+                            <Canvas Margin="13,10,0,0">
+                                <Rectangle
+                               Width="13"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" 
+                               Margin="3,0,0,0"/>
+                                <Rectangle
+                               Canvas.Top="4"
+                               Width="16"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5"/>
+                                <Rectangle
+                               Canvas.Top="8"
+                               Width="13"
+                               Height="1.5"
+                               Stroke="#000000"
+                               StrokeThickness="1.5" 
+                               Margin="3,0,0,0"/>
+                            </Canvas>
+                        </Grid>
+                    </RadioButton.Content>
+                </RadioButton>
+            </Grid>
+        </Border>
     </Grid>
 </UserControl>

+ 35 - 32
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -28,37 +29,13 @@ namespace compdfkit_tools.Common
         public string FontFamilyValue
         {
             get => FontFamilyComboBox.SelectedItem.ToString();
+            set => FontFamilyComboBox.SelectedItem = value;
         }
 
-        public bool IsBold
-        {
-            get
-            {
-                if (FontStyleComboBox.SelectedItem.ToString() == null || (FontStyleComboBox.SelectedItem.ToString() == "Italic"))
-                {
-                    return false;
-                }
-                else
-                {
-                    return true;
-                }
-            }
-        }
+        public bool IsRewrite = false;
 
-        public bool IsItalic
-        {
-            get
-            {
-                if (FontStyleComboBox.SelectedItem.ToString() == null || (FontStyleComboBox.SelectedItem.ToString() == "Bold"))
-                {
-                    return false;
-                }
-                else
-                {
-                    return true;
-                }
-            }
-        }
+        public bool IsBold;
+        public bool IsItalic;
 
         public TextAlignment TextAlignment
         {
@@ -104,9 +81,9 @@ namespace compdfkit_tools.Common
         {
             List<string> fontNameList = new List<string>()
             {
-                {"Courier New" },
-                {"Arial" },
-                {"Times Roman" }
+                {"Courier" },
+                {"Helvetica" },
+                {"Times" }
             };
             FontFamilyComboBox.ItemsSource = fontNameList;
             FontFamilyComboBox.SelectedIndex = 1;
@@ -149,11 +126,37 @@ namespace compdfkit_tools.Common
 
         private void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            FontChanged?.Invoke(this, EventArgs.Empty);
+            if (!IsRewrite)
+            {
+                FontFamilyTextBox.Text = (sender as ComboBox).SelectedItem.ToString();
+                FontChanged?.Invoke(this, EventArgs.Empty);
+            }
+
         }
 
         private void FontStyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
+            FontStyleTextBox.Text = (sender as ComboBox).SelectedItem.ToString();
+            if(FontStyleTextBox.Text == "Common")
+            {
+                IsBold = false;
+                IsItalic = false;
+            }
+            else if (FontStyleTextBox.Text == "Italic")
+            {
+                IsBold = false;
+                IsItalic = true;
+            }
+            else if (FontStyleTextBox.Text == "Bold")
+            {
+                IsBold = true;
+                IsItalic = false;
+            }
+            else
+            {
+                IsBold = true;
+                IsItalic = true;
+            }
             FontChanged?.Invoke(this, EventArgs.Empty);
         }
 

+ 13 - 14
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml

@@ -47,22 +47,21 @@
         </Style>
     </UserControl.Resources>
     <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
-        </Grid.RowDefinitions>
-        <RadioButton x:Name="SolidRadioButton" Tag="Solid" IsChecked="True" Grid.Row="0" Style="{StaticResource LineRadioButton}" VerticalAlignment="Center"  GroupName="LineStyleGroup" Margin="16,0,0,0" Click="RadioButton_Click">
-            <Line Name="SolidLineControl" Margin="10,0,0,0" Grid.Column="1" Stroke="#000000" StrokeThickness="1" X1="0" Y1="0" X2="112" Y2="0" VerticalAlignment="Center"></Line>
-        </RadioButton>
-        <Grid Grid.Row="1">
+        <Grid>
             <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="2*"></ColumnDefinition>
-                <ColumnDefinition Width="1*"></ColumnDefinition>
+                <ColumnDefinition Width="160"></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
             </Grid.ColumnDefinitions>
-            <RadioButton x:Name="DashRadioButton" Tag="Dash" Margin="16,0,0,0" Style="{StaticResource LineRadioButton}" GroupName="LineStyleGroup" Click="RadioButton_Click">
-                <Line Name="DashLineControl" Margin="10,0,0,0" Grid.Row="1" Grid.Column="1" Stroke="#000000" StrokeThickness="2" X1="0" Y1="0" X2="112" Y2="0" VerticalAlignment="Center" StrokeDashArray="0,1,1"></Line>
-            </RadioButton>
-            <local:NumericUpDownControl x:Name="NumericUpDownControl" Text="{Binding DashSpacing, Mode=TwoWay}" Grid.Column="1" Width="72" Height="28" Unit="pt" Minimum="1" Maxium="100" IsEnabled="{Binding ElementName=DashRadioButton, Path=IsChecked}"></local:NumericUpDownControl>
+            <StackPanel Margin="0,12,0,0">
+                <RadioButton x:Name="SolidRadioButton" Tag="Solid" IsChecked="True" Grid.Row="0" Style="{StaticResource LineRadioButton}" VerticalAlignment="Center" Margin="16,0,0,0" Click="RadioButton_Click">
+                    <Line Name="SolidLineControl" Margin="10,0,0,0" Grid.Column="1" Stroke="#000000" StrokeThickness="1" X1="0" Y1="0" X2="112" Y2="0" VerticalAlignment="Center"></Line>
+                </RadioButton>
+                <RadioButton x:Name="DashRadioButton"  Tag="Dash" Margin="16,12,0,0" Style="{StaticResource LineRadioButton}" Click="RadioButton_Click">
+                    <Line Name="DashLineControl" Margin="10,0,0,0" Grid.Row="1" Grid.Column="1" Stroke="#000000" StrokeThickness="2" X1="0" Y1="0" X2="112" Y2="0" VerticalAlignment="Center" StrokeDashArray="0,1,1"></Line>
+                </RadioButton>
+            </StackPanel>
+            <local:NumericUpDownControl x:Name="NumericUpDownControl" VerticalAlignment="Bottom" Margin="0,0,0,6" Text="{Binding DashSpacing, Mode=TwoWay}" Grid.Column="1" Width="72" Height="28" Unit="pt" Minimum="1" Maxium="100" IsEnabled="{Binding ElementName=DashRadioButton, Path=IsChecked}"></local:NumericUpDownControl>
         </Grid>
     </Grid>
+
 </UserControl>

+ 18 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml.cs

@@ -43,6 +43,24 @@ namespace compdfkit_tools.Common
             }
         }
 
+        private bool _isSolid = true;
+        public bool IsSolid { 
+            get  => _isSolid;
+            set {
+                _isSolid = value;
+                
+             }
+        }
+
+        private bool _isDash;   
+        public bool IsDash {
+            get => _isDash;
+            set {
+                _isDash = value; 
+                
+            }
+        }   
+
         public event EventHandler LineStyleChanged;
         public event PropertyChangedEventHandler PropertyChanged;
 

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpactiyUI.xaml

@@ -20,6 +20,6 @@
         </Grid.ColumnDefinitions>
         <Slider  Style="{StaticResource SliderStyle}" MinHeight="40" VerticalAlignment="Center" Maximum="100" Minimum="0" TickFrequency="1" 
                  IsSnapToTickEnabled="True" Value="{Binding OpacityValue, Mode=TwoWay}" Margin="10,0,10,0"></Slider>
-        <local:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl"  Grid.Column="1" Unit="%" Maxium="100" Minimum="1" Text="{Binding OpacityValue,Mode=TwoWay}"></local:DropDownNumberBoxControl>
+        <local:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl"  Grid.Column="1" Unit="%" Maxium="100" Minimum="1" Height="28" Width="72" Text="{Binding OpacityValue,Mode=TwoWay}"></local:DropDownNumberBoxControl>
     </Grid>
 </UserControl>

+ 9 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFThickness/CPDThicknessUI.xaml

@@ -6,12 +6,19 @@
              xmlns:local="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
              d:DesignHeight="40" d:DesignWidth="300">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="pack://application:,,,/compdfkit-assets;component/Styles/SliderStyle.xaml"></ResourceDictionary>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition Width="80"></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <Slider MinHeight="40" VerticalAlignment="Center" Maximum="16" Minimum="1" TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding Thickness, Mode=TwoWay}" Margin="10,0,10,0"></Slider>
-        <local:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl"  Grid.Column="1" Unit="pt" Maxium="16" Minimum="1" Text="{Binding Thickness,Mode=TwoWay}"></local:DropDownNumberBoxControl>
+        <Slider   Style="{StaticResource SliderStyle}" MinHeight="40" VerticalAlignment="Center" Maximum="16" Minimum="1" TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding Thickness, Mode=TwoWay}" Margin="10,0,10,0"></Slider>
+        <local:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl"  Grid.Column="1" Unit="pt" Maxium="16" Minimum="1" Text="{Binding Thickness,Mode=TwoWay}" Height="28" Width="72"></local:DropDownNumberBoxControl>
     </Grid>
 </UserControl>

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml

@@ -36,7 +36,7 @@
 
             <TextBlock Margin="0,20,0,0" Foreground="#0E1114" FontSize="14">Text Color:</TextBlock>
 
-            <common:ColorPickerControl x:Name="FontColorUI" Grid.Row="1" Margin="0,20,0,0"></common:ColorPickerControl>
+            <common:ColorPickerControl x:Name="FontColorUI" Grid.Row="1" Margin="0,20,0,0" TransparentBtnProperty="Collapsed"></common:ColorPickerControl>
 
             <Grid Grid.Row="2" Margin="0,20,0,0" Visibility="Visible">
                 <Grid.ColumnDefinitions>

+ 2 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextAlignUI.xaml

@@ -31,7 +31,8 @@
                 </ToggleButton.Content>
             </ToggleButton>
 
-            <ToggleButton Name="AlignCenterBtn" Width="30" Margin="10,0,0,0" BorderThickness="0" Padding="0,5,0,5" Tag="AlignCenter" Style="{StaticResource ToggleButtonStyle}" Click="TextAlignBtn_Click">
+            <ToggleButton Name="AlignCenterBtn" Width="30" Margin="10,0,0,0" BorderThickness="0" Padding="0,5,0,5" Tag="AlignCenter" Style="{StaticResource ToggleButtonStyle}" Click="TextAlignBtn_Click"
+                          >
                 <ToggleButton.Content>
                     <Path Name="AlignCenterPath" Fill="Gray">
                         <Path.Data>

+ 7 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -76,6 +76,9 @@
     <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFFreeTextUI.xaml.cs">
       <DependentUpon>CPDFFreeTextUI.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFTempStampUI.xaml.cs">
+      <DependentUpon>CPDFTempStampUI.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFNoteUI.xaml.cs">
       <DependentUpon>CPDFNoteUI.xaml</DependentUpon>
     </Compile>
@@ -331,6 +334,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFTempStampUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFNoteUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 409 - 72
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml

@@ -4,8 +4,7 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:edit_ctrl_demo"
-        xmlns:pdfview="clr-namespace:ComPDFKitViewer.PdfViewer;assembly=ComPDFKit.Viewer"
-        xmlns:tools="clr-namespace:compdfkit_tools.PDFControl;assembly=com.compdfkit.tools"
+        xmlns:cpdftools="clr-namespace:compdfkit_tools.PDFControl;assembly=com.compdfkit.tools"
         mc:Ignorable="d"
         Title="MainWindow" Height="700" Width="1200" WindowStartupLocation="CenterScreen">
     <Window.Resources>
@@ -17,99 +16,437 @@
         </ResourceDictionary>
     </Window.Resources>
     <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="auto"></RowDefinition>
-            <RowDefinition Height="*"></RowDefinition>
-            <RowDefinition Height="auto"></RowDefinition>
-        </Grid.RowDefinitions>
-
-        <!--顶部菜单部分-->
         <Grid>
             <Grid.RowDefinitions>
-                <RowDefinition Height="auto"></RowDefinition>
-                <RowDefinition Height="auto"></RowDefinition>
-                <RowDefinition Height="auto"></RowDefinition>
+                <RowDefinition Height="40"></RowDefinition>
+                <RowDefinition Height="*"></RowDefinition>
             </Grid.RowDefinitions>
-            <tools:TitleBarControl Name="TitleBarTool"></tools:TitleBarControl>
-            
-            <ToggleButton Name="PDFEditBtn" Grid.Row="1" HorizontalAlignment="Center" Padding="10,3,10,3" BorderThickness="0" Click="PDFEditBtn_Click">
-                <TextBlock  FontSize="14" VerticalAlignment="Center">PDFEdit</TextBlock>
-            </ToggleButton>
-
-            <Grid Grid.Row="2" Background="#F2F3F5">
-                <StackPanel  Orientation="Horizontal" HorizontalAlignment="Center">
-
-                    <!--文字编辑按钮-->
-                    <ToggleButton Style="{StaticResource ToggleButtonStyle}" Name="PDFTextEditButton" BorderThickness="0" Padding="10,5,10,5" Click="PDFTextEditButton_Click" Width="99" Height="40">
-                        <StackPanel Orientation="Horizontal">
-                            <Path Fill="#273C62" VerticalAlignment="Center">
+
+            <!--顶部工具栏-->
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+
+                <!--左侧工具栏-->
+                <StackPanel Orientation="Horizontal" Height="40" Margin="20,0,0,0">
+
+                    <!--打开文件-->
+                    <Button BorderThickness="0" VerticalContentAlignment="Center" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="OpenFile_Click">
+                        <Button.Content>
+                            <Viewbox Width="20" Height="20">
+                                <Path Fill="#43474D" >
+                                    <Path.Data>
+                                        M3.75,2 L3.91967773,2.00463867 C4.08325195,2.01391602 4.22851562,2.03710938 4.35546875,2.07421875 C4.52473958,2.12369792 
+                                    4.67578125,2.18489583 4.80859375,2.2578125 C4.94140625,2.33072917 5.05989583,2.41145833 5.1640625,2.5 C5.26822917,2.58854167 
+                                    5.37369792,2.66927083 5.48046875,2.7421875 C5.58723958,2.81510417 5.70182292,2.87630208 5.82421875,2.92578125 C5.94661458,2.97526042 
+                                    6.08854167,3 6.25,3 L6.25,3 L12,3 L12.1371528,3.00868056 C12.2262731,3.02025463 12.3107639,3.04340278 12.390625,3.078125 
+                                    C12.5104167,3.13020833 12.6158854,3.20182292 12.7070312,3.29296875 C12.7981771,3.38411458 12.8697917,3.48958333 12.921875,3.609375 
+                                    C12.9739583,3.72916667 13,3.859375 13,4 L13,4 L13,6 L15,6 L15.1332465,6.00868056 C15.2206308,6.02025463 15.3051215,6.04340278 
+                                    15.3867188,6.078125 C15.5091146,6.13020833 15.6158854,6.20182292 15.7070312,6.29296875 C15.7981771,6.38411458 15.8697917,6.48958333 
+                                    15.921875,6.609375 C15.9739583,6.72916667 16,6.85677083 16,6.9921875 C16,7.1484375 15.9635417,7.29947917 15.890625,7.4453125 
+                                    L15.890625,7.4453125 L12.6171875,14 L0,14 L0,3 L0.00868055556,2.86284722 C0.0202546296,2.77372685 0.0434027778,2.68923611 0.078125,2.609375 
+                                    C0.130208333,2.48958333 0.201822917,2.38411458 0.29296875,2.29296875 C0.384114583,2.20182292 0.489583333,2.13020833 0.609375,2.078125 
+                                    C0.729166667,2.02604167 0.859375,2 1,2 L1,2 L3.75,2 Z M15,7 L4.3125,7 L1.3125,13 L12,13 L15,7 Z M3.75,3 L1,3 L1,11.3828125 L3.4140625,6.5546875 
+                                    L3.48706055,6.43261719 C3.56665039,6.31738281 3.66601562,6.22265625 3.78515625,6.1484375 C3.94401042,6.04947917 4.11979167,6 4.3125,6 
+                                    L4.3125,6 L12,6 L12,4 L6.25,4 L6.08032227,3.99536133 C5.91674805,3.98608398 5.77148438,3.96289062 5.64453125,3.92578125 C5.47526042,3.87630208 
+                                    5.32421875,3.81510417 5.19140625,3.7421875 C5.05859375,3.66927083 4.94010417,3.58854167 4.8359375,3.5 C4.73177083,3.41145833 4.62630208,3.33072917 
+                                    4.51953125,3.2578125 C4.41276042,3.18489583 4.29817708,3.12369792 4.17578125,3.07421875 C4.05338542,3.02473958 3.91145833,3 3.75,3 L3.75,3 Z
+                                    </Path.Data>
+                                </Path>
+                            </Viewbox>
+                        </Button.Content>
+                    </Button>
+
+                    <!--保存文件-->
+                    <Button BorderThickness="0" VerticalContentAlignment="Center" Margin="10,0,0,0" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" 
+                            Click="SaveFileBtn_Click">
+                        <Button.Content>
+                            <Viewbox Width="20" Height="20">
+                                <Path Fill="#43474D" >
+                                    <Path.Data>
+                                        M11.707107,1 L15,4.29289322 L15,15 L1,15 L1,1 L11.707107,1 Z M11.293,2 L2,2 L2,14 L4,14 L4,8 L12,8 L12,14 L14,14 L14,4.707 L11.293,2 Z 
+                                        M11,9 L5,9 L5,14 L11,14 L11,9 Z M7,5 L7,6 L4,6 L4,5 L7,5 Z
+                                    </Path.Data>
+                                </Path>
+                            </Viewbox>
+                        </Button.Content>
+                    </Button>
+
+                    <!--工具栏展开收缩-->
+                    <ToggleButton Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ToolExpand_Click">
+                        <ToggleButton.Content>
+                            <Path Fill="#43474D" Width="30" Height="30">
                                 <Path.Data>
-                                    M1.25 0H0.5V0.75V13.25V14H1.25H17.75H18.5V13.25V7H17V12.5H2V1.5H12.5V0H1.25ZM11.5 5V2.5H3.5V5H5V4H6.75V10H6V11.5H9V10H8.25V4H10V5H11.5ZM15.75 
-                                3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
+                                    M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
                                 </Path.Data>
                             </Path>
-                            <TextBlock  FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0">Add Text</TextBlock>
-                        </StackPanel>
+                        </ToggleButton.Content>
                     </ToggleButton>
 
-                    <!--图片编辑按钮-->
-                    <ToggleButton Style="{StaticResource ToggleButtonStyle}" Name="PDFImageEditButton" BorderThickness="0" Padding="10,5,10,5" Margin="10,0,0,0" Click="PDFImageEditButton_Click">
-                        <StackPanel Orientation="Horizontal">
-                            <Path Fill="#273C62" VerticalAlignment="Center">
+                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
+
+                    <!--抓手工具-->
+                    <ToggleButton BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="True" IsEnabled="False" Visibility="Collapsed">
+                        <ToggleButton.Content>
+                            <Path Fill="#43474D">
                                 <Path.Data>
-                                    M1.25 0H0.5V0.75V13.25V14H1.25H17.75H18.5V13.25V7H17V12.5H2V1.5H12.5V0H1.25ZM11.5 5V2.5H3.5V5H5V4H6.75V10H6V11.5H9V10H8.25V4H10V5H11.5ZM15.75 
-                                3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
+                                    M8.7463 7.94055L8.43134 3.20358C8.38986 2.6073 8.82031 2.08322 9.40947 2.01273L9.46546 2.00656C9.75502 1.97416 10.0451 2.06271 10.2681 2.25159C10.4911 
+                                2.44047 10.6276 2.71317 10.6457 3.00614L10.9886 8.17061C10.999 8.31659 11.1097 8.43516 11.2537 8.45444C11.3176 8.46288 11.382 8.44409 11.4315 
+                                8.40258C11.481 8.36108 11.5111 8.30063 11.5145 8.23584L11.7612 3.47595C11.7918 2.85998 12.3116 2.38523 12.923 2.41468H12.9309C13.5429 2.44972 
+                                14.0111 2.97745 13.9773 3.59407L13.7218 8.51438C13.7137 8.66679 13.8235 8.79975 13.9738 8.81936C14.1225 8.83876 14.2625 8.73915 14.2914 
+                                8.59018L14.8006 6.02337C14.9178 5.41517 15.497 5.01851 16.0954 5.13574L16.1041 5.13751C16.7058 5.25854 17.0969 5.84695 16.979 6.45353L16.3684 
+                                9.53687C15.8189 13.3474 15.0586 15.5052 14.3946 16.4246C13.3649 17.8508 11.5573 17.8667 10.1251 17.8667C8.69381 17.8667 7.16012 17.5291 6.44796 
+                                16.9993C5.73492 16.4696 4.77079 15.2575 4.15837 13.9327L4.16712 13.9283C4.11876 13.8639 4.0774 13.7945 4.04376 13.7212L3.105 11.685C2.84552 11.1243 
+                                3.08338 10.4577 3.63781 10.1918L3.64656 10.1874C3.91235 10.0626 4.21656 10.0497 4.49179 10.1517C4.76702 10.2536 4.99055 10.4619 5.11287 10.7304C5.62206 
+                                11.8234 5.94227 12.324 6.07526 12.2324C6.27386 12.0949 6.12075 11.7176 5.85478 9.21249C5.67578 7.53039 5.45319 5.85328 5.18724 4.18289C5.07653 3.5968 
+                                5.44002 3.02581 6.01489 2.88273L6.07526 2.86775C6.35866 2.79957 6.65742 2.85178 6.90147 3.01215C7.14552 3.17252 7.3134 3.42693 7.36572 3.71571L8.168 
+                                8.02341C8.19642 8.17613 8.33897 8.27937 8.49171 8.25787C8.64561 8.23564 8.75656 8.09774 8.7463 7.94143V7.94055Z
                                 </Path.Data>
                             </Path>
-                            <TextBlock  FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0">Add Picture</TextBlock>
-                        </StackPanel>
+                        </ToggleButton.Content>
                     </ToggleButton>
 
-                    <Line Height="40" Stroke="#D5D6D8" StrokeThickness="2" X1="0" Y1="10" X2="0" Y2="30" Margin="8,0,8,0" />
+                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35" Visibility="Collapsed"></Line>
 
-                    <!--撤销-->
-                    <Button Style="{StaticResource LightButtonStyle}" BorderThickness="0"  Width="40" Height="40" IsEnabled="{Binding CanUndo,Mode=OneWay}" Click="UndoBtn_Click">
-                        <Path Fill="#43474D">
+                    <Grid>
+                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
+                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
+                        </ComboBox>
+                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
+                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
+                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
                             <Path.Data>
-                                M1.03033 3.62131L0.5 4.15164L1.03033 4.68197L4.65164 8.30328L5.7123 7.24261L3.37132 4.90164H10.0607C11.5794 4.90164 12.8107 6.13285 12.8107 
-                                7.65164C12.8107 9.17042 11.5794 10.4016 10.0607 10.4016H2.56066V11.9016H10.0607C12.4079 11.9016 14.3107 9.99885 14.3107 7.65164C14.3107 
-                                5.30443 12.4079 3.40164 10.0607 3.40164H3.37132L5.7123 1.06066L4.65164 0L1.03033 3.62131Z
+                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
                             </Path.Data>
                         </Path>
+                    </Grid>
+
+                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
+                        <Button.Content>
+                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
+                        </Button.Content>
                     </Button>
-                    <!--重做-->
-                    <Button Style="{StaticResource LightButtonStyle}" BorderThickness="0" Width="40" Height="40" Margin="10,0,0,0"  IsEnabled="{Binding CanRedo,Mode=OneWay}" Click="RedoBtn_Click">
-                        <Path Fill="#43474D">
-                            <Path.Data>
-                                M13.7802 3.62131L14.3105 4.15164L13.7802 4.68197L10.1589 8.30328L9.09825 7.24261L11.4392 4.90164H4.74989C3.2311 4.90164 1.99989 6.13285 
-                                1.99989 7.65164C1.99989 9.17042 3.2311 10.4016 4.74989 10.4016H12.2499V11.9016H4.74989C2.40268 11.9016 0.499887 9.99885 0.499887 
-                                7.65164C0.499887 5.30443 2.40268 3.40164 4.74989 3.40164H11.4392L9.09825 1.06066L10.1589 0L13.7802 3.62131Z
-                            </Path.Data>
-                        </Path>
+
+                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
+                        <Button.Content>
+                            <Path Fill="#0E1114">
+                                <Path.Data>
+                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
                     </Button>
+
                 </StackPanel>
+
+                <!--中间工具栏-->
+                <ComboBox Name="ViewComboBox" Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E" SelectionChanged="ComboBox_SelectionChanged">
+                    <ComboBoxItem>Viewer</ComboBoxItem>
+                    <ComboBoxItem IsSelected="True">PDF Edit</ComboBoxItem>
+                </ComboBox>
+
+                <!--右侧工具栏-->
+                <StackPanel Orientation="Horizontal" Grid.Column="2">
+
+                    <!--搜索按钮-->
+                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="ExpandSearchBtn_Click">
+                        <Button.Content>
+                            <Path Fill="#43474D">
+                                <Path.Data>
+                                    M5.10992 13.9353C2.71184 11.5372 2.71184 7.64917 5.10992 5.25108C7.50801 2.853 11.3961 2.853 13.7942 5.25108C16.1922 7.64917 
+                                16.1922 11.5372 13.7942 13.9353C11.3961 16.3334 7.50801 16.3334 5.10992 13.9353ZM4.04926 4.19042C1.06539 7.17429 1.06539 12.0121 
+                                4.04926 14.996C6.85422 17.8009 11.2975 17.9691 14.2989 15.5005L17.1989 18.4006C17.4918 18.6935 17.9667 18.6935 18.2596 
+                                18.4006C18.5525 18.1077 18.5525 17.6328 18.2596 17.3399L15.3595 14.4399C17.828 11.4384 17.6597 6.99533 14.8548 
+                                4.19042C11.8709 1.20655 7.03313 1.20655 4.04926 4.19042Z
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
+                    </Button>
+
+                    <!--右侧工具栏展开收缩-->
+                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Visibility="Collapsed">
+                        <ToggleButton.Content>
+                            <Path Fill="#43474D" Width="30" Height="30">
+                                <Path.Data>
+                                    M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
+                                </Path.Data>
+                            </Path>
+                        </ToggleButton.Content>
+                    </ToggleButton>
+                    
+                    <!--页面显示-->
+                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                        <ToggleButton.Content>
+                            <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
+                                <Path.Data>
+                                    <CombinedGeometry GeometryCombineMode="Exclude">
+                                        <CombinedGeometry.Geometry1>
+                                            M18.3327 10C18.3327 10 14.6017 16.25 9.99935 16.25C5.39698 16.25 1.66602 10 1.66602 10C1.66602 10 5.39698 3.75 9.99935 3.75C14.6017 3.75 18.3327 10 18.3327 10Z
+                                        </CombinedGeometry.Geometry1>
+                                        <CombinedGeometry.Geometry2>
+                                            <EllipseGeometry Center="10,10" RadiusX="2" RadiusY="2"/>
+                                        </CombinedGeometry.Geometry2>
+                                    </CombinedGeometry>
+                                </Path.Data>
+                            </Path>
+                        </ToggleButton.Content>
+                    </ToggleButton>
+
+                    <!--页面信息-->
+                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="PageInfoBtn_Click">
+                        <Button.Content>
+                            <Path Fill="#43474D" VerticalAlignment="Center">
+                                <Path.Data>
+                                    M2.75 10C2.75 5.99594 5.99594 2.75 10 2.75C14.0041 2.75 17.25 5.99594 17.25 10C17.25 14.0041 14.0041 17.25 10 
+                                17.25C5.99594 17.25 2.75 14.0041 2.75 10ZM10 1.25C5.16751 1.25 1.25 5.16751 1.25 10C1.25 14.8325 5.16751 
+                                18.75 10 18.75C14.8325 18.75 18.75 14.8325 18.75 10C18.75 5.16751 14.8325 1.25 10 1.25ZM6.5 11C7.05228 11 
+                                7.5 10.5523 7.5 10C7.5 9.44771 7.05228 9 6.5 9C5.94772 9 5.5 9.44771 5.5 10C5.5 10.5523 5.94772 11 6.5 11ZM10 
+                                11C10.5523 11 11 10.5523 11 10C11 9.44771 10.5523 9 10 9C9.44771 9 9 9.44771 9 10C9 10.5523 9.44771 11 10 11ZM14.5 
+                                10C14.5 10.5523 14.0523 11 13.5 11C12.9477 11 12.5 10.5523 12.5 10C12.5 9.44771 12.9477 9 13.5 9C14.0523 9 14.5 9.44771 14.5 10Z
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
+                    </Button>
+                </StackPanel>
+
             </Grid>
-            
-        </Grid>
 
-        <!--中间内容部分-->
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*"></ColumnDefinition>
-                <ColumnDefinition Width="auto"></ColumnDefinition>
-            </Grid.ColumnDefinitions>
-
-            <pdfview:CPDFViewer Name="PDFView"></pdfview:CPDFViewer>
-            
-            <!--右侧属性面板-->
-            <Border Name="PDFEditContainer" Grid.Column="1">
-                
-            </Border>
-        </Grid>
+            <Grid Name="BodyGrid" Grid.Row="1">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="0"></ColumnDefinition>
+                    <ColumnDefinition Width="0"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
+                    <ColumnDefinition Width="auto"></ColumnDefinition>
+                </Grid.ColumnDefinitions>
+
+                <!--工具栏展开-->
+                <Grid Name="ExpandToolContainer" Visibility="Collapsed">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="auto"></RowDefinition>
+                        <RowDefinition Height="*"></RowDefinition>
+                    </Grid.RowDefinitions>
+
+                    <StackPanel Name="BotaSideTool" Background="{StaticResource color.bg.jumpbar}" Orientation="Horizontal">
+
+                        <!--缩略图-->
+                        <ToggleButton Name="ThumbToolButton"  Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="ThumbToolButton_Click" >
+                            <ToggleButton.Content>
+                                <Path Width="20" Height="20" Fill="#273C62">
+                                    <Path.Data>
+                                        M3.25 1H2.5V1.75V14.25V15H3.25H13.749H14.499V14.25V8V5.65625V5.36131L14.2981 5.14538L10.6638 1.23913L10.4413 1H10.1147H8.49949H3.25ZM4 
+                                    13.5V2.5H8.49949H8.75V6V6.75H9.5H12.999V8V13.5H4ZM12.3466 5.25L10.25 2.99648V5.25H12.3466Z
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
+
+                        <!--大纲-->
+                        <ToggleButton  Name="OutlineToolButton"  Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="OutlineToolButton_Click">
+                            <ToggleButton.Content>
+                                <Path Width="20" Height="20" Fill="#001A4E">
+                                    <Path.Data>
+                                        M4.5 1.5H1.5V4.5H4.5V1.5ZM4.5 6.5H1.5V9.5H4.5V6.5ZM1.5 11.5H4.5V14.5H1.5V11.5ZM15.5 3.75V2.25H6.5V3.75H15.5ZM15.5 7.25V8.75H6.5V7.25H15.5ZM15.5 13.75V12.25H6.5V13.75H15.5Z
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
+
+                        <!--书签-->
+                        <ToggleButton Name="BookmarkToolButton" Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="BookmarkToolButtonn_Click">
+                            <ToggleButton.Content>
+                                <Path Width="20" Height="20" Stroke="#001A4E">
+                                    <Path.Data>
+                                        M6.1221 9.85217L1.25 12.6942V0.75H11.75V12.6942L6.8779 9.85217L6.5 9.63172L6.1221 9.85217Z
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
+
+                        <!--文字搜索-->
+                        <ToggleButton Name="SearchToolButton" Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="SearchToolButton_Click">
+                            <ToggleButton.Content>
+                                <Path Width="20" Height="20" Fill="#001A4E">
+                                    <Path.Data>
+                                        M4.9284 11.1635C3.06851 9.30364 3.06851 6.28816 4.9284 4.42827C6.78829 2.56838 9.80377 2.56838 11.6637 4.42827C13.5235 6.28816 13.5235 9.30364 11.6637 11.1635C9.80377 
+                                    13.0234 6.78829 13.0234 4.9284 11.1635ZM3.86774 3.36761C1.42207 5.81329 1.42207 9.77851 3.86774 12.2242C6.13397 14.4904 9.70494 14.6567 12.1626 12.723L14.3875 
+                                    14.9479C14.6804 15.2408 15.1552 15.2408 15.4481 14.9479C15.741 14.655 15.741 14.1801 15.4481 13.8872L13.2233 11.6624C15.1568 9.20466 14.9905 5.63379 12.7243 
+                                    3.36761C10.2786 0.921935 6.31342 0.921935 3.86774 3.36761Z
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
+
+                    </StackPanel>
 
-        <!--底部工具部分-->
-        <Grid Grid.Row="2">
-            
+                    <Border Grid.Row="1" Name="BotaToolContainer">
+
+                    </Border>
+                </Grid>
+
+                <!--拖动调节控件大小-->
+                <GridSplitter Name="Splitter" Grid.Column="1" Width="15" ResizeBehavior="PreviousAndNext" Visibility="Collapsed">
+                    <GridSplitter.Template>
+                        <ControlTemplate TargetType="{x:Type GridSplitter}">
+                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
+                        BorderBrush="{TemplateBinding Border.BorderBrush}"
+                        Background="{TemplateBinding Panel.Background}" >
+                                <Path Fill="Gray" VerticalAlignment="Center">
+                                    <Path.Data>
+                                        M15 3.75H1V2.25H15V3.75ZM15 8.75H1V7.25H15V8.75ZM1 13.75H15V12.25H1V13.75Z
+                                    </Path.Data>
+                                </Path>
+                            </Border>
+                        </ControlTemplate>
+                    </GridSplitter.Template>
+                </GridSplitter>
+
+                <Grid Grid.Column="2" >
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="auto"></RowDefinition>
+                        <RowDefinition Height="*"></RowDefinition>
+                    </Grid.RowDefinitions>
+
+                    <Border Background="#F2F3F5">
+                        <StackPanel  Orientation="Horizontal" HorizontalAlignment="Center">
+
+                            <!--文字编辑按钮-->
+                            <ToggleButton Style="{StaticResource ToggleButtonStyle}" Name="PDFTextEditButton" BorderThickness="0" Padding="10,5,10,5" Click="PDFTextEditButton_Click" Width="99" Height="40">
+                                <StackPanel Orientation="Horizontal">
+                                    <Path Fill="#273C62" VerticalAlignment="Center">
+                                        <Path.Data>
+                                            M1.25 0H0.5V0.75V13.25V14H1.25H17.75H18.5V13.25V7H17V12.5H2V1.5H12.5V0H1.25ZM11.5 5V2.5H3.5V5H5V4H6.75V10H6V11.5H9V10H8.25V4H10V5H11.5ZM15.75 
+                                3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
+                                        </Path.Data>
+                                    </Path>
+                                    <TextBlock  FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0">Add Text</TextBlock>
+                                </StackPanel>
+                            </ToggleButton>
+
+                            <!--图片编辑按钮-->
+                            <ToggleButton Style="{StaticResource ToggleButtonStyle}" Name="PDFImageEditButton" BorderThickness="0" Padding="10,5,10,5" Margin="10,0,0,0" Click="PDFImageEditButton_Click">
+                                <StackPanel Orientation="Horizontal">
+                                    <Path Fill="#273C62" VerticalAlignment="Center">
+                                        <Path.Data>
+                                            M1.25 0H0.5V0.75V13.25V14H1.25H17.75H18.5V13.25V7H17V12.5H2V1.5H12.5V0H1.25ZM11.5 5V2.5H3.5V5H5V4H6.75V10H6V11.5H9V10H8.25V4H10V5H11.5ZM15.75 
+                                3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
+                                        </Path.Data>
+                                    </Path>
+                                    <TextBlock  FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0">Add Picture</TextBlock>
+                                </StackPanel>
+                            </ToggleButton>
+
+                            <Line Height="40" Stroke="#D5D6D8" StrokeThickness="2" X1="0" Y1="10" X2="0" Y2="30" Margin="8,0,8,0" />
+
+                            <!--撤销-->
+                            <Button Style="{StaticResource LightButtonStyle}" BorderThickness="0"  Width="40" Height="40" IsEnabled="{Binding CanUndo,Mode=OneWay}" Click="UndoBtn_Click"
+                                    Background="Transparent">
+                                <Path Fill="#43474D">
+                                    <Path.Data>
+                                        M1.03033 3.62131L0.5 4.15164L1.03033 4.68197L4.65164 8.30328L5.7123 7.24261L3.37132 4.90164H10.0607C11.5794 4.90164 12.8107 6.13285 12.8107 
+                                7.65164C12.8107 9.17042 11.5794 10.4016 10.0607 10.4016H2.56066V11.9016H10.0607C12.4079 11.9016 14.3107 9.99885 14.3107 7.65164C14.3107 
+                                5.30443 12.4079 3.40164 10.0607 3.40164H3.37132L5.7123 1.06066L4.65164 0L1.03033 3.62131Z
+                                    </Path.Data>
+                                </Path>
+                            </Button>
+                            <!--重做-->
+                            <Button Style="{StaticResource LightButtonStyle}" BorderThickness="0" Width="40" Height="40" Margin="10,0,0,0"  IsEnabled="{Binding CanRedo,Mode=OneWay}" Click="RedoBtn_Click"
+                                    Background="Transparent">
+                                <Path Fill="#43474D">
+                                    <Path.Data>
+                                        M13.7802 3.62131L14.3105 4.15164L13.7802 4.68197L10.1589 8.30328L9.09825 7.24261L11.4392 4.90164H4.74989C3.2311 4.90164 1.99989 6.13285 
+                                1.99989 7.65164C1.99989 9.17042 3.2311 10.4016 4.74989 10.4016H12.2499V11.9016H4.74989C2.40268 11.9016 0.499887 9.99885 0.499887 
+                                7.65164C0.499887 5.30443 2.40268 3.40164 4.74989 3.40164H11.4392L9.09825 1.06066L10.1589 0L13.7802 3.62131Z
+                                    </Path.Data>
+                                </Path>
+                            </Button>
+                        </StackPanel>
+                    </Border>
+
+                    <!--PDFViewer-->
+                    <Border Grid.Row="1" x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}" MouseMove="PDFGrid_MouseMove"></Border>
+
+                    <Border Grid.Row="1" Background="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Center" CornerRadius="5" Width="100" Height="36" Margin="0,0,0,30"
+                        MouseEnter="Border_MouseEnter"  />
+                    <!--页码工具-->
+                    <Border Grid.Row="1" Name="FloatPageTool" Background="#CC000000" VerticalAlignment="Bottom" HorizontalAlignment="Center"
+                        Margin="0,0,0,20" CornerRadius="5" Width="100" Height="36" Visibility="Collapsed">
+                        <Grid>
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="auto"></ColumnDefinition>
+                                <ColumnDefinition Width="*"></ColumnDefinition>
+                                <ColumnDefinition Width="auto"></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+
+                            <!--上一页-->
+                            <Border Background="Transparent" Width="20" Height="20" Margin="11,0,0,0" MouseLeftButtonDown="PrevPageBorder_MouseLeftButtonDown">
+                                <Path Fill="White" VerticalAlignment="Center" HorizontalAlignment="Center">
+                                    <Path.Data>
+                                        M7.70711 13.7071C8.06759 13.3466 8.09532 12.7794 7.7903 12.3871L7.70711 12.2929L2.415 7L7.70711 1.70711C8.06759 1.34662 
+                                        8.09532 0.779392 7.7903 0.387101L7.70711 0.292894C7.34662 -0.0675898 6.77939 -0.0953197 6.3871 0.209705L6.29289 
+                                        0.292894L0.292892 6.29289C-0.0675917 6.65338 -0.0953217 7.22061 0.209703 7.6129L0.292892 7.70711L6.29289 
+                                        13.7071C6.68342 14.0976 7.31658 14.0976 7.70711 13.7071Z
+                                    </Path.Data>
+                                </Path>
+                            </Border>
+
+                            <!--页码范围-->
+                            <TextBlock Name="PageRangeText" Grid.Column="1" Foreground="White" FontSize="12" VerticalAlignment="Center" HorizontalAlignment="Center">2/3</TextBlock>
+
+                            <!--下一页-->
+                            <Border Width="20" Height="20" Background="Transparent" Grid.Column="2" Margin="0,0,11,0" MouseLeftButtonDown="NextPageBorder_MouseLeftButtonDown">
+                                <Path Fill="White" VerticalAlignment="Center" HorizontalAlignment="Center">
+                                    <Path.Data>
+                                        M0.292893 0.292893C-0.0675908 0.653377 -0.0953203 1.22061 0.209705 1.6129L0.292893 1.70711L5.585 7L0.292893 
+                                    12.2929C-0.0675908 12.6534 -0.0953203 13.2206 0.209705 13.6129L0.292893 13.7071C0.653377 14.0676 1.22061 14.0953 
+                                    1.6129 13.7903L1.70711 13.7071L7.70711 7.70711C8.06759 7.34662 8.09532 6.77939 7.7903 6.3871L7.70711 6.29289L1.70711 
+                                    0.292893C1.31658 -0.0976311 0.683418 -0.0976311 0.292893 0.292893Z
+                                    </Path.Data>
+                                </Path>
+                            </Border>
+
+                        </Grid>
+                    </Border>
+                </Grid>
+
+                <!--右侧面板-->
+                <Border Name="PropertyContainer" Grid.Column="3" Visibility="Hidden"></Border>
+            </Grid>
         </Grid>
+
+        <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
+            <Grid>
+
+                <!--文件信息-->
+                <Grid Name="FileInfoUI"  Width="422" Height="680" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White" Visibility="Collapsed">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*"></ColumnDefinition>
+                        <ColumnDefinition Width="*"></ColumnDefinition>
+                    </Grid.ColumnDefinitions>
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="auto"></RowDefinition>
+                        <RowDefinition Height="*"></RowDefinition>
+                    </Grid.RowDefinitions>
+
+                    <TextBlock Width="50" Height="20" FontSize="14" LineHeight="16" Margin="12,6,0,0" HorizontalAlignment="Left">FileInfo:</TextBlock>
+                    <Button Grid.Column="1" Width="16" Height="16" HorizontalAlignment="Right" Margin="0,8,8,0" BorderThickness="0" Click="FileInfoCloseBtn_Click">
+                        <Button.Content>
+                            <Path Fill="Black">
+                                <Path.Data>
+                                    M6.69495 6L11.5 1.19495L10.805 0.5L6 5.30505L1.19495 0.5L0.5 1.19495L5.30505 6L0.5 10.805L1.19495 11.5L6 6.69495L10.805 11.5L11.5 10.805L6.69495 6Z
+                                </Path.Data>
+                            </Path>
+                        </Button.Content>
+                    </Button>
+                    <cpdftools:CPDFInfoControl Grid.Row="1" Margin="25,10,25,0" Grid.ColumnSpan="2" Name="FileInfoControl"></cpdftools:CPDFInfoControl>
+                </Grid>
+
+                <!--密码验证-->
+                <local:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></local:PasswordDialog>
+            </Grid>
+
+        </Border>
     </Grid>
 </Window>

+ 483 - 86
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml.cs

@@ -1,5 +1,7 @@
-using ComPDFKit.PDFPage;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
 using compdfkit_tools.Edit;
+using compdfkit_tools.Helper;
 using compdfkit_tools.PDFControl;
 using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
@@ -9,21 +11,11 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing;
-using System.Linq;
 using System.Runtime.CompilerServices;
-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;
-using System.Xml.Linq;
 
 namespace edit_ctrl_demo
 {
@@ -39,9 +31,9 @@ namespace edit_ctrl_demo
         {
             get
             {
-                if (PDFView != null)
+                if (pdfViewControl != null&& pdfViewControl.PDFView!=null)
                 {
-                    return PDFView.UndoManager.CanUndo;
+                    return pdfViewControl.PDFView.UndoManager.CanUndo;
                 }
                 return false;
             }
@@ -54,9 +46,9 @@ namespace edit_ctrl_demo
         {
             get
             {
-                if (PDFView != null)
+                if (pdfViewControl != null && pdfViewControl.PDFView != null)
                 {
-                    return PDFView.UndoManager.CanRedo;
+                    return pdfViewControl.PDFView.UndoManager.CanRedo;
                 }
                 return false;
             }
@@ -70,8 +62,10 @@ namespace edit_ctrl_demo
         /// <summary>
         /// 缩放比例
         /// </summary>
-        private double[] zoomLevel = { 1.00f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
+        private PDFViewControl passwordViewer;
+        private PDFViewControl pdfViewControl;
 
+        private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
         public MainWindow()
         {
             InitializeComponent();
@@ -95,20 +89,104 @@ namespace edit_ctrl_demo
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
         {
             LoadDefaultDocument();
-            TitleBarTool.OpenFileEvent += TitleBarTool_OpenFileEvent;
-            PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
-            PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
-            PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
-            PDFView.MouseWheelZoomHandler += PDFView_MouseWheelZoomHandler;
+            BindZoomLevel();
+          
+            if(pdfViewControl!=null)
+            {
+                pdfViewControl.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
+                pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
+            }
         }
 
-        /// <summary>
-        /// 鼠标滚轮缩放事件
-        /// </summary>
-        private void PDFView_MouseWheelZoomHandler(object sender, bool e)
+        private void BindZoomLevel()
+        {
+            foreach (double zoomLevel in zoomLevelList)
+            {
+                ComboBoxItem zoomItem = new ComboBoxItem();
+                zoomItem.Content = zoomLevel + "%";
+                ZoomComboBox.Items.Add(zoomItem);
+            }
+        }
+
+        private void LoadDocument()
         {
-            double newZoom = CheckZoomLevel(PDFView.ZoomFactor + (e ? 0.01 : -0.01), e);
-            PDFView?.Zoom(newZoom);
+            pdfViewControl.PDFView?.Load();
+            PDFGrid.Child = pdfViewControl;
+            pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
+            pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
+            PasswordUI.Closed += PasswordUI_Closed;
+            PasswordUI.Canceled += PasswordUI_Canceled;
+            PasswordUI.Confirmed += PasswordUI_Confirmed;
+
+            UIElement currentBotaTool = GetBotaTool();
+            if (currentBotaTool is CPDFSearchControl)
+            {
+                ((CPDFSearchControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
+            }
+
+            if (currentBotaTool is CPDFThumbnailControl)
+            {
+                ((CPDFThumbnailControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
+                ((CPDFThumbnailControl)currentBotaTool).ThumbLoaded = false;
+                ((CPDFThumbnailControl)currentBotaTool).LoadThumb();
+            }
+
+            if (currentBotaTool is CPDFBookmarkControl)
+            {
+                ((CPDFBookmarkControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
+                ((CPDFBookmarkControl)currentBotaTool).LoadBookmark();
+            }
+
+            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
+
+            SetEditMode();
+        }
+
+        private void PasswordUI_Confirmed(object sender, string e)
+        {
+            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            {
+                passwordViewer.PDFView.Document.UnlockWithPassword(e);
+                if (passwordViewer.PDFView.Document.IsLocked == false)
+                {
+                    PasswordUI.SetShowError("", Visibility.Collapsed);
+                    PasswordUI.ClearPassword();
+                    PasswordUI.Visibility = Visibility.Collapsed;
+                    PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
+                }
+                else
+                {
+                    PasswordUI.SetShowError("error", Visibility.Visible);
+                }
+            }
+        }
+
+        private void PasswordUI_Canceled(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
+        }
+
+        private void PasswordUI_Closed(object sender, EventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+            PasswordUI.Visibility = Visibility.Collapsed;
+        }
+
+        private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
+        {
+            if (e.Key == "PageNum")
+            {
+                PageRangeText.Text = string.Format("{0}/{1}", e.Value, pdfViewControl.PDFView.Document.PageCount);
+            }
+
+            if (e.Key == "Zoom")
+            {
+                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+            }
         }
 
         /// <summary>
@@ -127,16 +205,16 @@ namespace edit_ctrl_demo
             }
 
             zoom *= 100;
-            for (int i = 0; i < zoomLevel.Length - 1; i++)
+            for (int i = 0; i < zoomLevelList.Length - 1; i++)
             {
-                if (zoom > zoomLevel[i] && zoom <= zoomLevel[i + 1] && IsGrowth)
+                if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
                 {
-                    standardZoom = zoomLevel[i + 1];
+                    standardZoom = zoomLevelList[i + 1];
                     break;
                 }
-                if (zoom >= zoomLevel[i] && zoom < zoomLevel[i + 1] && !IsGrowth)
+                if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
                 {
-                    standardZoom = zoomLevel[i];
+                    standardZoom = zoomLevelList[i];
                     break;
                 }
             }
@@ -183,7 +261,8 @@ namespace edit_ctrl_demo
             lastPDFEditEvent = e;
             if (e == null)
             {
-                PDFEditContainer.Child= null;
+                PropertyContainer.Child= null;
+                PropertyContainer.Visibility= Visibility.Collapsed;
                 return;
             }
            
@@ -196,40 +275,343 @@ namespace edit_ctrl_demo
             {
                 PDFTextEditControl textEditControl = new PDFTextEditControl();
                 textEditControl.SetPDFTextEditData(e);
-                PDFEditContainer.Child = textEditControl;
+                PropertyContainer.Child = textEditControl;
+                PropertyContainer.Visibility = Visibility.Visible;
                 return;
             }
 
-            if (e.EditType == CPDFEditType.EditImage)
+            if (e.EditType == CPDFEditType.EditImage && pdfViewControl!=null)
             {
                 PDFImageEditControl imageEditControl = new PDFImageEditControl();
-                imageEditControl.InitWithPDFViewer(PDFView);
+                imageEditControl.InitWithPDFViewer(pdfViewControl.PDFView);
                 imageEditControl.SetPDFImageEditData(e);
-                PDFEditContainer.Child = imageEditControl;
+                PropertyContainer.Child = imageEditControl;
+                PropertyContainer.Visibility = Visibility.Visible;
                 return;
             }
         }
 
         /// <summary>
-        /// 工具栏选择文件对话框事件通知
+        /// 加载显示默认文档
         /// </summary>
-        private void TitleBarTool_OpenFileEvent(object sender, string filePath)
+        private void LoadDefaultDocument()
         {
-            ClearPDFEditState();
-            PDFView?.CloseDocument();
-            PDFView?.InitDocument(filePath);
-            PDFView?.Load();
-            PDFView?.SetMouseMode(MouseModes.PanTool);
+            string defaultFilePath = "..\\..\\..\\..\\developer_guide_windows.pdf";
+            pdfViewControl = new PDFViewControl();
+            pdfViewControl.PDFView.InitDocument(defaultFilePath);
+            LoadDocument();
         }
 
         /// <summary>
-        /// 加载显示默认文档
+        /// 搜索工具点击处理
         /// </summary>
-        private void LoadDefaultDocument()
+        private void SearchToolButton_Click(object sender, RoutedEventArgs e)
         {
-            string defaultFilePath = "..\\..\\..\\..\\developer_guide_windows.pdf";
-            PDFView?.InitDocument(defaultFilePath);
-            PDFView?.Load();
+            UIElement botaTool = GetBotaTool();
+            if (botaTool == null || !(botaTool is CPDFSearchControl))
+            {
+                CPDFSearchControl searchControl = new CPDFSearchControl();
+                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    searchControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                }
+                SetBotaTool(searchControl);
+            }
+            ExpandBotaTool(SearchToolButton.IsChecked == true);
+            ClearToolState(SearchToolButton);
+        }
+
+        /// <summary>
+        /// 缩略图列表点击处理
+        /// </summary>
+        private void ThumbToolButton_Click(object sender, RoutedEventArgs e)
+        {
+            UIElement botaTool = GetBotaTool();
+            if (botaTool == null || !(botaTool is CPDFThumbnailControl))
+            {
+                CPDFThumbnailControl thumbControl = new CPDFThumbnailControl();
+
+                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    thumbControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                    thumbControl.LoadThumb();
+                }
+                SetBotaTool(thumbControl);
+            }
+            ExpandBotaTool(ThumbToolButton.IsChecked == true);
+            ClearToolState(ThumbToolButton);
+        }
+
+        /// <summary>
+        /// 书签列表点击处理
+        /// </summary>
+        private void BookmarkToolButtonn_Click(object sender, RoutedEventArgs e)
+        {
+            UIElement botaTool = GetBotaTool();
+            if (botaTool == null || !(botaTool is CPDFBookmarkControl))
+            {
+                CPDFBookmarkControl bookmarkControl = new CPDFBookmarkControl();
+
+                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    bookmarkControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                    bookmarkControl.LoadBookmark();
+                }
+                SetBotaTool(bookmarkControl);
+            }
+            ExpandBotaTool(BookmarkToolButton.IsChecked == true);
+            ClearToolState(BookmarkToolButton);
+        }
+
+        /// <summary>
+        /// 大纲列表处理
+        /// </summary>
+        private void OutlineToolButton_Click(object sender, RoutedEventArgs e)
+        {
+            UIElement botaTool = GetBotaTool();
+            if (botaTool == null || !(botaTool is CPDFOutlineControl))
+            {
+                CPDFOutlineControl outlineControl = new CPDFOutlineControl();
+
+                if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                {
+                    outlineControl.InitWithPDFViewer(pdfViewControl.PDFView);
+                }
+                SetBotaTool(outlineControl);
+            }
+            ExpandBotaTool(OutlineToolButton.IsChecked == true);
+            ClearToolState(OutlineToolButton);
+
+        }
+        /// <summary>
+        /// 设置Bota工具内容
+        /// </summary>
+        /// <param name="newChild"></param>
+        private void SetBotaTool(UIElement newChild)
+        {
+            BotaToolContainer.Child = newChild;
+        }
+
+        /// <summary>
+        /// 获取Bota工具
+        /// </summary>
+        /// <returns></returns>
+        private UIElement GetBotaTool()
+        {
+            return BotaToolContainer.Child;
+        }
+
+        /// <summary>
+        /// 展开Bota工具
+        /// </summary>
+        /// <param name="isExpand"></param>
+        private void ExpandBotaTool(bool isExpand)
+        {
+            BotaToolContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 清除左边工具栏状态
+        /// </summary>
+        private void ClearToolState(UIElement ignoreTool)
+        {
+            foreach (UIElement child in BotaSideTool.Children)
+            {
+                if (child != ignoreTool && child is ToggleButton buttonTool)
+                {
+                    buttonTool.IsChecked = false;
+                }
+            }
+        }
+
+        private void ToolExpand_Click(object sender, RoutedEventArgs e)
+        {
+            ToggleButton expandBtn = sender as ToggleButton;
+            if (expandBtn != null)
+            {
+                bool isExpand = expandBtn.IsChecked == true;
+                ExpandLeftPanel(isExpand);
+                if (isExpand)
+                {
+                    ThumbToolButton.IsChecked = isExpand;
+                    ThumbToolButton_Click(ThumbToolButton, new RoutedEventArgs());
+                }
+            }
+        }
+
+        private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ExpandLeftPanel(true);
+            SearchToolButton.IsChecked = true;
+            SearchToolButton_Click(SearchToolButton, new RoutedEventArgs());
+        }
+
+        private void ExpandLeftPanel(bool isExpand)
+        {
+            ExpandToolContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            if (isExpand)
+            {
+                BodyGrid.ColumnDefinitions[0].Width = new GridLength(260);
+                BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
+            }
+            else
+            {
+                BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
+                BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
+            }
+        }
+
+        private void Border_MouseEnter(object sender, MouseEventArgs e)
+        {
+            FloatPageTool.Visibility = Visibility.Visible;
+        }
+
+        private void PDFGrid_MouseMove(object sender, MouseEventArgs e)
+        {
+            FloatPageTool.Visibility = Visibility.Collapsed;
+        }
+
+        private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ToggleButton toggleButton = sender as ToggleButton;
+            if (toggleButton != null)
+            {
+                if (toggleButton.IsChecked == true)
+                {
+                    CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
+                    displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
+                    PropertyContainer.Child = displayPanel;
+                    PropertyContainer.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    PropertyContainer.Child = null;
+                    PropertyContainer.Visibility = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
+            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
+            {
+                if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
+                {
+                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
+                    ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
+                }
+            }
+        }
+
+        private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if (pdfViewControl != null)
+            {
+                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
+                pdfViewControl.PDFView.Zoom(newZoom);
+                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
+            }
+        }
+
+        private void ZoomOutBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if (pdfViewControl != null)
+            {
+                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
+                pdfViewControl.PDFView.Zoom(newZoom);
+                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
+            }
+        }
+
+        private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);
+        }
+
+        private void PrevPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex - 1);
+        }
+
+        private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
+        {
+            PasswordUI.Visibility = Visibility.Collapsed;
+            FileInfoUI.Visibility = Visibility.Visible;
+            FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            PopupBorder.Visibility = Visibility.Visible;
+        }
+
+        private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
+        {
+            PopupBorder.Visibility = Visibility.Collapsed;
+        }
+
+        private void OpenFile_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                string filePath = CommonHelper.GetFilePathOrEmpty();
+                if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+                {
+                    passwordViewer = new PDFViewControl();
+                    passwordViewer.PDFView.InitDocument(filePath);
+                    if (passwordViewer.PDFView.Document == null)
+                    {
+                        MessageBox.Show("Open File Failed");
+                        return;
+                    }
+
+                    if (passwordViewer.PDFView.Document.IsLocked)
+                    {
+                        PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                        PasswordUI.ClearPassword();
+                        PopupBorder.Visibility = Visibility.Visible;
+                        PasswordUI.Visibility = Visibility.Visible;
+                    }
+                    else
+                    {
+                        pdfViewControl = passwordViewer;
+                        LoadDocument();
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+
+            }
+
+        }
+
+        private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+            {
+                try
+                {
+                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                    if (pdfDoc.WriteToLoadedPath())
+                    {
+                        return;
+                    }
+
+                    SaveFileDialog saveDialog = new SaveFileDialog();
+                    saveDialog.Filter = "(*.pdf)|*.pdf";
+                    saveDialog.DefaultExt = ".pdf";
+                    saveDialog.OverwritePrompt = true;
+
+                    if (saveDialog.ShowDialog() == true)
+                    {
+                        pdfDoc.WriteToFilePath(saveDialog.FileName);
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                }
+            }
         }
 
         /// <summary>
@@ -238,21 +620,21 @@ namespace edit_ctrl_demo
         private void PDFTextEditButton_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton senderBtn=sender as ToggleButton;
-            if(senderBtn != null)
+            if(senderBtn != null && pdfViewControl!=null)
             {
                 ClearPDFEditState(senderBtn);
                 if (senderBtn.IsChecked == true)
                 {
-                    PDFView?.SetPDFEditType(CPDFEditType.EditText);
-                    PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
-                    PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                    PDFView?.ReloadDocument();
+                    pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
+                    pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
+                    pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                    pdfViewControl.PDFView?.ReloadDocument();
                 }
                 else
                 {
-                    PDFView?.SetPDFEditType(CPDFEditType.None);
-                    PDFView?.SetMouseMode(MouseModes.PanTool);
-                    PDFView?.ReloadDocument();
+                    pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
+                    pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
+                    pdfViewControl.PDFView?.ReloadDocument();
                 }
             }
         }
@@ -263,19 +645,19 @@ namespace edit_ctrl_demo
         private void PDFImageEditButton_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton senderBtn = sender as ToggleButton;
-            if (senderBtn != null)
+            if (senderBtn != null && pdfViewControl!=null)
             {
                 ClearPDFEditState(senderBtn);
                 senderBtn.IsChecked = false;
-                PDFView?.SetPDFEditType(CPDFEditType.EditImage);
-                PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                PDFView?.ReloadDocument();
+                pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage);
+                pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                pdfViewControl.PDFView?.ReloadDocument();
                 OpenFileDialog openFileDialog = new OpenFileDialog();
                 openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
                 if (openFileDialog.ShowDialog() == true)
                 {
-                    PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
-                    PDFView?.AddPDFEditImage(openFileDialog.FileName);
+                    pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
+                    pdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName);
                 }
             }
         }
@@ -288,8 +670,7 @@ namespace edit_ctrl_demo
             List<ToggleButton> clearBtnList = new List<ToggleButton>()
             { 
                 PDFTextEditButton,
-                PDFImageEditButton,
-                PDFEditBtn,
+                PDFImageEditButton
             };
 
             foreach (ToggleButton item in clearBtnList)
@@ -300,8 +681,11 @@ namespace edit_ctrl_demo
                 }
                 item.IsChecked = false;
             }
-            
-            PDFEditContainer.Child = null;
+
+            if(PropertyContainer!=null)
+            {
+                PropertyContainer.Child = null;
+            }
         }
 
         /// <summary>
@@ -309,7 +693,10 @@ namespace edit_ctrl_demo
         /// </summary>
         private void UndoBtn_Click(object sender, RoutedEventArgs e)
         {
-            PDFView?.UndoManager?.Undo();
+            if(pdfViewControl!=null && pdfViewControl.PDFView!=null)
+            {
+                pdfViewControl.PDFView.UndoManager?.Undo();
+            }
         }
 
         /// <summary>
@@ -317,7 +704,10 @@ namespace edit_ctrl_demo
         /// </summary>
         private void RedoBtn_Click(object sender, RoutedEventArgs e)
         {
-            PDFView?.UndoManager?.Redo();
+            if (pdfViewControl != null && pdfViewControl.PDFView != null)
+            {
+                pdfViewControl.PDFView.UndoManager?.Redo();
+            }
         }
 
         /// <summary>
@@ -341,7 +731,7 @@ namespace edit_ctrl_demo
                     {
                         PDFTextEditControl textEditControl = new PDFTextEditControl();
                         textEditControl.SetPDFTextEditData(lastPDFEditEvent);
-                        PDFEditContainer.Child = textEditControl;
+                        PropertyContainer.Child = textEditControl;
                     }
                 };
                 editCommand.PopupMenu.Items.Add(propertyMenu);
@@ -400,7 +790,7 @@ namespace edit_ctrl_demo
                         {
                             lastPDFEditEvent.ReplaceImagePath = openFileDialog.FileName;
                             lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                            PDFView?.ClearSelectPDFEdit();
+                            pdfViewControl.PDFView?.ClearSelectPDFEdit();
                         }
                     }
                 };
@@ -410,9 +800,9 @@ namespace edit_ctrl_demo
                 exportMenu.Header = "导出";
                 exportMenu.Click += (o, p) =>
                 {
-                    if (PDFView != null)
+                    if (pdfViewControl != null && pdfViewControl.PDFView!=null)
                     {
-                        Dictionary<int, List<Bitmap>> imageDict = PDFView.GetSelectedImages();
+                        Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView.GetSelectedImages();
                         if (imageDict != null && imageDict.Count > 0)
                         {
                             System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
@@ -528,24 +918,31 @@ namespace edit_ctrl_demo
         /// <summary>
         /// 进入文字和图片编辑
         /// </summary>
-        private void PDFEditBtn_Click(object sender, RoutedEventArgs e)
+        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            ToggleButton senderBtn = sender as ToggleButton;
-            if (senderBtn != null)
+            SetEditMode();
+        }
+
+        private void SetEditMode()
+        {
+            ClearPDFEditState(null);
+
+            if (pdfViewControl != null && ViewComboBox != null)
             {
-                ClearPDFEditState(senderBtn);
-                if (senderBtn.IsChecked == true)
+                if (ViewComboBox.SelectedIndex == 0)
                 {
-                    PDFView?.SetPDFEditType(CPDFEditType.EditText|CPDFEditType.EditImage);
-                    PDFView?.SetPDFEditCreateType(CPDFEditType.None);
-                    PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                    PDFView?.ReloadDocument();
+                    pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
+                    pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
+                    pdfViewControl.PDFView?.ReloadDocument();
+                    return;
                 }
-                else
+
+                if (ViewComboBox.SelectedIndex == 1)
                 {
-                    PDFView?.SetPDFEditType(CPDFEditType.None);
-                    PDFView?.SetMouseMode(MouseModes.PanTool);
-                    PDFView?.ReloadDocument();
+                    pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
+                    pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
+                    pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                    pdfViewControl.PDFView?.ReloadDocument();
                 }
             }
         }

+ 61 - 0
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/PasswordDialog.xaml

@@ -0,0 +1,61 @@
+<UserControl x:Class="edit_ctrl_demo.PasswordDialog"
+             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:edit_ctrl_demo"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800" BorderBrush="Black" BorderThickness="1">
+    
+    <Grid  Width="534" Height="206" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*"></ColumnDefinition>
+            <ColumnDefinition Width="*"></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="auto"></RowDefinition>
+        </Grid.RowDefinitions>
+
+        <TextBlock Height="20" FontSize="14" LineHeight="16" Margin="12,6,0,0" HorizontalAlignment="Left">Please enter the password:</TextBlock>
+        
+        <Button Grid.Column="1" Width="16" Height="16" HorizontalAlignment="Right" Margin="0,8,8,0" BorderThickness="0" Click="PasswordDialogClose_Click">
+            <Button.Content>
+                <Path Fill="Black">
+                    <Path.Data>
+                        M6.69495 6L11.5 1.19495L10.805 0.5L6 5.30505L1.19495 0.5L0.5 1.19495L5.30505 6L0.5 10.805L1.19495 11.5L6 6.69495L10.805 11.5L11.5 10.805L6.69495 6Z
+                    </Path.Data>
+                </Path>
+            </Button.Content>
+        </Button>
+
+        <Grid Grid.Row="1" Margin="0,36,0,0" Grid.ColumnSpan="2">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"></ColumnDefinition>
+                <ColumnDefinition Width="*"></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="auto"></RowDefinition>
+                <RowDefinition Height="auto"></RowDefinition>
+            </Grid.RowDefinitions>
+
+            <Image Width="32" Height="32" Source="pack://application:,,,/compdfkit-assets;component/Resource/warn.png"/>
+
+            <TextBlock FontSize="14" Foreground="#43474D" Grid.Column="1" Name="FileEncryptText" VerticalAlignment="Center"></TextBlock>
+
+            <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Height="52" Margin="0,22,0,0" >
+                <TextBlock FontSize="14" Foreground="#43474D" Margin="0,-20,0,0"  VerticalAlignment="Center">Please enter the password:</TextBlock>
+                <StackPanel Margin="8,0,0,0">
+                    <PasswordBox Name="PasswordBoxText" Padding="5,0,0,0" Height="32" Width="185"  VerticalContentAlignment="Center" VerticalAlignment="Center"></PasswordBox>
+                    <TextBlock Name="ErrorTipsText" Foreground="Red" Margin="0,4,0,0" Visibility="Collapsed"></TextBlock>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Margin="0,0,24,12" Grid.ColumnSpan="2">
+            <Button Width="112" Height="32" Click="PasswordDialogConfirm_Click">OK</Button>
+            <Button Width="112" Height="32" Margin="8,0,0,0" Click="PasswordDialogCancel_Click">Cancel</Button>
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 64 - 0
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/PasswordDialog.xaml.cs

@@ -0,0 +1,64 @@
+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 edit_ctrl_demo
+{
+    /// <summary>
+    /// PasswordDialog.xaml 的交互逻辑
+    /// </summary>
+    public partial class PasswordDialog : UserControl
+    {
+        public event EventHandler Closed;
+
+        public event EventHandler Canceled;
+
+        public event EventHandler<string> Confirmed;
+        public PasswordDialog()
+        {
+            InitializeComponent();
+        }
+
+        public void SetShowText(string newText)
+        {
+            FileEncryptText.Text = newText;
+        }
+
+        private void PasswordDialogClose_Click(object sender, RoutedEventArgs e)
+        {
+            Closed?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void PasswordDialogCancel_Click(object sender, RoutedEventArgs e)
+        {
+            Canceled?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void PasswordDialogConfirm_Click(object sender, RoutedEventArgs e)
+        {
+            Confirmed?.Invoke(this, PasswordBoxText.Password);
+        }
+
+        public void SetShowError(string errorText,Visibility visible)
+        {
+            ErrorTipsText.Text = errorText;
+            ErrorTipsText.Visibility = visible;
+        }
+
+        public void ClearPassword()
+        {
+            PasswordBoxText.Password = string.Empty;
+        }
+    }
+}

+ 7 - 0
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/edit-ctrl-demo.csproj

@@ -78,8 +78,15 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="PasswordDialog.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="PasswordDialog.xaml.cs">
+      <DependentUpon>PasswordDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>

+ 128 - 136
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml

@@ -21,25 +21,24 @@
                 <RowDefinition Height="40"></RowDefinition>
                 <RowDefinition Height="*"></RowDefinition>
             </Grid.RowDefinitions>
+                <!--顶部工具栏-->
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="auto"></ColumnDefinition>
+                        <ColumnDefinition Width="*"></ColumnDefinition>
+                        <ColumnDefinition Width="auto"></ColumnDefinition>
+                    </Grid.ColumnDefinitions>
 
-            <!--顶部工具栏-->
-            <Grid>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="auto"></ColumnDefinition>
-                    <ColumnDefinition Width="*"></ColumnDefinition>
-                    <ColumnDefinition Width="auto"></ColumnDefinition>
-                </Grid.ColumnDefinitions>
-
-                <!--左侧工具栏-->
-                <StackPanel Orientation="Horizontal" Height="40" Margin="20,0,0,0">
+                    <!--左侧工具栏-->
+                    <StackPanel Orientation="Horizontal" Height="40" Margin="20,0,0,0">
 
-                    <!--打开文件-->
-                    <Button BorderThickness="0" VerticalContentAlignment="Center" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="OpenFile_Click">
-                        <Button.Content>
-                            <Viewbox Width="20" Height="20">
-                                <Path Fill="#43474D" >
-                                    <Path.Data>
-                                        M3.75,2 L3.91967773,2.00463867 C4.08325195,2.01391602 4.22851562,2.03710938 4.35546875,2.07421875 C4.52473958,2.12369792 
+                        <!--打开文件-->
+                        <Button BorderThickness="0" VerticalContentAlignment="Center" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="OpenFile_Click">
+                            <Button.Content>
+                                <Viewbox Width="20" Height="20">
+                                    <Path Fill="#43474D" >
+                                        <Path.Data>
+                                            M3.75,2 L3.91967773,2.00463867 C4.08325195,2.01391602 4.22851562,2.03710938 4.35546875,2.07421875 C4.52473958,2.12369792 
                                     4.67578125,2.18489583 4.80859375,2.2578125 C4.94140625,2.33072917 5.05989583,2.41145833 5.1640625,2.5 C5.26822917,2.58854167 
                                     5.37369792,2.66927083 5.48046875,2.7421875 C5.58723958,2.81510417 5.70182292,2.87630208 5.82421875,2.92578125 C5.94661458,2.97526042 
                                     6.08854167,3 6.25,3 L6.25,3 L12,3 L12.1371528,3.00868056 C12.2262731,3.02025463 12.3107639,3.04340278 12.390625,3.078125 
@@ -54,46 +53,46 @@
                                     L4.3125,6 L12,6 L12,4 L6.25,4 L6.08032227,3.99536133 C5.91674805,3.98608398 5.77148438,3.96289062 5.64453125,3.92578125 C5.47526042,3.87630208 
                                     5.32421875,3.81510417 5.19140625,3.7421875 C5.05859375,3.66927083 4.94010417,3.58854167 4.8359375,3.5 C4.73177083,3.41145833 4.62630208,3.33072917 
                                     4.51953125,3.2578125 C4.41276042,3.18489583 4.29817708,3.12369792 4.17578125,3.07421875 C4.05338542,3.02473958 3.91145833,3 3.75,3 L3.75,3 Z
-                                    </Path.Data>
-                                </Path>
-                            </Viewbox>
-                        </Button.Content>
-                    </Button>
-                    
-                    <!--保存文件-->
-                    <Button BorderThickness="0" VerticalContentAlignment="Center" Margin="10,0,0,0" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" 
+                                        </Path.Data>
+                                    </Path>
+                                </Viewbox>
+                            </Button.Content>
+                        </Button>
+
+                        <!--保存文件-->
+                        <Button BorderThickness="0" VerticalContentAlignment="Center" Margin="10,0,0,0" Width="30" Height="30" Style="{StaticResource LightButtonStyle}" Background="Transparent" 
                             Click="SaveFileBtn_Click">
-                        <Button.Content>
-                            <Viewbox Width="20" Height="20">
-                                <Path Fill="#43474D" >
-                                    <Path.Data>
-                                        M11.707107,1 L15,4.29289322 L15,15 L1,15 L1,1 L11.707107,1 Z M11.293,2 L2,2 L2,14 L4,14 L4,8 L12,8 L12,14 L14,14 L14,4.707 L11.293,2 Z 
+                            <Button.Content>
+                                <Viewbox Width="20" Height="20">
+                                    <Path Fill="#43474D" >
+                                        <Path.Data>
+                                            M11.707107,1 L15,4.29289322 L15,15 L1,15 L1,1 L11.707107,1 Z M11.293,2 L2,2 L2,14 L4,14 L4,8 L12,8 L12,14 L14,14 L14,4.707 L11.293,2 Z 
                                         M11,9 L5,9 L5,14 L11,14 L11,9 Z M7,5 L7,6 L4,6 L4,5 L7,5 Z
+                                        </Path.Data>
+                                    </Path>
+                                </Viewbox>
+                            </Button.Content>
+                        </Button>
+
+                        <!--工具栏展开收缩-->
+                        <ToggleButton Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ToolExpand_Click">
+                            <ToggleButton.Content>
+                                <Path Fill="#43474D" Width="30" Height="30">
+                                    <Path.Data>
+                                        M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
                                     </Path.Data>
                                 </Path>
-                            </Viewbox>
-                        </Button.Content>
-                    </Button>
-                    
-                    <!--工具栏展开收缩-->
-                    <ToggleButton Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ToolExpand_Click">
-                        <ToggleButton.Content>
-                            <Path Fill="#43474D" Width="30" Height="30">
-                                <Path.Data>
-                                    M22.5 8.5H7.5V12.25H13H22.5V8.5ZM12.25 13.75H7.5V21.5H12.25V13.75ZM13.75 21.5V13.75H22.5V21.5H13.75ZM7.5 7H6V8.5V21.5V23H7.5H22.5H24V21.5V8.5V7H22.5H7.5Z
-                                </Path.Data>
-                            </Path>
-                        </ToggleButton.Content>
-                    </ToggleButton>
-
-                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
-                    
-                    <!--抓手工具-->
-                    <ToggleButton BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="True" IsEnabled="False" Visibility="Collapsed">
-                        <ToggleButton.Content>
-                            <Path Fill="#43474D">
-                                <Path.Data>
-                                    M8.7463 7.94055L8.43134 3.20358C8.38986 2.6073 8.82031 2.08322 9.40947 2.01273L9.46546 2.00656C9.75502 1.97416 10.0451 2.06271 10.2681 2.25159C10.4911 
+                            </ToggleButton.Content>
+                        </ToggleButton>
+
+                        <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
+
+                        <!--抓手工具-->
+                        <ToggleButton BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="True" IsEnabled="False" Visibility="Collapsed">
+                            <ToggleButton.Content>
+                                <Path Fill="#43474D">
+                                    <Path.Data>
+                                        M8.7463 7.94055L8.43134 3.20358C8.38986 2.6073 8.82031 2.08322 9.40947 2.01273L9.46546 2.00656C9.75502 1.97416 10.0451 2.06271 10.2681 2.25159C10.4911 
                                 2.44047 10.6276 2.71317 10.6457 3.00614L10.9886 8.17061C10.999 8.31659 11.1097 8.43516 11.2537 8.45444C11.3176 8.46288 11.382 8.44409 11.4315 
                                 8.40258C11.481 8.36108 11.5111 8.30063 11.5145 8.23584L11.7612 3.47595C11.7918 2.85998 12.3116 2.38523 12.923 2.41468H12.9309C13.5429 2.44972 
                                 14.0111 2.97745 13.9773 3.59407L13.7218 8.51438C13.7137 8.66679 13.8235 8.79975 13.9738 8.81936C14.1225 8.83876 14.2625 8.73915 14.2914 
@@ -104,104 +103,102 @@
                                 11.8234 5.94227 12.324 6.07526 12.2324C6.27386 12.0949 6.12075 11.7176 5.85478 9.21249C5.67578 7.53039 5.45319 5.85328 5.18724 4.18289C5.07653 3.5968 
                                 5.44002 3.02581 6.01489 2.88273L6.07526 2.86775C6.35866 2.79957 6.65742 2.85178 6.90147 3.01215C7.14552 3.17252 7.3134 3.42693 7.36572 3.71571L8.168 
                                 8.02341C8.19642 8.17613 8.33897 8.27937 8.49171 8.25787C8.64561 8.23564 8.75656 8.09774 8.7463 7.94143V7.94055Z
-                                </Path.Data>
-                            </Path>
-                        </ToggleButton.Content>
-                    </ToggleButton>
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
 
-                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
+                        <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
 
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
+                        <Grid>
+                            <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
                               SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
+                            </ComboBox>
+                            <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
                              IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
-
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
+                            <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
                                 <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
+                                    M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
                                 </Path.Data>
                             </Path>
-                        </Button.Content>
-                    </Button>
+                        </Grid>
 
-                </StackPanel>
+                        <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
+                            <Button.Content>
+                                <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
+                            </Button.Content>
+                        </Button>
 
-                <!--中间工具栏-->
-                <ComboBox Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E">
-                    <ComboBoxItem IsSelected="True">Viewer</ComboBoxItem>
-                </ComboBox>
+                        <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
+                            <Button.Content>
+                                <Path Fill="#0E1114">
+                                    <Path.Data>
+                                        M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
+                                    </Path.Data>
+                                </Path>
+                            </Button.Content>
+                        </Button>
 
-                <!--右侧工具栏-->
-                <StackPanel Orientation="Horizontal" Grid.Column="2">
+                    </StackPanel>
 
-                    <!--搜索按钮-->
-                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="ExpandSearchBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#43474D">
-                                <Path.Data>
-                                    M5.10992 13.9353C2.71184 11.5372 2.71184 7.64917 5.10992 5.25108C7.50801 2.853 11.3961 2.853 13.7942 5.25108C16.1922 7.64917 
+                    <!--中间工具栏-->
+                    <ComboBox Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E">
+                        <ComboBoxItem IsSelected="True">Viewer</ComboBoxItem>
+                    </ComboBox>
+
+                    <!--右侧工具栏-->
+                    <StackPanel Orientation="Horizontal" Grid.Column="2">
+
+                        <!--搜索按钮-->
+                        <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="ExpandSearchBtn_Click">
+                            <Button.Content>
+                                <Path Fill="#43474D">
+                                    <Path.Data>
+                                        M5.10992 13.9353C2.71184 11.5372 2.71184 7.64917 5.10992 5.25108C7.50801 2.853 11.3961 2.853 13.7942 5.25108C16.1922 7.64917 
                                 16.1922 11.5372 13.7942 13.9353C11.3961 16.3334 7.50801 16.3334 5.10992 13.9353ZM4.04926 4.19042C1.06539 7.17429 1.06539 12.0121 
                                 4.04926 14.996C6.85422 17.8009 11.2975 17.9691 14.2989 15.5005L17.1989 18.4006C17.4918 18.6935 17.9667 18.6935 18.2596 
                                 18.4006C18.5525 18.1077 18.5525 17.6328 18.2596 17.3399L15.3595 14.4399C17.828 11.4384 17.6597 6.99533 14.8548 
                                 4.19042C11.8709 1.20655 7.03313 1.20655 4.04926 4.19042Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
+                                    </Path.Data>
+                                </Path>
+                            </Button.Content>
+                        </Button>
 
-                    <!--页面显示-->
-                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
-                        <ToggleButton.Content>
-                            <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
-                                <Path.Data>
-                                    <CombinedGeometry GeometryCombineMode="Exclude">
-                                        <CombinedGeometry.Geometry1>
-                                            M18.3327 10C18.3327 10 14.6017 16.25 9.99935 16.25C5.39698 16.25 1.66602 10 1.66602 10C1.66602 10 5.39698 3.75 9.99935 3.75C14.6017 3.75 18.3327 10 18.3327 10Z
-                                        </CombinedGeometry.Geometry1>
-                                        <CombinedGeometry.Geometry2>
-                                            <EllipseGeometry Center="10,10" RadiusX="2" RadiusY="2"/>
-                                        </CombinedGeometry.Geometry2>
-                                    </CombinedGeometry>
-                                </Path.Data>
-                            </Path>
-                        </ToggleButton.Content>
-                    </ToggleButton>
+                        <!--页面显示-->
+                        <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                            <ToggleButton.Content>
+                                <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
+                                    <Path.Data>
+                                        <CombinedGeometry GeometryCombineMode="Exclude">
+                                            <CombinedGeometry.Geometry1>
+                                                M18.3327 10C18.3327 10 14.6017 16.25 9.99935 16.25C5.39698 16.25 1.66602 10 1.66602 10C1.66602 10 5.39698 3.75 9.99935 3.75C14.6017 3.75 18.3327 10 18.3327 10Z
+                                            </CombinedGeometry.Geometry1>
+                                            <CombinedGeometry.Geometry2>
+                                                <EllipseGeometry Center="10,10" RadiusX="2" RadiusY="2"/>
+                                            </CombinedGeometry.Geometry2>
+                                        </CombinedGeometry>
+                                    </Path.Data>
+                                </Path>
+                            </ToggleButton.Content>
+                        </ToggleButton>
 
-                    <!--页面信息-->
-                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="PageInfoBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#43474D" VerticalAlignment="Center">
-                                <Path.Data>
-                                    M2.75 10C2.75 5.99594 5.99594 2.75 10 2.75C14.0041 2.75 17.25 5.99594 17.25 10C17.25 14.0041 14.0041 17.25 10 
+                        <!--页面信息-->
+                        <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="PageInfoBtn_Click">
+                            <Button.Content>
+                                <Path Fill="#43474D" VerticalAlignment="Center">
+                                    <Path.Data>
+                                        M2.75 10C2.75 5.99594 5.99594 2.75 10 2.75C14.0041 2.75 17.25 5.99594 17.25 10C17.25 14.0041 14.0041 17.25 10 
                                 17.25C5.99594 17.25 2.75 14.0041 2.75 10ZM10 1.25C5.16751 1.25 1.25 5.16751 1.25 10C1.25 14.8325 5.16751 
                                 18.75 10 18.75C14.8325 18.75 18.75 14.8325 18.75 10C18.75 5.16751 14.8325 1.25 10 1.25ZM6.5 11C7.05228 11 
                                 7.5 10.5523 7.5 10C7.5 9.44771 7.05228 9 6.5 9C5.94772 9 5.5 9.44771 5.5 10C5.5 10.5523 5.94772 11 6.5 11ZM10 
                                 11C10.5523 11 11 10.5523 11 10C11 9.44771 10.5523 9 10 9C9.44771 9 9 9.44771 9 10C9 10.5523 9.44771 11 10 11ZM14.5 
                                 10C14.5 10.5523 14.0523 11 13.5 11C12.9477 11 12.5 10.5523 12.5 10C12.5 9.44771 12.9477 9 13.5 9C14.0523 9 14.5 9.44771 14.5 10Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
-                </StackPanel>
-
-            </Grid>
-
+                                    </Path.Data>
+                                </Path>
+                            </Button.Content>
+                        </Button>
+                    </StackPanel>
+                </Grid>
             <Grid Name="BodyGrid" Grid.Row="1">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="0"></ColumnDefinition>
@@ -218,7 +215,6 @@
                     </Grid.RowDefinitions>
 
                     <StackPanel Name="BotaSideTool" Background="{StaticResource color.bg.jumpbar}" Orientation="Horizontal">
-
                         <!--缩略图-->
                         <ToggleButton Name="ThumbToolButton"  Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="ThumbToolButton_Click" >
                             <ToggleButton.Content>
@@ -252,7 +248,6 @@
                                 </Path>
                             </ToggleButton.Content>
                         </ToggleButton>
-
                         <!--文字搜索-->
                         <ToggleButton Name="SearchToolButton" Height="40" Width="65" BorderThickness="0"  Style="{StaticResource ToggleButtonStyle}" Click="SearchToolButton_Click">
                             <ToggleButton.Content>
@@ -266,11 +261,8 @@
                                 </Path>
                             </ToggleButton.Content>
                         </ToggleButton>
-
                     </StackPanel>
-
                     <Border Grid.Row="1" Name="BotaToolContainer">
-
                     </Border>
                 </Grid>
 
@@ -345,7 +337,7 @@
 
         <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
             <Grid>
-                
+
                 <!--文件信息-->
                 <Grid Name="FileInfoUI"  Width="422" Height="680" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White" Visibility="Collapsed">
                     <Grid.ColumnDefinitions>
@@ -369,7 +361,7 @@
                     </Button>
                     <cpdftools:CPDFInfoControl Grid.Row="1" Margin="25,10,25,0" Grid.ColumnSpan="2" Name="FileInfoControl"></cpdftools:CPDFInfoControl>
                 </Grid>
-                
+
                 <!--密码验证-->
                 <local:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></local:PasswordDialog>
             </Grid>

+ 112 - 0
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml.cs

@@ -2,6 +2,8 @@
 using compdfkit_tools.Helper;
 using compdfkit_tools.PDFControl;
 using compdfkit_tools.PDFControlUI;
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using System;
@@ -55,6 +57,8 @@ namespace viewer_ctrl_demo
             PDFGrid.Child = pdfViewControl;
             pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
             pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
+            pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
+            pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
@@ -82,6 +86,114 @@ namespace viewer_ctrl_demo
 
         }
 
+        private void PDFView_AnnotCommandHandler(object sender,AnnotCommandArgs e)
+        {
+            if (e != null && e.CommandType == CommandType.Context)
+            {
+                e.Handle = true;
+                e.PopupMenu = new ContextMenu();
+
+                MenuItem fitWidthMenu = new MenuItem();
+                fitWidthMenu.Header = "Fit Width";
+                fitWidthMenu.Click += (o, p) =>
+                {
+                    if(pdfViewControl!=null)
+                    {
+                        pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(fitWidthMenu);
+
+                MenuItem fitSizeMenu = new MenuItem();
+                fitSizeMenu.Header = "Actual Size";
+                fitSizeMenu.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(fitSizeMenu);
+
+                MenuItem zoomInMenu = new MenuItem();
+                zoomInMenu.Header = "Zoom In";
+                zoomInMenu.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
+                        pdfViewControl.PDFView?.Zoom(newZoom);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(zoomInMenu);
+
+                MenuItem zoomOutMenu = new MenuItem();
+                zoomOutMenu.Header = "Zoom Out";
+                zoomOutMenu.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
+                        pdfViewControl.PDFView?.Zoom(newZoom);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(zoomOutMenu);
+                e.PopupMenu.Items.Add(new Separator());
+
+                MenuItem singleView = new MenuItem();
+                singleView.Header = "Single Page";
+                singleView.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(singleView);
+
+                MenuItem singleContinuousView = new MenuItem();
+                singleContinuousView.Header = "Single Continuous Page";
+                singleContinuousView.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(singleContinuousView);
+
+                MenuItem doubleView = new MenuItem();
+                doubleView.Header = "Double Page";
+                doubleView.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(doubleView);
+
+                MenuItem doubleContinuousView = new MenuItem();
+                doubleContinuousView.Header = "Double Continuous Page";
+                doubleContinuousView.Click += (o, p) =>
+                {
+                    if (pdfViewControl != null)
+                    {
+                        pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
+                    }
+                };
+
+                e.PopupMenu.Items.Add(doubleContinuousView);
+            }
+        }
+
         private void PasswordUI_Confirmed(object sender, string e)
         {
             if(passwordViewer!=null && passwordViewer.PDFView!=null && passwordViewer.PDFView.Document!=null)