123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.CustomControl;
- using PDF_Office.EventAggregators;
- using PDF_Office.Model;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Media;
- namespace PDF_Office.ViewModels.EditTools.Redaction
- {
- public class RedactionContentViewModel : BindableBase,INavigationAware
- {
- public IEventAggregator eventAggregator;
- public IRegionManager redactionRegion;
- public IDialogService dialogs;
- private CPDFViewer PDFViewer;
- private ViewContentViewModel viewContentViewModel;
- public string RedactionDocumentRegionName { get; set; }
- public string RedactionBottomBarRegionName { get; set; }
- public string RedactionDocumentName = "RedactionDocumentContent";
- public string Unicode = null;
- public DelegateCommand CloseEditToolCommand { get; set; }
- public DelegateCommand ApplyCommmand { get; set; }
- public DelegateCommand RemoveCommand { get; set; }
- public DelegateCommand PageRedactionCommand { get; set; }
- public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator,IDialogService dialogService)
- {
- this.redactionRegion = regionManager;
- this.eventAggregator = eventAggregator;
- this.dialogs = dialogService;
- RedactionDocumentRegionName = Guid.NewGuid().ToString();
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
- CloseEditToolCommand = new DelegateCommand(CloseEditTool);
- ApplyCommmand = new DelegateCommand(apply);
- RemoveCommand = new DelegateCommand(remove);
- PageRedactionCommand = new DelegateCommand(pageMark);
- }
- /// <summary>
- /// 应用
- /// </summary>
- private void apply()
- {
- AlertsMessage alertsMessage = new AlertsMessage();
- 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)
- {
- viewContentViewModel.saveAsFile(true);
- }
- }
- /// <summary>
- /// 擦除
- /// </summary>
- private void remove()
- {
- }
- private void pageMark()
- {
- dialogs.ShowDialog(DialogNames.PageMarkDialog);
- }
- public void CloseEditTool()
- {
- PDFViewer.SetMouseMode(MouseModes.Default);
- redactionRegion.Regions[RegionNames.ViwerRegionName].Remove(PDFViewer);
- redactionRegion.Regions[RedactionDocumentRegionName].Remove(PDFViewer);
- this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
- }
- #region Navigation
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
- if (!redactionRegion.Regions[RedactionDocumentRegionName].Views.Contains(PDFViewer))
- {
- RedactionAnnotArgs redactionArgs = new RedactionAnnotArgs();
- AnnotHandlerEventArgs annotArgs = null;
- redactionArgs.LineColor = ((SolidColorBrush)Brushes.Black).Color;
- redactionArgs.BgColor = ((SolidColorBrush)Brushes.Black).Color;
- redactionArgs.FontColor = ((SolidColorBrush)Brushes.Red).Color;
- //redactionArgs.LineColor = Settings.Default.RedactionsSettings.LineColor;
- //redactionArgs.BgColor = Settings.Default.RedactionsSettings.BgColor;
- //redactionArgs.FontColor = Settings.Default.RedactionsSettings.FontColor;
- //redactionArgs.Align = Settings.Default.RedactionsSettings.Align;
- //redactionArgs.FontSize = Settings.Default.RedactionsSettings.FontSize;
- //redactionArgs.Content = Settings.Default.RedactionsSettings.Content;
- //if (!Settings.Default.RedactionsSettings.isUseText)
- //{
- // redactionArgs.Content = "";
- //}
- annotArgs = redactionArgs;
- if (annotArgs != null)
- {
- //annotArgs.Author = Settings.Default.AppProperties.Description.Author;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(annotArgs);
- }
- redactionRegion.AddToRegion(RedactionDocumentRegionName, PDFViewer);
- }
-
- }
- #endregion
- }
- }
|