Просмотр исходного кода

ComPDFKit(win) - 已签名不弹出电子签名 折叠时设置注释属性面板

weixiangjie 7 месяцев назад
Родитель
Сommit
60dc1d021b

+ 1 - 3
Demo/Examples/Compdfkit_Tools/Annotation/AnnotationControl/AnnotationControl.xaml.cs

@@ -357,9 +357,7 @@ baseWidget.GetAnnotData().Annot);
 
         public void UnloadEvent()
         {
-            //PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
-            //PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
-            //panelState.PropertyChanged -= PanelState_PropertyChanged;
+            PDFAnnotationControl.UnLoadPDFViewHandler();
         }
 
         private void PdfAnnotationControl_ClearAnnotationBar(object sender, EventArgs e)

+ 1 - 99
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -76,9 +76,6 @@ namespace Compdfkit_Tools.PDFControl
                 pdfViewerControl.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
                 pdfViewerControl.MouseLeftButtonUpHandler -= PdfViewerControl_MouseLeftButtonUpHandler;
                 pdfViewerControl.MouseLeftButtonUpHandler += PdfViewerControl_MouseLeftButtonUpHandler;
-                //this.pdfViewerControl.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
-                //this.pdfViewerControl.AnnotEditHandler -= PdfViewer_AnnotEditHandler;
-                //this.pdfViewerControl.AnnotEditHandler += PdfViewer_AnnotEditHandler;
                 pdfViewerControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
                 pdfViewerControl.MouseRightButtonDownHandler += PDFViewControl_MouseRightButtonDownHandler;
             }
@@ -103,45 +100,6 @@ namespace Compdfkit_Tools.PDFControl
             }
         }
 
-
-        //private void PdfViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
-        //{
-        //    if (e != null && e.Count > 0)
-        //    {
-        //        if (e[0].EditAction == ActionType.Del)
-        //        {
-        //            if (pdfViewerControl.MouseMode == MouseModes.AnnotCreate && pdfViewerControl.ToolManager.CurrentAnnotArgs is EraseArgs)
-        //            {
-        //                return;
-        //            }
-        //            SetAnnotEventData(null);
-        //        }
-
-        //        if (e[0].EditAction == ActionType.Modify && e[0].EditAnnotArgs != null && e[0].EditAnnotArgs.EventType == AnnotArgsType.AnnotSticky)
-        //        {
-        //            CPDFNoteUI tempUI = annotationPanel as CPDFNoteUI;
-        //            if (tempUI == null || tempUI.annotAttribEvent == null)
-        //            {
-        //                tempUI = tempAnnotationPanel as CPDFNoteUI;
-        //            }
-        //            if (tempUI == null || tempUI.annotAttribEvent == null)
-        //            {
-        //                tempUI = pdfNoteUI;
-        //            }
-        //            if (tempUI != null && tempUI.annotAttribEvent != null)
-        //            {
-        //                AnnotAttribEvent oldEvent = tempUI.annotAttribEvent;
-        //                oldEvent.Attribs[AnnotAttrib.NoteText] = e[0].EditAnnotArgs.Content;
-        //                tempUI.SetPresentAnnotAttrib(oldEvent);
-        //            }
-        //        }
-        //        if (e[0].EditAction == ActionType.Add && e[0].EditAnnotArgs.EventType == AnnotArgsType.AnnotStamp)
-        //        {
-        //            pdfViewerControl.SetMouseMode(MouseModes.PanTool);
-        //        }
-        //    }
-        //}
-
         public void UnLoadPDFViewHandler()
         {
             if (this.pdfViewerControl != null)
@@ -157,7 +115,7 @@ namespace Compdfkit_Tools.PDFControl
 
         private void AnnotationControl_Unloaded(object sender, RoutedEventArgs e)
         {
-            UnLoadPDFViewHandler();
+            // UnLoadPDFViewHandler();
         }
 
         private UIElement GetAnnotationPanel()
@@ -980,62 +938,6 @@ namespace Compdfkit_Tools.PDFControl
                 pdfViewerControl.SetToolType(ToolType.CreateAnnot);
                 pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
             }
-            //if (pdfViewerControl != null)
-            //{
-            //    CPDFFreehandUI freehandUI = sender as CPDFFreehandUI;
-            //    if (e)
-            //    {
-            //        annotArgs = pdfViewerControl.ToolManager.CurrentAnnotArgs;
-            //        eraseArgs = new EraseArgs();
-            //        eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
-            //        eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
-
-            //        if (freehandUI != null)
-            //        {
-            //            eraseArgs.Thickness = freehandUI.GetEraseThickness();
-            //        }
-            //        else
-            //        {
-            //            eraseArgs.Thickness = 1;
-            //        }
-
-            //        disableClean = true;
-            //        pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
-            //        pdfViewerControl.SetToolParam(eraseArgs);
-            //        disableClean = false;
-            //        EmptyMessage.Visibility = Visibility.Collapsed;
-            //    }
-            //    else
-            //    {
-            //        pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
-            //        FreehandAnnotArgs freehandAnnotArgs = annotArgs as FreehandAnnotArgs;
-            //        if (freehandAnnotArgs == null)
-            //        {
-            //            freehandAnnotArgs = new FreehandAnnotArgs();
-
-            //            freehandAnnotArgs.InkColor = Colors.Red;
-            //            freehandAnnotArgs.Transparency = 1;
-            //            freehandAnnotArgs.LineWidth = 1;
-            //            annotArgs = freehandAnnotArgs;
-            //        }
-
-            //        if (freehandUI != null)
-            //        {
-            //            freehandUI.PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
-            //            Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
-            //            attribDict[AnnotAttrib.Color] = freehandAnnotArgs.InkColor;
-            //            attribDict[AnnotAttrib.Transparency] = freehandAnnotArgs.Transparency;
-            //            attribDict[AnnotAttrib.Thickness] = freehandAnnotArgs.LineWidth;
-            //            attribDict[AnnotAttrib.NoteText] = freehandAnnotArgs.Content;
-
-            //            AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(freehandAnnotArgs, attribDict);
-            //            freehandUI.SetPresentAnnotAttrib(annotEvent);
-            //            freehandUI.PropertyChanged += CPDFAnnotationControl_PropertyChanged;
-            //            freehandUI.ClearAnnotAttribEvent();
-            //        }
-            //        pdfViewerControl.SetToolParam(freehandAnnotArgs);
-            //    }
-            //}
         }
 
         public void CreatTempAnnotationPanel(BaseAnnot baseAnnot)

+ 10 - 0
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -216,6 +216,16 @@ namespace PDFViewer
                     baseWidget.GetAnnotData().Annot);
                     if ((annotParam as WidgetParm).WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
                     {
+                        var sigWidget = baseWidget.GetAnnotData().Annot as CPDFSignatureWidget;
+                        if(sigWidget == null)
+                        {
+                            return;
+                        }
+                        var sig = sigWidget.GetSignature(viewControl.GetCPDFViewer().GetDocument());
+                        if (sigWidget.IsSigned() && sig != null && sig.SignerList.Count > 0)
+                        {
+                            return;
+                        }
                         if (currentMode == "Annotation")
                         {
                             CPDFSignatureUI signatureProperty = new CPDFSignatureUI();