Browse Source

隐藏注释

OYXH\oyxh 1 năm trước cách đây
mục cha
commit
21c5c59d9e

+ 33 - 20
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -249,13 +249,17 @@ namespace PDF_Master.ViewModels.BOTA
         public void HiddenAnnot()
         {
             AnnotationListItems.Clear();
-            IsEmptyPanelVisibility = Visibility.Visible;
+            CurrentAnnotationLists = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
+            AnnotationListItems.AddRange(CurrentAnnotationLists);
+            //IsEmptyPanelVisibility = Visibility.Visible;
         }
 
         public void DisplayAnnot()
         {
-            AnnotationListItems = GetDocumentAnnotionList();
-            CurrentAnnotationLists = GetDocumentAnnotionList();
+            AnnotationListItems.Clear();
+            //AnnotationListItems = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
+            CurrentAnnotationLists = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
+            AnnotationListItems.AddRange(CurrentAnnotationLists);
             RefreshAnnotationListItems();
         }
 
@@ -284,7 +288,7 @@ namespace PDF_Master.ViewModels.BOTA
                     }
                     PdfViewer.ReloadVisibleAnnots();
                     //提取出来的注释文件 时间为空  则显示未系统当前时间
-                    CurrentAnnotationLists = GetDocumentAnnotionList();
+                    CurrentAnnotationLists = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
                     //BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
                     //CurrentAnnotationLists = new ObservableCollection<AnnotationHandlerEventArgs>(CurrentAnnotationLists.OrderBy(item => item.ClientRect.X).ThenBy(item => item.ClientRect.Y));
                     AnnotationListItems.Clear();
@@ -871,17 +875,17 @@ namespace PDF_Master.ViewModels.BOTA
                         DialogParameters value = new DialogParameters();
                         value.Add(ParameterNames.Annotation, args);
                         dialogs.ShowDialog(DialogNames.AddAnnotationDialog, value, e =>
-                        {
-                            if (e.Result == ButtonResult.OK && e.Parameters != null)
-                            {
-                                PdfViewer.UndoManager.CanSave = true;
-                                if (e.Parameters.ContainsKey(ParameterNames.Annotation) && e.Parameters.ContainsKey(ParameterNames.AnnotEvent))
-                                {
-                                    AnnotationHandlerEventArgs annotation = e.Parameters.GetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation);
-                                    RefreshOneListItem(annotation.AnnotHandlerEventArgs);
-                                }
-                            }
-                        });
+                                                                                                                                                                                          {
+                                                                                                                                                                                              if (e.Result == ButtonResult.OK && e.Parameters != null)
+                                                                                                                                                                                              {
+                                                                                                                                                                                                  PdfViewer.UndoManager.CanSave = true;
+                                                                                                                                                                                                  if (e.Parameters.ContainsKey(ParameterNames.Annotation) && e.Parameters.ContainsKey(ParameterNames.AnnotEvent))
+                                                                                                                                                                                                  {
+                                                                                                                                                                                                      AnnotationHandlerEventArgs annotation = e.Parameters.GetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation);
+                                                                                                                                                                                                      RefreshOneListItem(annotation.AnnotHandlerEventArgs);
+                                                                                                                                                                                                  }
+                                                                                                                                                                                              }
+                                                                                                                                                                                          });
                     }
                     //else if (args.EventType == AnnotArgsType.AnnotFreeText)
                     //{
@@ -1225,11 +1229,11 @@ namespace PDF_Master.ViewModels.BOTA
 
             #endregion BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
 
-            CurrentAnnotationLists = GetDocumentAnnotionList();
+            CurrentAnnotationLists = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
 
             AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
 
-            AnnotationListItems = GetDocumentAnnotionList();
+            AnnotationListItems.AddRange(CurrentAnnotationLists);
 
             AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
             //按照PageIndex,分组 排序
@@ -1303,9 +1307,10 @@ namespace PDF_Master.ViewModels.BOTA
         /// 获取listbox绑定数据
         /// </summary>
         /// <returns></returns>
-        public ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
+        public ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots)
         {
             ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
+            HideAnnots = new ObservableCollection<AnnotationHandlerEventArgs>();
             for (int i = 0; i < PdfViewer.Document.PageCount; i++)
             {
                 var items = PdfViewer.GetAnnotCommentList(i, PdfViewer.Document);
@@ -1314,7 +1319,7 @@ namespace PDF_Master.ViewModels.BOTA
                     //原型图上,目前对波浪线的类型,在注释列表不显示
                     //注释列表 不显示链接注释
                     if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly
-                        && item.EventType != AnnotArgsType.AnnotLink)
+                    && item.EventType != AnnotArgsType.AnnotLink)
                     {
                         if (item.EventType == AnnotArgsType.AnnotLink)
                         {
@@ -1327,9 +1332,17 @@ namespace PDF_Master.ViewModels.BOTA
                             }
                         }
                         AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
+                        bool isVisible = PdfViewer.CheckAnnotVisible(args.PageIndex, args.AnnotIndex);
                         if (args.AnnotHandlerEventArgs != null)
                         {
-                            list.Add(args);
+                            if (isVisible)
+                            {
+                                list.Add(args);
+                            }
+                            else
+                            {
+                                HideAnnots.Add(args);
+                            }
                         }
                     }
                 }

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

@@ -902,6 +902,7 @@ namespace PDF_Master.ViewModels.Tools
                 for (int i = 0; i < e.Count; i++)
                 {
                     AnnotEditEvent editEvent = e[i];
+                    bool isVisible = PDFViewer.CheckAnnotVisible(editEvent.PageIndex, editEvent.AnnotIndex);
                     switch (editEvent.EditAction)
                     {
                         case ActionType.Add: