|
@@ -17,11 +17,13 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
{
|
|
|
- public class RedactionContentViewModel : BindableBase,INavigationAware
|
|
|
+ public class RedactionContentViewModel : BindableBase, INavigationAware
|
|
|
{
|
|
|
public IEventAggregator eventAggregator;
|
|
|
|
|
@@ -46,10 +48,12 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
|
|
|
public DelegateCommand ApplyCommmand { get; set; }
|
|
|
|
|
|
- public DelegateCommand RemoveCommand { get; set; }
|
|
|
-
|
|
|
public DelegateCommand PageRedactionCommand { get; set; }
|
|
|
|
|
|
+ public DelegateCommand EraseCommand { get; set; }
|
|
|
+
|
|
|
+ public RedactionCommandEventArgs TempArgs { get; set; }
|
|
|
+
|
|
|
private int currentPage = 0;
|
|
|
|
|
|
/// <summary>
|
|
@@ -63,9 +67,9 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
set
|
|
|
{
|
|
|
SetProperty(ref currentPage, value);
|
|
|
- if(value>=1&&value<=PDFViewer.Document.PageCount&&!isFromSelf)
|
|
|
+ if (value >= 1 && value <= PDFViewer.Document.PageCount && !isFromSelf)
|
|
|
{
|
|
|
- PDFViewer.GoToPage(value-1);
|
|
|
+ PDFViewer.GoToPage(value - 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -82,7 +86,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
}
|
|
|
|
|
|
|
|
|
- public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator,IDialogService dialogService)
|
|
|
+ public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogService)
|
|
|
{
|
|
|
this.redactionRegion = regionManager;
|
|
|
this.eventAggregator = eventAggregator;
|
|
@@ -92,10 +96,80 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
CloseEditToolCommand = new DelegateCommand(CloseEditTool);
|
|
|
ApplyCommmand = new DelegateCommand(apply);
|
|
|
- RemoveCommand = new DelegateCommand(remove);
|
|
|
+ EraseCommand = new DelegateCommand(erase);
|
|
|
PageRedactionCommand = new DelegateCommand(pageMark);
|
|
|
+
|
|
|
+ eventAggregator.GetEvent<RedactionCommandEvent>().Subscribe(SetContextMenu, e => e.UniCode == Unicode);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetContextMenu(RedactionCommandEventArgs obj)
|
|
|
+ {
|
|
|
+ var contextmenu = App.Current.FindResource("RedactionContextMenu") as ContextMenu;
|
|
|
+ obj.args.PopupMenu = contextmenu;
|
|
|
+ for(int i=0;i<contextmenu.Items.Count;i++)
|
|
|
+ {
|
|
|
+ if(contextmenu.Items[i] is MenuItem)
|
|
|
+ {
|
|
|
+ var item = contextmenu.Items[i] as MenuItem;
|
|
|
+ switch (item.Name)
|
|
|
+ {
|
|
|
+ case "MenuSetDeufalt":
|
|
|
+ item.Command = new DelegateCommand<RedactionCommandEventArgs>(SetDefualtProperty);
|
|
|
+ item.CommandParameter = obj;
|
|
|
+ break;
|
|
|
+ case "MenuProperties":
|
|
|
+ item.Command = new DelegateCommand<RedactionCommandEventArgs>(ShowProperty);
|
|
|
+ item.CommandParameter = obj;
|
|
|
+ break;
|
|
|
+ case "MenuRepeat":
|
|
|
+ item.Command = new DelegateCommand<RedactionCommandEventArgs>(RepreatMark);
|
|
|
+ item.CommandParameter = obj;
|
|
|
+ break;
|
|
|
+ case "MenuApply":
|
|
|
+ item.Command = this.ApplyCommmand;
|
|
|
+ break;
|
|
|
+ case "MenuErase":
|
|
|
+ item.Command = this.EraseCommand;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 设置当前为默认属性
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="args"></param>
|
|
|
+ private void SetDefualtProperty(RedactionCommandEventArgs args)
|
|
|
+ {
|
|
|
+ DialogParameters keyValues = new DialogParameters();
|
|
|
+ keyValues.Add(ParameterNames.DataModel,args.args.AnnotEventArgsList[0] as RedactionAnnotArgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 显示属性弹窗
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="args"></param>
|
|
|
+ private void ShowProperty(RedactionCommandEventArgs args)
|
|
|
+ {
|
|
|
+ DialogParameters keyValues = new DialogParameters();
|
|
|
+ keyValues.Add(ParameterNames.DataModel, args.args.AnnotEventArgsList[0] as RedactionAnnotArgs);
|
|
|
+ dialogs.ShowDialog(DialogNames.MarkSettingDialog,keyValues,null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 显示跨页标记弹窗
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="args"></param>
|
|
|
+ private void RepreatMark(RedactionCommandEventArgs args)
|
|
|
+ {
|
|
|
+ DialogParameters keyValues = new DialogParameters();
|
|
|
+ keyValues.Add(ParameterNames.PageCount,PDFViewer.Document.PageCount);
|
|
|
+ dialogs.ShowDialog(DialogNames.RepeatMarkDialog, keyValues, null);
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 应用
|
|
|
/// </summary>
|
|
@@ -114,7 +188,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
/// <summary>
|
|
|
/// 擦除
|
|
|
/// </summary>
|
|
|
- private void remove()
|
|
|
+ private void erase()
|
|
|
{
|
|
|
|
|
|
}
|