Bladeren bron

Bug-BOTA隐藏注释后,注释列表的注释也需要隐藏

OYXH\oyxh 2 jaren geleden
bovenliggende
commit
f6271a44d5

+ 35 - 10
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -99,6 +99,18 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
+        private bool CanIsEnabled()
+        {
+            if (AnnotationListItems.Count > 0)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
         private List<string> colors = new List<string>();
         private List<string> authors = new List<string>();
         private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
@@ -106,8 +118,8 @@ namespace PDF_Office.ViewModels.BOTA
         public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
         public DelegateCommand<object> AddNotesCommand { get; set; }
         public DelegateCommand<object> ScreenCommand { get; set; }
-        public DelegateCommand<object> ExportCommentsCommand { get; set; }
-        public DelegateCommand<object> ImportCommentsCommand { get; set; }
+        public DelegateCommand ExportCommentsCommand { get; set; }
+        public DelegateCommand ImportCommentsCommand { get; set; }
         public DelegateCommand<object> DeleteCommand { get; set; }
 
         public DelegateCommand DeleteAllCommand { get; set; }
@@ -125,20 +137,32 @@ namespace PDF_Office.ViewModels.BOTA
             ListBoxItemPreviewMouseLeftButtonDown = new DelegateCommand<object>(ListBoxItem_PreviewMouseLeftButtonDown);
             AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
             ScreenCommand = new DelegateCommand<object>(ScreenEvent);
-            ExportCommentsCommand = new DelegateCommand<object>(ExportCommentsEvent);
-            ImportCommentsCommand = new DelegateCommand<object>(ImportCommentsEvent);
+            ExportCommentsCommand = new DelegateCommand(ExportCommentsEvent, CanIsEnabled).ObservesProperty(() => AnnotationListItems);
+            ImportCommentsCommand = new DelegateCommand(ImportCommentsEvent);
             DeleteCommand = new DelegateCommand<object>(DelegateEvent);
-            DeleteAllCommand = new DelegateCommand(DeleteAllEvent);
+            DeleteAllCommand = new DelegateCommand(DeleteAllEvent, CanIsEnabled).ObservesProperty(() => AnnotationListItems);
             PageSortCommand = new DelegateCommand(PageSortEvent);
             TimeAscendingCommand = new DelegateCommand(TimeAscendingEvent);
             TimeDescendingCommand = new DelegateCommand(TimeDescendingEvent);
         }
 
+        public void HiddenAnnot()
+        {
+            AnnotationListItems.Clear();
+            IsEmptyPanelVisibility = Visibility.Visible;
+        }
+
+        public void DisplayAnnot()
+        {
+            AnnotationListItems = GetDocumentAnnotionList();
+            RefreshAnnotationListItems();
+        }
+
         /// <summary>
         /// 导入注释
         /// </summary>
         /// <param name="obj"></param>
-        private async void ImportCommentsEvent(object obj)
+        private async void ImportCommentsEvent()
         {
             Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
             dlg.Filter = "PDF|*.xfdf";
@@ -263,7 +287,6 @@ namespace PDF_Office.ViewModels.BOTA
                     if (result)
                     {
                         RemoveItem(annotation);
-
                     }
                 }
             }
@@ -330,7 +353,7 @@ namespace PDF_Office.ViewModels.BOTA
         /// 导出注释
         /// </summary>
         /// <param name="obj"></param>
-        private void ExportCommentsEvent(object obj)
+        private void ExportCommentsEvent()
         {
             if (ViewContentViewModel.CanSave)
             {
@@ -429,7 +452,7 @@ namespace PDF_Office.ViewModels.BOTA
         /// 刷新列表数据
         /// </summary>
         /// <param name="button"></param>
-        private async void RefreshAnnotationListItems(System.Windows.Controls.Button button)
+        private async void RefreshAnnotationListItems(System.Windows.Controls.Button button = null)
         {
             switch (AnnotationSortOrder)
             {
@@ -1035,10 +1058,12 @@ namespace PDF_Office.ViewModels.BOTA
 
             #endregion BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
 
+            CurrentAnnotationLists = GetDocumentAnnotionList();
+
             AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
 
             AnnotationListItems = GetDocumentAnnotionList();
-            CurrentAnnotationLists.AddRange(AnnotationListItems);
+
             AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
             //按照PageIndex,分组 排序
             ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);

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

@@ -629,12 +629,28 @@ namespace PDF_Office.ViewModels.Tools
         {
             PDFViewer.SetDrawAnnot(true);
             BtnShowAnnotIsChecked = true;
+
+            bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
+
+            if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
+            {
+                AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
+                viewModel.DisplayAnnot();
+            }
         }
 
         private void HiddenAnnot_Click(object sender, RoutedEventArgs e)
         {
             PDFViewer.SetDrawAnnot(false);
             BtnShowAnnotIsChecked = false;
+
+            bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
+
+            if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
+            {
+                AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
+                viewModel.HiddenAnnot();
+            }
         }
 
         private void SetAddAnnotation(ItemCollection items)