فهرست منبع

综合-视图 旋转刷新 手绘缩略图、阅读页右键菜单

OYXH\oyxh 2 سال پیش
والد
کامیت
4f0c6be334

+ 3 - 2
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -249,6 +249,7 @@ namespace PDF_Office.ViewModels.BOTA
         public void DisplayAnnot()
         {
             AnnotationListItems = GetDocumentAnnotionList();
+            CurrentAnnotationLists = GetDocumentAnnotionList();
             RefreshAnnotationListItems();
         }
 
@@ -551,7 +552,7 @@ namespace PDF_Office.ViewModels.BOTA
         /// 刷新列表数据
         /// </summary>
         /// <param name="button"></param>
-        private async void RefreshAnnotationListItems(System.Windows.Controls.Button button = null)
+        public async void RefreshAnnotationListItems(System.Windows.Controls.Button button = null)
         {
             switch (AnnotationSortOrder)
             {
@@ -1281,7 +1282,7 @@ namespace PDF_Office.ViewModels.BOTA
         /// 获取listbox绑定数据
         /// </summary>
         /// <returns></returns>
-        private ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
+        public ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
         {
             ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
             for (int i = 0; i < PdfViewer.Document.PageCount; i++)

+ 15 - 4
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -39,7 +39,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
     internal class LinkAnnotPropertyViewModel : BindableBase, INavigationAware
     {
-
         #region 文案
 
         private string T_title;
@@ -70,7 +69,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             T_Page = App.MainPageLoader.GetString("Link_Page");
         }
 
-        #endregion
+        #endregion 文案
 
         public AnnotAttribEvent AnnotAttribEvent { get; set; }
 
@@ -751,7 +750,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 var isHas = views.FindFirst(q => q is Views.TipContent.LinkAnnotTip);
                 if (isHas != null)
                 {
-                    isExist=true;
+                    isExist = true;
                 }
                 //foreach (var item in views)
                 //{
@@ -1214,7 +1213,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         }
                     }
                 }
-
+                if (pdfViewer != null && pdfViewer.ToolManager != null && pdfViewer.ToolManager.CurrentAnnotArgs?.EventType == AnnotArgsType.AnnotLink)
+                {
+                    LinkAnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                    if (LinkAnnotArgs == null)
+                    {
+                        LinkAnnotArgs = (LinkAnnotArgs)propertyPanel.annot;
+                        backPageIndex = pdfViewer.CurrentIndex;
+                    }
+                    else
+                    {
+                        LinkAnnotArgs.PageIndex = pdfViewer.CurrentIndex;
+                    }
+                }
                 if (LinkAnnotArgs == null)
                 {
                     LinkAnnotArgs = (LinkAnnotArgs)propertyPanel.annot;

+ 82 - 7
PDF Office/ViewModels/PropertyPanel/ViewModular/ViewModularContentViewModel.cs

@@ -1,11 +1,14 @@
 using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Office.Interop.Word;
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
 using PDF_Office.Model;
+using PDF_Office.Model.BOTA;
 using PDF_Office.ViewModels.BOTA;
 using PDF_Office.Views;
+using PDF_Office.Views.BOTA;
 using PDFSettings.Settings;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -13,6 +16,7 @@ using Prism.Regions;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -23,8 +27,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
 {
     public class ViewModularContentViewModel : BindableBase, INavigationAware
     {
-
         #region 文案
+
         private string T_title;
 
         public string T_Title
@@ -135,8 +139,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
             }
         }
 
-
-
         private void InitString()
         {
             T_Title = App.MainPageLoader.GetString("ViewProperties_Title");
@@ -151,8 +153,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
             T_RotateTitle = App.MainPageLoader.GetString("ViewProperties_RotateTitle");
         }
 
-
-        #endregion
+        #endregion 文案
 
         private IRegionManager region;
 
@@ -344,10 +345,84 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
             {
                 SplitScreenPDFViewer.RotatePage(PageRotate.Rotate90, right, SplitScreenPDFViewer.CurrentIndex);
             }
-
+            PDFViewer.UndoManager.CanSave = true;
             //后续需要添加,缩略图旋转改变
 
-            PDFViewer.UndoManager.CanSave = true;
+            if (ViewContentViewModel.OpenBOTA == true)
+            {
+                UpdateTabItemAnnotation();
+            }
+        }
+
+        private void UpdateTabItemAnnotation()
+        {
+            bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
+
+            if (isTabItemAnnotation == true && bOTAContent.TabItemAnnotation.IsSelected == true)
+            {
+                AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
+
+                if (viewModel != null)
+                {
+                    if (viewModel.AnnotationListItems.Count > 0)
+                    {
+                        var list = viewModel.AnnotationListItems.Where(q => q.AnnotHandlerEventArgs is FreehandAnnotArgs).ToList();
+                        if (list.Count() > 0)
+                        {
+                            for (int i = 0; i < list.Count(); i++)
+                            {
+                                var item = list[i];
+                                viewModel.UpdateModifiedAnnot(item.PageIndex, item.AnnotIndex, false);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private AnnotationContentViewModel GetAnnotationContentViewModel(BOTAContentViewModel bOTAContentViewModel, out AnnotationContent annotation)
+        {
+            AnnotationContentViewModel viewModel = null;
+            annotation = null;
+            if (bOTAContentViewModel != null)
+            {
+                if (region.Regions.ContainsRegionWithName(bOTAContentViewModel.BOTAContentRegionName))
+                {
+                    var views = region.Regions[bOTAContentViewModel.BOTAContentRegionName].Views;
+                    foreach (var item in views)
+                    {
+                        if (item is AnnotationContent annotation1)
+                        {
+                            annotation = annotation1;
+                            viewModel = annotation1.DataContext as AnnotationContentViewModel;
+                            break;
+                        }
+                    }
+                }
+            }
+            return viewModel;
+        }
+
+        private bool IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, string tabItemText)
+        {
+            bool isTabItem = false;
+            bOTAContentViewModel = null;
+            bOTAContent = null;
+            if (region.Regions.ContainsRegionWithName(ViewContentViewModel.BOTARegionName))
+            {
+                var views = region.Regions[ViewContentViewModel.BOTARegionName].Views;
+                var model = views.FirstOrDefault(q => q is BOTAContent);
+                if (model is BOTAContent bOTAContent1)
+                {
+                    bOTAContent = bOTAContent1;
+                    bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
+                    if (bOTAContentViewModel.CurrentBar == tabItemText)
+                    {
+                        isTabItem = true;
+                    }
+                }
+            }
+            return isTabItem;
         }
 
         /// <summary>

+ 31 - 5
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -151,11 +151,15 @@ namespace PDF_Office.ViewModels.Tools
                     var annotArgs = new SelectToolArgs();
                     PDFViewer.SetToolParam(annotArgs);
                 }
+                else
+                {
+                    PDFViewer.SetMouseMode(MouseModes.PanTool);
+                }
             }
             else
             {
                 //鼠标滚动页面
-                PDFViewer.SetMouseMode(MouseModes.PanTool);
+                PDFViewer.SetMouseMode(MouseModes.Scroll);
                 PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
             }
         }
@@ -336,6 +340,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (item is MenuItem menuItem)
                 {
+                    menuItem.IsCheckable = false;
                     menuItem.Click -= PageDisplay_Click;
                     menuItem.Click += PageDisplay_Click;
                 }
@@ -377,7 +382,25 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (item is MenuItem menuItem)
                 {
-                    menuItem.Click -= PageDisplay_Click;
+                    //switch (PDFViewer.ModeFit)
+                    //{
+                    //    case FitMode.FitWidth:
+                    //        break;
+
+                    //    case FitMode.FitHeight:
+                    //        break;
+
+                    //    case FitMode.FitSize:
+                    //        break;
+
+                    //    case FitMode.FitFree:
+                    //        break;
+
+                    //    default:
+                    //        break;
+                    //}
+                    menuItem.IsCheckable = false;
+                    menuItem.Click -= ViewZoom_Click;
                     menuItem.Click += ViewZoom_Click;
                 }
             }
@@ -391,6 +414,7 @@ namespace PDF_Office.ViewModels.Tools
                 {
                     case "FitWidth":
                         PDFViewer.ChangeFitMode(FitMode.FitWidth);
+
                         break;
 
                     case "FitHeight":
@@ -430,6 +454,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (item is MenuItem menuItem)
                 {
+                    menuItem.IsCheckable = false;
                     menuItem.Click -= ToolMode_Click;
                     menuItem.Click += ToolMode_Click;
                 }
@@ -443,14 +468,14 @@ namespace PDF_Office.ViewModels.Tools
                 switch (menuItem.Tag.ToString())
                 {
                     case "default":
-                        PDFViewer.SetMouseMode(MouseModes.Default);
+                        PDFViewer.SetMouseMode(MouseModes.PanTool);
                         //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
                         BtnHandIsChecked = false;
                         ShowPropertyPanel(false);
                         break;
 
                     case "roll":
-                        PDFViewer.SetMouseMode(MouseModes.PanTool);
+                        PDFViewer.SetMouseMode(MouseModes.Scroll);
                         //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
                         BtnHandIsChecked = true;
                         ShowPropertyPanel(false);
@@ -466,6 +491,7 @@ namespace PDF_Office.ViewModels.Tools
                             PDFViewer.SetToolParam(annotHandler);
                             ShowPropertyPanel(false);
                         }
+
                         break;
 
                     default:
@@ -762,7 +788,7 @@ namespace PDF_Office.ViewModels.Tools
             BindingPDFViewerHandler();
             BindingEvent();
             LoaedStickyNotePopup();
-            BtnHandIsChecked = (PDFViewer.MouseMode == MouseModes.Scroll? true:false);
+            BtnHandIsChecked = (PDFViewer.MouseMode == MouseModes.Scroll ? true : false);
         }
 
         #endregion Navigation