Bläddra i källkod

其他 - 部分注释的选中修改参数功能

zhuyi 1 år sedan
förälder
incheckning
12fe3ffa46

+ 150 - 74
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -19,6 +19,8 @@ using ComPDFKit.Tool.Help;
 using ComPDFKit.Tool.SettingParam;
 using ComPDFKit.Import;
 using ComPDFKitViewer.BaseObject;
+using ComPDFKitViewer.Widget;
+using ComPDFKit.PDFDocument;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -208,6 +210,7 @@ namespace Compdfkit_Tools.PDFControl
 
             CPDFAnnotationType annotationType = pdfAnnotationData.AnnotationType;
             AnnotParam annotHandlerEventArgs = null;
+            pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
             switch (annotationType)
             {
                 case CPDFAnnotationType.Highlight:
@@ -659,7 +662,7 @@ namespace Compdfkit_Tools.PDFControl
                         pdfLinkUI = new CPDFLinkUI();
                     }
                     LinkParam linkAnnotArgs = new LinkParam();
-                    if (this.pdfViewerControl != null&& pdfViewerControl.PDFViewTool!=null && pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument() != null)
+                    if (this.pdfViewerControl != null && pdfViewerControl.PDFViewTool != null && pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument() != null)
                     {
                         pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
                         pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINK);
@@ -779,77 +782,150 @@ namespace Compdfkit_Tools.PDFControl
 
         public void CreatTempAnnotationPanel(BaseAnnot baseAnnot)
         {
-            //switch (baseAnnot.CurrentType)
-            //{
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
-            //        tempAnnotationPanel = new CPDFMarkupUI();
-            //        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Highlight);
-            //        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
-            //        tempAnnotationPanel = new CPDFMarkupUI();
-            //        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Underline);
-            //        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
-            //        tempAnnotationPanel = new CPDFMarkupUI();
-            //        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Strikeout);
-            //        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
-            //        tempAnnotationPanel = new CPDFMarkupUI();
-            //        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Squiggly);
-            //        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
-            //        tempAnnotationPanel = new CPDFShapeUI();
-            //        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Square);
-            //        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
-            //        tempAnnotationPanel = new CPDFShapeUI();
-            //        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Circle);
-            //        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
-            //        tempAnnotationPanel = new CPDFShapeUI();
-            //        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Line);
-            //        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
-            //        CPDFFreehandUI tempFreehandPanel = new CPDFFreehandUI();
-            //        tempFreehandPanel.SetPresentAnnotAttrib(annotAttribEvent);
-            //        tempFreehandPanel.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
-            //        tempFreehandPanel.EraseChangeHandler += PdfFreehandUI_EraseChangeHandler;
-            //        tempAnnotationPanel = tempFreehandPanel;
-            //        break;
-
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
-            //        tempAnnotationPanel = new CPDFFreeTextUI();
-            //        (tempAnnotationPanel as CPDFFreeTextUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
-            //        tempAnnotationPanel = new CPDFNoteUI();
-            //        (tempAnnotationPanel as CPDFNoteUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
-            //        tempAnnotationPanel = new CPDFTempStampUI();
-            //        (tempAnnotationPanel as CPDFTempStampUI).SetPresentAnnotAttrib(annotAttribEvent);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
-            //        tempAnnotationPanel = new CPDFLinkUI();
-            //        (tempAnnotationPanel as CPDFLinkUI).SetPresentAnnotAttrib(annotAttribEvent, pdfViewerControl.Document.PageCount);
-            //        break;
-            //    case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
-            //        tempAnnotationPanel = null;
-            //        break;
-            //    default:
-            //        break;
-            //}
+            switch (baseAnnot.CurrentType)
+            {
+                case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
+                    {
+                        tempAnnotationPanel = new CPDFMarkupUI();
+                        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Highlight);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot as CPDFMarkupAnnotation, pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
+                    {
+                        tempAnnotationPanel = new CPDFMarkupUI();
+                        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Underline);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot as CPDFMarkupAnnotation, pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
+                    {
+                        tempAnnotationPanel = new CPDFMarkupUI();
+                        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Strikeout);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot as CPDFMarkupAnnotation, pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
+                    {
+                        tempAnnotationPanel = new CPDFMarkupUI();
+                        (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Squiggly);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot as CPDFMarkupAnnotation, pdfViewerControl);
+                    }
+                    break;
+
+                case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
+                    {
+                        tempAnnotationPanel = new CPDFShapeUI();
+                        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Square);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot, pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
+                    {
+                        tempAnnotationPanel = new CPDFShapeUI();
+                        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Circle);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot, pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
+                    {
+                        tempAnnotationPanel = new CPDFShapeUI();
+                        (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Line);
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot, pdfViewerControl);
+                    }
+                    break;
+
+                case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
+                    {
+
+                        CPDFFreehandUI tempFreehandPanel = new CPDFFreehandUI();
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        tempFreehandPanel.SetPresentAnnotAttrib(annotParam, baseAnnot.GetAnnotData().Annot, pdfViewerControl.PDFToolManager.GetDocument(), pdfViewerControl);
+                        tempFreehandPanel.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
+                        tempFreehandPanel.EraseChangeHandler += PdfFreehandUI_EraseChangeHandler;
+                        tempAnnotationPanel = tempFreehandPanel;
+                    }
+                    break;
+
+                case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
+                    {
+                        tempAnnotationPanel = new CPDFFreeTextUI();
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFFreeTextUI).SetPresentAnnotAttrib(annotParam as FreeTextParam, baseAnnot.GetAnnotData().Annot as CPDFFreeTextAnnotation, pdfViewerControl);
+                    }
+                    break;
+
+                case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
+                    {
+                        tempAnnotationPanel = new CPDFNoteUI();
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFNoteUI).SetPresentAnnotAttrib(annotParam as StickyNoteParam, baseAnnot.GetAnnotData().Annot as CPDFTextAnnotation, pdfViewerControl);
+                    }
+                    break;
+
+                case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
+                    {
+                        tempAnnotationPanel = new CPDFTempStampUI();
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFTempStampUI).SetPresentAnnotAttrib(annotParam as StampParam , baseAnnot.GetAnnotData().Annot as CPDFStampAnnotation , pdfViewerControl.PDFToolManager.GetDocument(), pdfViewerControl);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
+                    {
+                        tempAnnotationPanel = new CPDFLinkUI();
+                        AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
+                                                               pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(),
+                                                               baseAnnot.GetAnnotData().PageIndex,
+                                                               baseAnnot.GetAnnotData().Annot);
+                        (tempAnnotationPanel as CPDFLinkUI).SetPresentAnnotAttrib(annotParam as LinkParam, baseAnnot.GetAnnotData().Annot as CPDFLinkAnnotation, pdfViewerControl, pdfViewerControl.PDFToolManager.GetDocument().PageCount);
+                    }
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
+                    tempAnnotationPanel = null;
+                    break;
+                default:
+                    break;
+            }
         }
 
         public void LoadAnnotationPanel(CPDFAnnotationType annotationType)
@@ -906,7 +982,7 @@ namespace Compdfkit_Tools.PDFControl
 
         private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
         {
-            SetAnnotEventData(); 
+            SetAnnotEventData();
         }
 
         public void ClearPanel()
@@ -920,7 +996,7 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (pdfViewerControl.PDFToolManager != null)
             {
-                if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot()==null && isTempPanel)
+                if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot() == null && isTempPanel)
                 {
                     ShowCurrentAnnotPanel();
                     isTempPanel = false;

+ 48 - 28
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -373,19 +373,27 @@ namespace Compdfkit_Tools.PDFControlUI
                 if(param is SquareParam)
                 {
                     SquareParam squareParam= (SquareParam)param;
-                    BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
-                        squareParam.LineColor[0],
-                        squareParam.LineColor[1],
-                        squareParam.LineColor[2]));
                     CPDFThicknessControl.Thickness = (int)squareParam.LineWidth;
-                    BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
+
+                    if (squareParam.LineColor != null)
+                    {
+                        BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
+                            squareParam.LineColor[0],
+                            squareParam.LineColor[1],
+                            squareParam.LineColor[2]));
+                        BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
                         squareParam.LineColor[0],
                         squareParam.LineColor[1],
                         squareParam.LineColor[2]));
-                    FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
-                       squareParam.BgColor[0],
-                       squareParam.BgColor[1],
-                       squareParam.BgColor[2]));
+                    }
+
+                    if (squareParam.BgColor!=null)
+                    {
+                        FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
+                           squareParam.BgColor[0],
+                           squareParam.BgColor[1],
+                           squareParam.BgColor[2]));
+                    }
                     if (squareParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
                     {
                         CPDFLineStyleControl.DashStyle = DashStyles.Solid;
@@ -399,19 +407,25 @@ namespace Compdfkit_Tools.PDFControlUI
                 if(param is CircleParam)
                 {
                     CircleParam circleParam= (CircleParam)param;
-                    BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
-                       circleParam.LineColor[0],
-                       circleParam.LineColor[1],
-                       circleParam.LineColor[2]));
                     CPDFThicknessControl.Thickness = (int)circleParam.LineWidth;
-                    BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
-                       circleParam.LineColor[0],
-                       circleParam.LineColor[1],
-                       circleParam.LineColor[2]));
-                    FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
-                       circleParam.BgColor[0],
-                       circleParam.BgColor[1],
-                       circleParam.BgColor[2]));
+                    if (circleParam.LineColor != null)
+                    {
+                        BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
+                           circleParam.LineColor[0],
+                           circleParam.LineColor[1],
+                           circleParam.LineColor[2]));
+                        BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
+                           circleParam.LineColor[0],
+                           circleParam.LineColor[1],
+                           circleParam.LineColor[2]));
+                    }
+                    if (circleParam.BgColor!=null)
+                    {
+                        FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
+                           circleParam.BgColor[0],
+                           circleParam.BgColor[1],
+                           circleParam.BgColor[2]));
+                    }
                     if (circleParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
                     {
                         CPDFLineStyleControl.DashStyle = DashStyles.Solid;
@@ -425,20 +439,26 @@ namespace Compdfkit_Tools.PDFControlUI
                 if(param is LineParam)
                 {
                     LineParam lineParam= (LineParam)param;
-                    BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
-                      lineParam.LineColor[0],
-                      lineParam.LineColor[1],
-                      lineParam.LineColor[2]));
                     CPDFThicknessControl.Thickness = (int)lineParam.LineWidth;
-                    BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
+
+                    if (lineParam.LineColor != null)
+                    {
+                        BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
+                          lineParam.LineColor[0],
+                          lineParam.LineColor[1],
+                          lineParam.LineColor[2]));
+                        BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
                        lineParam.LineColor[0],
                        lineParam.LineColor[1],
                        lineParam.LineColor[2]));
-                    FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
+                    }
+                    if (lineParam.BgColor != null)
+                    {
+                        FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
                        lineParam.BgColor[0],
                        lineParam.BgColor[1],
                        lineParam.BgColor[2]));
-
+                    }
                     if(lineParam.BorderStyle==C_BORDER_STYLE.BS_SOLID)
                     {
                         CPDFLineStyleControl.DashStyle = DashStyles.Solid;