Sfoglia il codice sorgente

填写与签名 - 选中注释跳转指定的属性面板

chenrongqian@kdanmobile.com 2 anni fa
parent
commit
2f59ff0ede

+ 5 - 2
PDF Office/EventAggregators/FillAndSignEvent.cs

@@ -1,4 +1,5 @@
-using Prism.Events;
+using ComPDFKitViewer.AnnotEvent;
+using Prism.Events;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -11,9 +12,11 @@ namespace PDF_Office.EventAggregators
     public class FillAndSigntEventArgs
     {
         public string Unicode { get; set; }
+        public string AppUnicode { get; set; }
+        public List<AnnotHandlerEventArgs> Annots { get; set; }
+
     }
     public class FillAndSignEvent : PubSubEvent<FillAndSigntEventArgs>
     {
-
     }
 }

+ 23 - 5
PDF Office/ViewModels/FillAndSign/FillAndSignContentViewModel.cs

@@ -100,12 +100,13 @@ namespace PDF_Office.ViewModels.FillAndSign
         /// </summary>
         public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
         #endregion
-
+        string Unicode = "";
         public FillAndSignContentViewModel(IRegionManager regionManager, IEventAggregator events)
         {
            
             regions = regionManager;
             this.events = events;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
             ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
             InitDictionary();
@@ -122,7 +123,7 @@ namespace PDF_Office.ViewModels.FillAndSign
         #region 事件聚合器(来自AnnotToolContentViewModel)
         private void SubscribeEvent()
         {
-            events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign);
+            events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign, e => e.AppUnicode == Unicode);
         }
 
         private void FromFillAndSign(FillAndSigntEventArgs obj)
@@ -131,8 +132,25 @@ namespace PDF_Office.ViewModels.FillAndSign
             {
                 if(string.IsNullOrEmpty(obj.Unicode) == false)
                 {
-                    AnnotHandlerEventArgs annotArgs = null;
-                    FindAnnotTypeKey(obj.Unicode, ref annotArgs);
+                    if(obj.Unicode == "Clear")
+                    {
+                        viewContentViewModel.FillAndSign.Clear();
+                    }
+                    else
+                    {
+                        if(obj.Annots != null && obj.Annots.Count > 0)
+                        {
+                            if (obj.Annots[0].EventType == AnnotArgsType.AnnotFreehand)
+                            {
+                                GetFreehand(obj.Annots);
+                            }
+                            else if(obj.Annots[0].EventType == AnnotArgsType.AnnotFreeText)
+                            {
+                                GetFreetext(obj.Annots);
+                            }
+                        }
+                    }
+                   
                 }
             }
         }
@@ -835,7 +853,7 @@ namespace PDF_Office.ViewModels.FillAndSign
                     foreach (var itemAnnot in annots)
                     {
                         var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
-                        PDFViewer.SelectAnnotation(itemAnnot.PageIndex, itemAnnot.AnnotIndex);
+                        //PDFViewer.SelectAnnotation(itemAnnot.PageIndex, itemAnnot.AnnotIndex);
                         propertyPanel.AnnotEvents.Add(eventitem);
 
                     }

+ 9 - 2
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -30,8 +30,8 @@ namespace PDF_Office.ViewModels.Tools
 {
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
-        #region 事件绑定和解绑
 
+        #region 事件绑定和解绑
         private void BindingEvent()
         {
             //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
@@ -151,7 +151,14 @@ namespace PDF_Office.ViewModels.Tools
             if (e.ClickCount == 2)
             {
                 if (CurrentSelectedAnnot != null)
-                    PopAnnotNoteText(CurrentSelectedAnnot);
+                {
+                    var type = CurrentSelectedAnnot.EventType;
+                    if (type != AnnotArgsType.AnnotSticky && type != AnnotArgsType.AnnotFreeText &&
+                        type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline && type != AnnotArgsType.AnnotStrikeout)
+                  
+                        PopAnnotNoteText(CurrentSelectedAnnot);
+                }
+                   
             }
         }
 

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

@@ -507,7 +507,7 @@ namespace PDF_Office.ViewModels.Tools
             else
             {
                 freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
-                if (NavigatedToFillAndSignVM(freehandArgs, "Freehand"))
+                if (NavigatedToFillAndSignVM(selectedArgs, "Freehand"))
                 {
                     return freehandArgs;
                 }
@@ -591,7 +591,7 @@ namespace PDF_Office.ViewModels.Tools
                 freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
                 textAlignment = freetextArgs.Align;
 
-                if(NavigatedToFillAndSignVM(freetextArgs, "Freetext"))
+                if(NavigatedToFillAndSignVM(selectedArgs, "Freetext"))
                 {
                     return freetextArgs;
                 }
@@ -602,14 +602,14 @@ namespace PDF_Office.ViewModels.Tools
         }
 
         //Event导航到填写与签名的属性面板
-        private bool NavigatedToFillAndSignVM(AnnotHandlerEventArgs annot, string tag)
+        private bool NavigatedToFillAndSignVM(List<AnnotHandlerEventArgs> annots, string tag)
         {
-            if (viewContentViewModel.FillAndSign != null && viewContentViewModel.FillAndSign.Count > 0)
+            if (viewContentViewModel.FillAndSign != null && viewContentViewModel.FillAndSign.Count > 0 && annots != null && annots.Count > 0)
             {
-                var annotFillAndSign = viewContentViewModel.FillAndSign.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
+                var annotFillAndSign = viewContentViewModel.FillAndSign.FirstOrDefault(temp => temp.Item1 == annots[0].PageIndex && temp.Item2 == annots[0].AnnotIndex);
                 if (annotFillAndSign != null)
                 {
-                    this.events.GetEvent<FillAndSignEvent>().Publish(new FillAndSigntEventArgs { Unicode = tag });
+                    this.events.GetEvent<FillAndSignEvent>().Publish(new FillAndSigntEventArgs { Unicode = tag , AppUnicode = App.mainWindowViewModel.SelectedItem.Unicode, Annots = annots });
                     return true;
                 }
             }

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

@@ -279,6 +279,7 @@ 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 StickyNotePopup customStickyPopup;
 
         //private bool isHiddenAnnot = true;

+ 3 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -539,6 +539,9 @@ namespace PDF_Office.ViewModels
             get { return canSave; }
             set
             {
+                if (events != null && canSave == false)
+                    this.events.GetEvent<FillAndSignEvent>().Publish(new FillAndSigntEventArgs { Unicode = "Clear", AppUnicode = unicode });
+
                 SetProperty(ref canSave, value);
             }
         }