|
@@ -46,11 +46,11 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
|
|
|
public DelegateCommand CloseEditToolCommand { get; set; }
|
|
|
|
|
|
- public DelegateCommand ApplyCommmand { get; set; }
|
|
|
+ public DelegateCommand<string> ApplyCommmand { get; set; }
|
|
|
|
|
|
public DelegateCommand PageRedactionCommand { get; set; }
|
|
|
|
|
|
- public DelegateCommand EraseCommand { get; set; }
|
|
|
+ public DelegateCommand<string> EraseCommand { get; set; }
|
|
|
|
|
|
public RedactionCommandEventArgs TempArgs { get; set; }
|
|
|
|
|
@@ -110,8 +110,8 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
RedactionDocumentRegionName = Guid.NewGuid().ToString();
|
|
|
Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
CloseEditToolCommand = new DelegateCommand(CloseEditTool);
|
|
|
- ApplyCommmand = new DelegateCommand(apply,CanExcute).ObservesProperty(() => IsEnable);
|
|
|
- EraseCommand = new DelegateCommand(erase, CanExcute).ObservesProperty(() => IsEnable);
|
|
|
+ ApplyCommmand = new DelegateCommand<string>(apply,CanExcute).ObservesProperty(() => IsEnable);
|
|
|
+ EraseCommand = new DelegateCommand<string>(erase, CanExcute).ObservesProperty(() => IsEnable);
|
|
|
PageRedactionCommand = new DelegateCommand(pageMark);
|
|
|
|
|
|
eventAggregator.GetEvent<RedactionCommandEvent>().Subscribe(SetContextMenu, e => e.UniCode == Unicode);
|
|
@@ -121,6 +121,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
{
|
|
|
var contextmenu = App.Current.FindResource("RedactionContextMenu") as ContextMenu;
|
|
|
obj.args.PopupMenu = contextmenu;
|
|
|
+ TempArgs = obj;
|
|
|
for(int i=0;i<contextmenu.Items.Count;i++)
|
|
|
{
|
|
|
if(contextmenu.Items[i] is MenuItem)
|
|
@@ -146,9 +147,11 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
break;
|
|
|
case "MenuApply":
|
|
|
item.Command = this.ApplyCommmand;
|
|
|
+ item.CommandParameter = "Single";
|
|
|
break;
|
|
|
case "MenuErase":
|
|
|
item.Command = this.EraseCommand;
|
|
|
+ item.CommandParameter = "Single";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -203,22 +206,31 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
/// <summary>
|
|
|
/// 应用
|
|
|
/// </summary>
|
|
|
- private void apply()
|
|
|
+ private void apply(string type)
|
|
|
{
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
- alertsMessage.ShowDialog("Apply Redactions", "Use blank blocks to remove selected sensitive content."+
|
|
|
+ alertsMessage.ShowDialog("Apply Redactions", "Use blank blocks to remove selected sensitive content." +
|
|
|
|
|
|
-"This action will permanently delete the marked ciphertext information from this document and you will not be able to retrieve the marked ciphertext information.","Cancel","Apply & Save As");
|
|
|
- if(alertsMessage.result== ContentResult.Ok)
|
|
|
+"This action will permanently delete the marked ciphertext information from this document and you will not be able to retrieve the marked ciphertext information.", "Cancel", "Apply & Save As");
|
|
|
+ if (alertsMessage.result == ContentResult.Ok)
|
|
|
{
|
|
|
- viewContentViewModel.saveAsFile(true);
|
|
|
+ if (!string.IsNullOrEmpty(type) && type == "All")
|
|
|
+ {
|
|
|
+ viewContentViewModel.saveAsFile(applyAll);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ viewContentViewModel.saveAsFile(applySingle);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 擦除
|
|
|
/// </summary>
|
|
|
- private void erase()
|
|
|
+ private void erase(string type)
|
|
|
{
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
alertsMessage.ShowDialog("","Replace selected sensitive content with color blocks."+
|
|
@@ -226,11 +238,96 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
|
|
|
"This action will permanently delete the marked ciphertext information from this document and you will not be able to retrieve the marked ciphertext information.", "Cancel", "Apply & Save As");
|
|
|
if (alertsMessage.result == ContentResult.Ok)
|
|
|
{
|
|
|
- viewContentViewModel.saveAsFile(false,true);
|
|
|
+ if (!string.IsNullOrEmpty(type) && type == "All")
|
|
|
+ {
|
|
|
+ viewContentViewModel.saveAsFile(eraseAll);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ viewContentViewModel.saveAsFile(eraseSingle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 应用所有密文块
|
|
|
+ /// </summary>
|
|
|
+ private void applyAll()
|
|
|
+ {
|
|
|
+ PDFViewer.Document.ApplyRedaction();
|
|
|
+ PDFViewer.Document.ReleasePages();
|
|
|
+ PDFViewer.ReloadDocument();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 擦除所有密文块
|
|
|
+ /// </summary>
|
|
|
+ private void eraseAll()
|
|
|
+ {
|
|
|
+ for (int i = 0; i < PDFViewer.Document.PageCount; i++)
|
|
|
+ {
|
|
|
+ //获取页面Page对象
|
|
|
+ var page = PDFViewer.Document.PageAtIndex(i);
|
|
|
+ var annots = PDFViewer.GetAnnotCommentList(i, PDFViewer.Document);
|
|
|
+ //循环擦除当前页的标记密文
|
|
|
+ for (int j = 0; j < annots.Count; j++)
|
|
|
+ {
|
|
|
+ if (annots[j].EventType == AnnotArgsType.AnnotRedaction)
|
|
|
+ {
|
|
|
+ foreach (var rect in (annots[j] as RedactionAnnotArgs).QuardRects)
|
|
|
+ {
|
|
|
+ page.ErasureRedaction(rect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 应用选中的密文块
|
|
|
+ /// </summary>
|
|
|
+ private void applySingle()
|
|
|
+ {
|
|
|
+ AnnotCommandArgs annotCommand =TempArgs.args;
|
|
|
+ if (annotCommand != null)
|
|
|
+ {
|
|
|
+ List<RedactionAnnotArgs> redactionList = new List<RedactionAnnotArgs>();
|
|
|
+ foreach (AnnotHandlerEventArgs annotArgs in annotCommand.AnnotEventArgsList)
|
|
|
+ {
|
|
|
+ if (annotArgs.EventType == AnnotArgsType.AnnotRedaction)
|
|
|
+ {
|
|
|
+ redactionList.Add((RedactionAnnotArgs)annotArgs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PDFViewer.ApplyRedaction(redactionList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 擦除选中的密文块
|
|
|
+ /// </summary>
|
|
|
+ private void eraseSingle()
|
|
|
+ {
|
|
|
+ AnnotCommandArgs annotCommand = TempArgs.args;
|
|
|
+ if (annotCommand != null)
|
|
|
+ {
|
|
|
+ List<RedactionAnnotArgs> redactionList = new List<RedactionAnnotArgs>();
|
|
|
+ foreach (AnnotHandlerEventArgs annotArgs in annotCommand.AnnotEventArgsList)
|
|
|
+ {
|
|
|
+ if (annotArgs.EventType == AnnotArgsType.AnnotRedaction)
|
|
|
+ {
|
|
|
+ foreach (var rect in (annotArgs as RedactionAnnotArgs).QuardRects)
|
|
|
+ {
|
|
|
+ var page = PDFViewer.Document.PageAtIndex((annotArgs as RedactionAnnotArgs).PageIndex);
|
|
|
+ page.ErasureRedaction(rect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private bool CanExcute()
|
|
|
+ private bool CanExcute(string type)
|
|
|
{
|
|
|
return IsEnable;
|
|
|
}
|