|
@@ -34,6 +34,10 @@ using Prism.Events;
|
|
|
using System.Windows.Input;
|
|
|
using ContextMenu = System.Windows.Controls.ContextMenu;
|
|
|
using MenuItem = System.Windows.Controls.MenuItem;
|
|
|
+using System.Drawing;
|
|
|
+using Color = System.Windows.Media.Color;
|
|
|
+using Brush = System.Windows.Media.Brush;
|
|
|
+using FontFamily = System.Windows.Media.FontFamily;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
@@ -654,8 +658,8 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
-
|
|
|
+ {
|
|
|
+ e.PopupMenu = ViewerContextMenu();
|
|
|
if (e.PopupMenu != null)
|
|
|
{
|
|
|
e.Handle = true;
|
|
@@ -666,6 +670,166 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ private ContextMenu ViewerContextMenu()
|
|
|
+ {
|
|
|
+ ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
+
|
|
|
+ ViewerContextMenu_Loaded(contextMenu, null);
|
|
|
+ return contextMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ViewerContextMenu_Loaded(object sender, RoutedEventArgs e,Visibility visibility =Visibility.Collapsed)
|
|
|
+ {
|
|
|
+ ContextMenu contextMenu = sender as ContextMenu;
|
|
|
+ if (contextMenu.Items.Count > 0)
|
|
|
+ {
|
|
|
+ int index = PDFViewer.CurrentIndex;
|
|
|
+ //检测是否已存在相同数据
|
|
|
+ CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
|
|
|
+ foreach (var item in contextMenu.Items)
|
|
|
+ {
|
|
|
+ if (item is Separator separator) {
|
|
|
+
|
|
|
+ separator.Visibility = visibility;
|
|
|
+ }
|
|
|
+ if (item is MenuItem menuItem1)
|
|
|
+ {
|
|
|
+ //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
|
|
|
+ //{
|
|
|
+ // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
|
|
|
+ //}
|
|
|
+
|
|
|
+ switch (menuItem1.Tag.ToString())
|
|
|
+ {
|
|
|
+ case "Copy":
|
|
|
+ //粘贴
|
|
|
+ //if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
|
|
|
+ //{
|
|
|
+ // menuItem1.IsEnabled = false;
|
|
|
+ // menuItem1.Opacity = 0.5;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // menuItem1.IsEnabled = true;
|
|
|
+ // menuItem1.Opacity = 1;
|
|
|
+ //}
|
|
|
+ menuItem1.CommandTarget = (UIElement)PDFViewer;
|
|
|
+ menuItem1.Command = ApplicationCommands.Paste;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "AddAnnotation":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "HiddenAnnot":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "DisplayAnnot":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "AddBookMark":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "DelBookMark":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "ToolMode":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "ReadModel":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "UnReadModel":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "ViewZoom":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "PageDisplay":
|
|
|
+ menuItem1.Visibility = visibility;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Select":
|
|
|
+ menuItem1.Click -= Select_Click;
|
|
|
+
|
|
|
+ menuItem1.Click += Select_Click;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Print":
|
|
|
+ menuItem1.Command = viewContentViewModel.PrintCommand;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void Select_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (viewContentViewModel.OpenBOTA == false)
|
|
|
+ {
|
|
|
+ viewContentViewModel.OpenBOTA = true;
|
|
|
+ }
|
|
|
+ bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemSearch");
|
|
|
+ if (isBook == false)
|
|
|
+ {
|
|
|
+ bOTAContent.TabItemSearch.IsSelected = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public IRegionManager region;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //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;
|
|
|
+ }
|
|
|
+
|
|
|
private bool isHightAnnot(AnnotHandlerEventArgs annot)
|
|
|
{
|
|
|
if (annot.EventType == AnnotArgsType.AnnotUnderline ||
|
|
@@ -909,6 +1073,9 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
UnBindingPDFViewerHandler();
|
|
|
+ ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
+
|
|
|
+ ViewerContextMenu_Loaded(contextMenu, null,Visibility.Visible);
|
|
|
viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
|
|
|
}
|
|
|
|