|
@@ -2,6 +2,7 @@
|
|
|
using ComPDFKitViewer;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
+using Microsoft.Office.Interop.Word;
|
|
|
using Microsoft.Win32;
|
|
|
using PDF_Office.CustomControl;
|
|
|
using PDF_Office.EventAggregators;
|
|
@@ -60,11 +61,14 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
|
|
|
public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
|
|
|
|
|
|
+ public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
|
|
|
+
|
|
|
public AnnotToolContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
|
|
|
{
|
|
|
region = regionManager;
|
|
|
events = eventAggregator;
|
|
|
MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
|
|
|
+ SetAddAnnotationCommand = new DelegateCommand<object>(AddAnnotation_Click);
|
|
|
PropertyRegionName = Guid.NewGuid().ToString();
|
|
|
BindingEvent();
|
|
|
InitDefaultValue();
|
|
@@ -755,12 +759,167 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
e.Handle = true;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.PopupMenu = ViewerContextMenu();
|
|
|
+ if (e.PopupMenu != null)
|
|
|
+ {
|
|
|
+ e.Handle = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private ContextMenu ViewerContextMenu()
|
|
|
+ {
|
|
|
+ ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
|
+ contextMenu.Loaded += ContextMenu_Loaded;
|
|
|
+
|
|
|
+ return contextMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ContextMenu_Loaded(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ContextMenu contextMenu = sender as ContextMenu;
|
|
|
+ if (contextMenu.Items.Count > 0)
|
|
|
+ {
|
|
|
+ //粘贴
|
|
|
+ MenuItem menuItem = contextMenu.Items[0] as MenuItem;
|
|
|
+ if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
|
|
|
+ {
|
|
|
+ menuItem.IsEnabled = false;
|
|
|
+ menuItem.Opacity = 0.5;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menuItem.IsEnabled = true;
|
|
|
+ menuItem.Opacity = 1;
|
|
|
+ }
|
|
|
+ //添加注释 >
|
|
|
+ MenuItem menuItem1 = contextMenu.Items[2] as MenuItem;
|
|
|
+ if (menuItem1.Items.Count > 0)
|
|
|
+ {
|
|
|
+ SetAddAnnotation(menuItem1.Items);
|
|
|
+ }
|
|
|
+ //隐藏注释 >
|
|
|
+ MenuItem menuItem2 = contextMenu.Items[3] as MenuItem;
|
|
|
+ //显示注释 >
|
|
|
+ MenuItem menuItem3 = contextMenu.Items[4] as MenuItem;
|
|
|
+ if (menuItem2.Visibility == Visibility.Visible)
|
|
|
+ {
|
|
|
+ menuItem3.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menuItem3.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ //添加书签 >
|
|
|
+ MenuItem menuItem4 = contextMenu.Items[5] as MenuItem;
|
|
|
+ //删除书签 >
|
|
|
+ MenuItem menuItem5 = contextMenu.Items[6] as MenuItem;
|
|
|
+ if (menuItem4.Visibility == Visibility.Visible)
|
|
|
+ {
|
|
|
+ menuItem5.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menuItem5.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ //工具模式 >
|
|
|
+ MenuItem menuItem6 = contextMenu.Items[8] as MenuItem;
|
|
|
+ //进入阅读模式 >
|
|
|
+ MenuItem menuItem7 = contextMenu.Items[9] as MenuItem;
|
|
|
+ //退出阅读模式 >
|
|
|
+ MenuItem menuItem8 = contextMenu.Items[10] as MenuItem;
|
|
|
+ if (App.IsBookMode)
|
|
|
+ {
|
|
|
+ menuItem7.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menuItem7.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ if (menuItem7.Visibility == Visibility.Visible)
|
|
|
+ {
|
|
|
+ menuItem8.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menuItem8.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ //视图缩放 >
|
|
|
+ MenuItem menuItem9 = contextMenu.Items[12] as MenuItem;
|
|
|
+ //页面显示 >
|
|
|
+ MenuItem menuItem10 = contextMenu.Items[13] as MenuItem;
|
|
|
+ //查找
|
|
|
+ MenuItem menuItem11 = contextMenu.Items[15] as MenuItem;
|
|
|
+ //打印...
|
|
|
+ MenuItem menuItem12 = contextMenu.Items[16] as MenuItem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetAddAnnotation(ItemCollection items)
|
|
|
+ {
|
|
|
+ foreach (var item in items)
|
|
|
+ {
|
|
|
+ if (item is MenuItem menuItem)
|
|
|
+ {
|
|
|
+ menuItem.CommandParameter = item;
|
|
|
+ menuItem.Command = SetAddAnnotationCommand;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddAnnotation_Click(object sender)
|
|
|
+ {
|
|
|
+ if (sender is MenuItem menuItem)
|
|
|
+ {
|
|
|
+ AnnotHandlerEventArgs annotHandler = null;
|
|
|
+ if (menuItem.Tag.ToString() == AddAnnotType.AnnotFreeText.ToString())
|
|
|
+ {
|
|
|
+ annotHandler = GetFreetext();
|
|
|
+ //if (annotHandler != null)
|
|
|
+ //{
|
|
|
+ // annotHandler.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
+ // PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ // PDFViewer.SetToolParam(annotHandler);
|
|
|
+ // ShowPropertyPanel(true);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ if (menuItem.Tag.ToString() == AddAnnotType.AnnotLine.ToString())
|
|
|
+ {
|
|
|
+ annotHandler = GetArrowLine("Line");
|
|
|
+ //if (annotHandler != null)
|
|
|
+ //{
|
|
|
+ // annotHandler.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
+ // PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ // PDFViewer.SetToolParam(annotHandler);
|
|
|
+ // ShowPropertyPanel(true);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ if (annotHandler != null)
|
|
|
+ {
|
|
|
+ annotHandler.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewer.SetToolParam(annotHandler);
|
|
|
+ ShowPropertyPanel(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //if (sender is AnnotHandlerEventArgs annotHandler)
|
|
|
+ //{
|
|
|
+ // if (annotHandler != null)
|
|
|
+ // {
|
|
|
+ // annotHandler.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
+ // PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ // PDFViewer.SetToolParam(annotHandler);
|
|
|
+ // ShowPropertyPanel(true);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
private ContextMenu SelectAnnotContextMenu(object sender)
|
|
|
{
|
|
|
var popMenu = App.Current.FindResource("SelectAnnotContextMenu") as ContextMenu;
|