OYXH\oyxh 1 سال پیش
والد
کامیت
8ff954af26

+ 10 - 1
PDF Office/EventAggregators/SplitEvent.cs

@@ -44,7 +44,8 @@ namespace PDF_Office.EventAggregators
         public string Unicode { get; set; }
         public bool IsReadMode { get; set; }
 
-        //public bool IsBotaShow { get; set; }
+        public bool IsBOTAShow  { get; set; }
+        public bool IsPropertyOpen { get; set; }
     }
 
     public class ReadModePropertyOpenArgs
@@ -52,6 +53,11 @@ namespace PDF_Office.EventAggregators
         public string Unicode { get; set; }
         public bool IsPropertyOpen { get; set; }
     }
+    public class ReadModeBOTAShowArgs
+    {
+        public string Unicode { get; set; }
+        public bool IsBOTAShow { get; set; }
+    }
 
     public class ReadModeEvent : PubSubEvent<ReadModeArgs>
     {
@@ -60,4 +66,7 @@ namespace PDF_Office.EventAggregators
     public class ReadModePropertyOpenEvent : PubSubEvent<ReadModePropertyOpenArgs>
     {
     }
+    public class ReadModeBOTAShowEvent : PubSubEvent<ReadModeBOTAShowArgs>
+    {
+    }
 }

+ 7 - 4
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -164,11 +164,14 @@ namespace PDF_Office.ViewModels.Tools
                                 SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", BtnShowAnnotIsChecked);
                                 break;
 
-                            case "AddBookMark":
-                                //menuItem1.Click -= AddBookMark_Click;
-                                //menuItem1.Click += AddBookMark_Click;
+                            case "AddBookMark":
+
                                 menuItem1.Command = AddBookMarkCommand;
                                 SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
+                                if (viewContentViewModel.mainViewModel.IsBookMode)
+                                {
+                                    menuItem1.IsEnabled = false;
+                                }
                                 break;
 
                             case "DelBookMark":
@@ -365,7 +368,7 @@ namespace PDF_Office.ViewModels.Tools
             menuItem.Header = header;
             menuItem.Tag = tag;
 
-            if (tag == "Link")
+            if (tag == "OutLine")
             {
                 if (viewContentViewModel.mainViewModel.IsBookMode)
                 {

+ 39 - 54
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -293,20 +293,6 @@ namespace PDF_Office.ViewModels.Tools
                         isTabItem = true;
                     }
                 }
-                //foreach (var item in views)
-                //{
-                //    if (item is BOTAContent bOTAContent1)
-                //    {
-                //        bOTAContent = bOTAContent1;
-                //        bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
-                //        if (bOTAContentViewModel.CurrentBar == tabItemText)
-                //        {
-                //            isTabItem = true;
-
-                //            break;
-                //        }
-                //    }
-                //}
             }
             return isTabItem;
         }
@@ -494,54 +480,53 @@ namespace PDF_Office.ViewModels.Tools
 
         private void DelBookMark_Click(object sender, RoutedEventArgs e)
         {
-            if (viewContentViewModel.OpenBOTA == false)
+            CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA);
+            if (bOTAContentVM != null && bOTA != null)
             {
-                viewContentViewModel.OpenBOTA = true;
-            }
-            bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemBookMark");
-            if (isBook == false)
-            {
-                bOTAContent.TabItemBookMark.IsSelected = true;
-            }
-            BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentViewModel, out BookmarkContent bookmark);
+                BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentVM, out BookmarkContent bookmark);
 
-            int index = PDFViewer.CurrentIndex;
-            //检测是否已存在相同数据
-            CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
-            if (bookmarkContentViewModel != null && bookmark != null && bOTAContent != null && list != null)
-            {
-                bookmarkContentViewModel.DeleteCommand.Execute(list);
-                isAddBookMark = bookmarkContentViewModel.isAddBookMark;
+                int index = PDFViewer.CurrentIndex;
+                //检测是否已存在相同数据
+                CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
+                if (bookmarkContentViewModel != null && bookmark != null && bOTA != null && list != null)
+                {
+                    bookmarkContentViewModel.DeleteCommand.Execute(list);
+                    isAddBookMark = bookmarkContentViewModel.isAddBookMark;
+                }
             }
-
-            //        bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemBookMark");
-
-            //if (isBook == false || viewContentViewModel.OpenBOTA == false)
-            //{
-            //    viewContentViewModel.OpenBOTA = true;
-            //    bOTAContent.TabItemBookMark.IsSelected = true;
-            //}
         }
 
-        private void AddBookMark_Click()
+        private void CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA)
         {
             if (viewContentViewModel.OpenBOTA == false)
             {
                 viewContentViewModel.OpenBOTA = true;
             }
-            bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemBookMark");
+            bool isBook = IsBOTATabItemShow(out bOTAContentVM, out bOTA, "TabItemBookMark");
             if (isBook == false)
             {
-                bOTAContent.TabItemBookMark.IsSelected = true;
+                bOTA.TabItemBookMark.IsSelected = true;
             }
-            BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentViewModel, out BookmarkContent bookmark);
+        }
 
-            if (bookmarkContentViewModel != null && bookmark != null && bOTAContent != null)
+        private void AddBookMark_Click()
+        {
+            CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA);
+            //if (viewContentViewModel.mainViewModel.IsBookMode)
+            //{
+            //    this.events.GetEvent<ReadModeBOTAShowEvent>().Publish(new ReadModeBOTAShowArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsBOTAShow = true });
+            //}
+            if (bOTAContentVM != null && bOTA != null)
             {
-                //bookmarkContentViewModel.AddBookmarkCommand.Execute(bookmark.BookMarkListView);
-                bookmark.BtnAddBookmark_Click(null, null);
-                isAddBookMark = bookmarkContentViewModel.isAddBookMark;
-                return;
+                BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentVM, out BookmarkContent bookmark);
+
+                if (bookmarkContentViewModel != null && bookmark != null && bOTA != null)
+                {
+                    //bookmarkContentViewModel.AddBookmarkCommand.Execute(bookmark.BookMarkListView);
+                    bookmark.BtnAddBookmark_Click(null, null);
+                    isAddBookMark = bookmarkContentViewModel.isAddBookMark;
+                    return;
+                }
             }
         }
 
@@ -626,13 +611,13 @@ namespace PDF_Office.ViewModels.Tools
                 if (item is MenuItem menuItem)
                 {
                     string str = menuItem.Tag.ToString();
-                    if (str == AddAnnotType.AnnotLink.ToString()
-                    || str == AddAnnotType.AnnotStamp.ToString()
-                    || str == AddAnnotType.AnnotAutograph.ToString()
-                    )
-                    {
-                        InBookModeSetIsEnabled(menuItem);
-                    }
+                    //if (str == AddAnnotType.AnnotLink.ToString()
+                    //|| str == AddAnnotType.AnnotStamp.ToString()
+                    //|| str == AddAnnotType.AnnotAutograph.ToString()
+                    //)
+                    //{
+                    //    InBookModeSetIsEnabled(menuItem);
+                    //}
                     menuItem.CommandParameter = item;
                     menuItem.Command = SetAddAnnotationCommand;
                 }