Explorar el Código

注释 - 签名区分图章和手绘

chenrongqian@kdanmobile.com hace 1 año
padre
commit
31cee2c3a9

+ 64 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -292,6 +292,59 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
+        private void SelectedSignature(List<AnnotHandlerEventArgs> annotlist)
+        {
+            if (annotlist == null || annotlist.Count == 0)
+                return;
+
+            var annot = annotlist[0];
+
+            if (annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand)
+                return;
+            if (annot.PageIndex < 0 || annot.AnnotIndex < 0)
+                return;
+
+
+            var signAnnot = AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
+            if (signAnnot == null)
+            {
+                if (annot.EventType == AnnotArgsType.AnnotStamp)
+                {
+                    GetStamp();
+                    StrAnnotToolChecked = "Stamp";
+                }
+                else
+                {
+                    GetFreehand();
+                    StrAnnotToolChecked = "";
+                }
+            }
+            else
+            {
+                GetSignature();
+                StrAnnotToolChecked = "Signature";
+            }
+
+        }
+
+        private void AddAnnotSignature(AnnotHandlerEventArgs annot)
+        {
+            if ((annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand) ||
+            (annot.PageIndex < 0 || annot.AnnotIndex < 0)) return;
+
+            if (StrAnnotToolChecked == "Signature")
+            {
+                if (AnnotSignatures == null)
+                    AnnotSignatures = new List<Tuple<int, int>>();
+
+                var signAnnot = AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
+                if (signAnnot == null)
+                {
+                    AnnotSignatures.Add(new Tuple<int, int>(annot.PageIndex, annot.AnnotIndex));
+                }
+            }
+        }
+
         #endregion 与触发事件调用相关的函数
 
         #region PDFViewer事件
@@ -310,6 +363,7 @@ namespace PDF_Office.ViewModels.Tools
                         if (e.IsAnnotCreateReset == false)
                         {
                             GetSelectedAnnots(e);
+                            SelectedSignature(e.AnnotItemsList);
                             CurrentSelectedAnnot = annot;
                         }
                         else
@@ -808,9 +862,18 @@ namespace PDF_Office.ViewModels.Tools
                                )
                             {
                                 PDFViewer.ClearSelectAnnots();
-                                PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
+                                if (StrAnnotToolChecked != "Signature")
+                                {
+                                    PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
+                                }
+                                else
+                                {
+                                    AddAnnotSignature(annot);
+                                    PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
+                                } 
                             }
 
+                            
                             break;
 
                         case ActionType.Del:

+ 15 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -246,6 +246,7 @@ namespace PDF_Office.ViewModels.Tools
                         return;
                     }
                     annotArgs = GetStamp();
+
                     break;
 
                 case "Image":
@@ -634,6 +635,20 @@ namespace PDF_Office.ViewModels.Tools
             return false;
         }
 
+        private void FromFillAndSign(FillAndSigntEventArgs obj)
+        {
+            if (obj != null)
+            {
+                if (string.IsNullOrEmpty(obj.Unicode) == false)
+                {
+                    if (obj.Unicode == "Clear")
+                    {
+                        AnnotSignatures.Clear();
+                    }
+                }
+            }
+        }
+
         /// <summary>
         /// 便签
         /// </summary>

+ 2 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -279,8 +279,9 @@ namespace PDF_Office.ViewModels.Tools
         private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
         private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
         private Dictionary<string, string> ToolTipDict = new Dictionary<string, string>();
-       //private List<Tuple<int,int>> AnnotStamp
+        private List<Tuple<int, int>> AnnotSignatures = new List<Tuple<int, int>>();
         private StickyNotePopup customStickyPopup;
+        string Unicode = "";
 
         //private bool isHiddenAnnot = true;
         private bool isAddBookMark = true;

+ 6 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -55,6 +55,12 @@ namespace PDF_Office.ViewModels.Tools
             InitToolDict();
             InitToolTipDict();
             InitPopMenu();
+            SubscribeEvent();
+        }
+        private void SubscribeEvent()
+        {
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign, e => e.AppUnicode == Unicode);
         }
 
         private void InitPopMenu()