|
@@ -12,6 +12,8 @@ using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Input;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Form
|
|
|
{
|
|
@@ -55,6 +57,7 @@ namespace PDF_Office.ViewModels.Form
|
|
|
private IRegionManager regions;
|
|
|
|
|
|
private string CurrentToolBtnType;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 按钮和属性面板键值对
|
|
|
/// </summary>
|
|
@@ -72,6 +75,18 @@ namespace PDF_Office.ViewModels.Form
|
|
|
public DelegateCommand ClosedMenuCommand { get; set; }
|
|
|
|
|
|
public event EventHandler<string> UncheckedToolsBtnEvent;
|
|
|
+
|
|
|
+ #region 右键菜单
|
|
|
+ public DelegateCommand<object> PropertyMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> CrossPageMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> JumpPosMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> HideNameMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> SearchFormMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> PrintMenuCommand { get; set; }
|
|
|
+ public DelegateCommand<object> DefaultValueMenuCommand { get; set; }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化
|
|
@@ -87,8 +102,59 @@ namespace PDF_Office.ViewModels.Form
|
|
|
ClosedMenuCommand = new DelegateCommand(ClosedMenu);
|
|
|
AlignmentClosedMenuCommand = new DelegateCommand(AlignmentClosedMenu);
|
|
|
InitBtnToProperty();
|
|
|
+
|
|
|
+ //右键菜单
|
|
|
+ PropertyMenuCommand = new DelegateCommand<object>(PropertyMenu);
|
|
|
+ CrossPageMenuCommand = new DelegateCommand<object>(CrossPageMenu);
|
|
|
+ JumpPosMenuCommand = new DelegateCommand<object>(JumpPosMenu);
|
|
|
+ HideNameMenuCommand = new DelegateCommand<object>(HideNameMenu);
|
|
|
+ SearchFormMenuCommand = new DelegateCommand<object>(SearchFormMenu);
|
|
|
+ PrintMenuCommand = new DelegateCommand<object>(PrintMenu);
|
|
|
+ DefaultValueMenuCommand = new DelegateCommand<object>(DefaultValueMenu);
|
|
|
+ }
|
|
|
+
|
|
|
+ #region Command实现
|
|
|
+
|
|
|
+ #region Command右键菜单
|
|
|
+
|
|
|
+ private void PropertyMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ private void CrossPageMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void JumpPosMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ private void HideNameMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SearchFormMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PrintMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DefaultValueMenu(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
private void InitBtnToProperty()
|
|
|
{
|
|
@@ -343,6 +409,15 @@ namespace PDF_Office.ViewModels.Form
|
|
|
{
|
|
|
UncheckedToolsBtnEvent?.Invoke(null, CurrentToolBtnType);
|
|
|
CurrentToolBtnType = "";
|
|
|
+ if (PDFViewer != null)
|
|
|
+ {
|
|
|
+ PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
|
|
|
+ PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
|
|
|
+ PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
|
|
|
+ PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
|
|
|
+ PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
@@ -363,9 +438,147 @@ namespace PDF_Office.ViewModels.Form
|
|
|
PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
|
|
|
PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
|
|
|
PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
|
|
|
+ PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
|
|
|
+ PDFViewer.AnnotCommandHandler += PDFViewer_WidgetCommandHandler;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private void PDFViewer_WidgetCommandHandler(object sender, AnnotCommandArgs e)
|
|
|
+ {
|
|
|
+ if (e == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ switch (e.CommandType)
|
|
|
+ {
|
|
|
+ case CommandType.Context:
|
|
|
+ if(e.CommandTarget == TargetType.WidgetView)
|
|
|
+ {
|
|
|
+ WidgetViewCommandArgs widgetCommand = e as WidgetViewCommandArgs;
|
|
|
+ if(widgetCommand != null && widgetCommand.AnnotEvent != null )
|
|
|
+ {
|
|
|
+ if (widgetCommand.AnnotEvent.AnnotItemsList.Count == 1)
|
|
|
+ {
|
|
|
+ e.PopupMenu = SelectedFormMenu(sender);
|
|
|
+ }
|
|
|
+ else if(widgetCommand.AnnotEvent.AnnotItemsList.Count > 1)
|
|
|
+ {
|
|
|
+ e.PopupMenu = MultiSelectedFormMenu(sender);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.PopupMenu = BlankReaMenu(sender);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ e.DoCommand();
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (e.PopupMenu != null)
|
|
|
+ {
|
|
|
+ e.Handle = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitMenu(CustomPopMenu customMenu,object sender)
|
|
|
+ {
|
|
|
+ int index= 0;
|
|
|
+ //属性
|
|
|
+ customMenu.SetMenuBinding(index, sender, PropertyMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "Property");
|
|
|
+ index++;
|
|
|
+ //复制
|
|
|
+ customMenu.SetMenuBinding(index, sender, ApplicationCommands.Copy);
|
|
|
+ customMenu.SetTagProperty(index, "Copy");
|
|
|
+ index++;
|
|
|
+ //剪切
|
|
|
+ customMenu.SetMenuBinding(index, sender, ApplicationCommands.Cut);
|
|
|
+ customMenu.SetTagProperty(index, "Cut");
|
|
|
+ index++;
|
|
|
+ //粘贴
|
|
|
+ customMenu.SetMenuBinding(index, sender, ApplicationCommands.Paste);
|
|
|
+ customMenu.SetTagProperty(index, "Paste");
|
|
|
+ index++;
|
|
|
+ //删除
|
|
|
+ customMenu.SetMenuBinding(index, sender, ApplicationCommands.Delete);
|
|
|
+ customMenu.SetTagProperty(index, "Delete");
|
|
|
+ index++;
|
|
|
+ //创建多个副本
|
|
|
+ customMenu.SetMenuBinding(index, sender, ApplicationCommands.Delete);
|
|
|
+ customMenu.SetTagProperty(index, "CreateCopy");
|
|
|
+ index++;
|
|
|
+ //跨页复制
|
|
|
+ customMenu.SetMenuBinding(index, sender, CrossPageMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "CrossPage");
|
|
|
+ index++;
|
|
|
+ //显示跳位编号
|
|
|
+ customMenu.SetMenuBinding(index, sender, JumpPosMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "JumpPos");
|
|
|
+ index++;
|
|
|
+ //隐藏名称
|
|
|
+ customMenu.SetMenuBinding(index, sender, HideNameMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "HideName");
|
|
|
+ index++;
|
|
|
+ //查找
|
|
|
+ customMenu.SetMenuBinding(index, sender, SearchFormMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "SearchForm");
|
|
|
+ index++;
|
|
|
+ //打印
|
|
|
+ customMenu.SetMenuBinding(index, sender, PrintMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "print");
|
|
|
+ index++;
|
|
|
+ //设置当前属性为默认值
|
|
|
+ customMenu.SetMenuBinding(index, sender, DefaultValueMenuCommand);
|
|
|
+ customMenu.SetTagProperty(index, "DefaultValue");
|
|
|
+ index++;
|
|
|
+ customMenu.AllMenuVisibility(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击空白处
|
|
|
+ private ContextMenu BlankReaMenu(object sender)
|
|
|
+ {
|
|
|
+ var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
|
|
|
+ CustomPopMenu customMenu = new CustomPopMenu(popMenu);
|
|
|
+ InitMenu(customMenu, sender);
|
|
|
+ customMenu.SetVisibilityProperty("Property", false);
|
|
|
+ customMenu.SetVisibilityProperty("Copy", false);
|
|
|
+ customMenu.SetVisibilityProperty("Cut", false);
|
|
|
+ customMenu.SetVisibilityProperty("Delete", false);
|
|
|
+ customMenu.SetVisibilityProperty("CreateCopy", false);
|
|
|
+ customMenu.SetVisibilityProperty("CrossPage", false);
|
|
|
+ customMenu.SetVisibilityProperty("DefaultValue", false);
|
|
|
+ return popMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ //选中一个
|
|
|
+ private ContextMenu SelectedFormMenu(object sender)
|
|
|
+ {
|
|
|
+ var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
|
|
|
+ CustomPopMenu customMenu = new CustomPopMenu(popMenu);
|
|
|
+ InitMenu(customMenu, sender);
|
|
|
+ customMenu.SetVisibilityProperty("SearchForm", false);
|
|
|
+ customMenu.SetVisibilityProperty("print", false);
|
|
|
+ return popMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ //多选
|
|
|
+ private ContextMenu MultiSelectedFormMenu(object sender)
|
|
|
+ {
|
|
|
+ var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
|
|
|
+ CustomPopMenu customMenu = new CustomPopMenu(popMenu);
|
|
|
+ InitMenu(customMenu, sender);
|
|
|
+ customMenu.SetVisibilityProperty("CreateCopy", false);
|
|
|
+ customMenu.SetVisibilityProperty("DefaultValue", false);
|
|
|
+ customMenu.SetVisibilityProperty("SearchForm", false);
|
|
|
+ customMenu.SetVisibilityProperty("print", false);
|
|
|
+ return popMenu;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|