123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.EventAggregators;
- using PDF_Office.Model;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Mvvm;
- using Prism.Regions;
- 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;
- private CPDFViewer PDFViewer;
- public string RedactionDocumentRegionName { get; set; }
- public string RedactionBottomBarRegionName { get; set; }
- public string RedactionDocumentName = "RedactionDocumentContent";
- public string Unicode = null;
- public DelegateCommand CloseEditToolCommand { get; set; }
- public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
- {
- this.redactionRegion = regionManager;
- this.eventAggregator = eventAggregator;
- RedactionDocumentRegionName = Guid.NewGuid().ToString();
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
- CloseEditToolCommand = new DelegateCommand(CloseEditTool);
- }
- 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 });
- }
- 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);
- 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);
- }
-
- }
- }
- }
|