소스 검색

bota-注释列表-多选注释

OYXH\oyxh 2 년 전
부모
커밋
4a29503be0

+ 5 - 0
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -22,6 +22,7 @@ using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
@@ -841,6 +842,10 @@ namespace PDF_Office.ViewModels.BOTA
             {
                 PdfViewer.SelectAnnotation(annotation.PageIndex, annotation.AnnotIndex);
             }
+            if (obj is Dictionary<int, List<int>> eventArgs)
+            {
+                PdfViewer.SelectAnnotation(eventArgs);
+            }
         }
 
         public async void UpdateAddedAnnot(int pageIndex, int annotIndex)

+ 32 - 20
PDF Office/ViewModels/Dialog/BOTA/ScreenAnnotationDialogViewModel.cs

@@ -288,50 +288,62 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                             {
                                 case "Highlight":
                                     btnHighlight = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "FreeHand":
                                     btnFreeHand = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotSticky":
                                     btnAnnotSticky = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotStamp":
                                     btnAnnotStamp = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "SharpLine":
                                     btnSharpLine = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "SharpArrow":
                                     btnSharpArrow = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotCircle":
                                     btnAnnotCircle = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotSquare":
                                     btnAnnotSquare = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotFreeText":
                                     btnAnnotFreeText = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotStrikeout":
                                     btnAnnotStrikeout = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "Underline":
                                     btnUnderLine = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
 
                                 case "AnnotLink":
                                     btnAnnotLink = iconToggleBtn;
+                                    iconToggleBtns.Add(iconToggleBtn);
                                     break;
                             }
                         }
@@ -348,10 +360,10 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     //btnAnnotStrikeout = arrys[9] as CustomIconToggleBtn;
                     //btnUnderLine = arrys[10] as CustomIconToggleBtn;
                     //btnAnnotLink = arrys[11] as CustomIconToggleBtn;
-                    for (int i = 0; i < arrys.Length - 2; i++)
-                    {
-                        iconToggleBtns.Add(arrys[i] as CustomIconToggleBtn);
-                    }
+                    //for (int i = 0; i < arrys.Length - 2; i++)
+                    //{
+                    //    iconToggleBtns.Add(arrys[i] as CustomIconToggleBtn);
+                    //}
                     SetBtnSelectedState(arrys);
                 }
             }
@@ -519,22 +531,22 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
         /// <param name="obj"></param>
         private void CleanEvent(Object obj)
         {
-            //for (int i = 0; i < iconToggleBtns.Count; i++)
-            //{
-            //    SetBtnType(iconToggleBtns[i], true);
-            //}
-
-            //if (this._ListColor != null)
-            //{
-            //    this._ListColor.SelectedItems.Clear();
-            //}
-            //if (this._ListAuthor != null)
-            //{
-            //    this._ListAuthor.SelectedItems.Clear();
-            //}
-            DialogParameters valuePairs = new DialogParameters();
-            valuePairs.Add(ParameterNames.AnnotationCleanState, true);
-            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+            for (int i = 0; i < iconToggleBtns.Count; i++)
+            {
+                SetBtnType(iconToggleBtns[i], true);
+            }
+
+            if (this._ListColor != null)
+            {
+                this._ListColor.SelectedItems.Clear();
+            }
+            if (this._ListAuthor != null)
+            {
+                this._ListAuthor.SelectedItems.Clear();
+            }
+            //DialogParameters valuePairs = new DialogParameters();
+            //valuePairs.Add(ParameterNames.AnnotationCleanState, true);
+            //RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
         }
 
         /// <summary>

+ 1 - 1
PDF Office/Views/BOTA/AnnotationContent.xaml

@@ -66,6 +66,7 @@
                 BorderThickness="0"
                 ItemTemplate="{StaticResource AnnotationListItemTemplate}"
                 ItemsSource="{Binding AnnotationListItems}"
+                SelectionChanged="AnnotationList_SelectionChanged"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 SelectionMode="Extended">
                 <ListBox.ItemContainerStyle>
@@ -73,7 +74,6 @@
                         <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                         <EventSetter Event="PreviewMouseDown" Handler="ListBoxItem_PreviewMouseDown" />
                         <EventSetter Event="PreviewMouseDoubleClick" Handler="ListBoxItem_PreviewMouseDoubleClick" />
-
                         <Setter Property="Template" Value="{StaticResource AnnotationListItemStyle}" />
                         <Setter Property="Padding" Value="0" />
                         <Setter Property="Margin" Value="0,-1,0,-1" />

+ 54 - 10
PDF Office/Views/BOTA/AnnotationContent.xaml.cs

@@ -48,11 +48,11 @@ namespace PDF_Office.Views.BOTA
         {
             if (e.ClickCount == 1)
             {
-                if (Mouse.LeftButton == e.ButtonState)
-                {
-                    viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(sender);
-                }
-                else if (Mouse.RightButton == e.ButtonState)
+                //if (Mouse.LeftButton == e.ButtonState)
+                //{
+                //    viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(sender);
+                //}
+                if (Mouse.RightButton == e.ButtonState)
                 {
                     var pos = e.GetPosition(AnnotationList);
 
@@ -106,11 +106,6 @@ namespace PDF_Office.Views.BOTA
             }
         }
 
-        private void AnnotationList_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            //AnnotationList.ContextMenu.IsEnabled = false;
-        }
-
         private async void MenuExpandAll_Click(object sender, RoutedEventArgs e)
         {
             SetAllExpander(true);
@@ -277,5 +272,54 @@ namespace PDF_Office.Views.BOTA
             MenuMore.PlacementTarget = BtnMore;
             MenuMore.IsOpen = true;
         }
+
+        private void AnnotationList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            if (AnnotationList.SelectedItems.Count > 1)
+            {
+                viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(AnnotationList.SelectedItems);
+            }
+            else if (AnnotationList.SelectedItems.Count == 1)
+            {
+                viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(AnnotationList.SelectedItem);
+            }
+        }
+
+        private void AnnotationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var a1 = (sender as ListBox).SelectedItems.Count;
+            var a2 = (e.OriginalSource as ListBox).SelectedItems.Count;
+            var a3 = (e.Source as ListBox).SelectedItems.Count;
+            if (a1 == 1)
+            {
+                viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute((sender as ListBox).SelectedItem);
+            }
+            else if (a1 > 1)
+            {
+                Dictionary<int, List<int>> selectedItemDics = new Dictionary<int, List<int>>();
+                List<AnnotationHandlerEventArgs> eventArgs = new List<AnnotationHandlerEventArgs>();
+                List<int> ints = new List<int>();
+                foreach (var item in (sender as ListBox).SelectedItems)
+                {
+                    if (item is AnnotationHandlerEventArgs annotation)
+                    {
+                        if (!selectedItemDics.ContainsKey(annotation.PageIndex))
+                        {
+                            ints.Clear();
+                            ints.Add(annotation.AnnotIndex);
+                            selectedItemDics.Add(annotation.PageIndex, ints);
+                        }
+                        else
+                        {
+                            ints.Add(annotation.AnnotIndex);
+                            selectedItemDics[annotation.PageIndex] = ints;
+                        }
+                    }
+
+                    //eventArgs.Add((AnnotationHandlerEventArgs)item);
+                }
+                viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(selectedItemDics);
+            }
+        }
     }
 }