123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.Model;
- using PDF_Master.Properties;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
- {
- internal class StickyNotePopupViewModel : BindableBase, INavigationAware
- {
- private string authorText;
- public string AuthorText
- {
- get { return authorText; }
- set
- {
- SetProperty(ref authorText, value);
- }
- }
- private string dateText;
- public string DateText
- {
- get { return dateText; }
- set
- {
- SetProperty(ref dateText, value);
- }
- }
- private string contentText;
- public string ContentText
- {
- get { return contentText; }
- set
- {
- SetProperty(ref contentText, value);
- }
- }
- private ViewContentViewModel ViewContentViewModel;
- private StickyAnnotArgs StickyAnnotArgs;
- private AnnotCommandArgs AnnotCommandArgs;
- private CPDFViewer PDFViewer;
- public DelegateCommand<object> ContentTextLostFocus { get; set; }
- public StickyNotePopupViewModel()
- {
- ContentTextLostFocus = new DelegateCommand<object>(ContentText_LostFocus);
- }
- private void ContentText_LostFocus(object obj)
- {
- if (ViewContentViewModel == null || StickyAnnotArgs == null || PDFViewer == null || AnnotCommandArgs == null)
- {
- return;
- }
- if (string.IsNullOrEmpty(ContentText))
- {
- ViewContentViewModel.IsNoteAdd = false;
- return;
- }
- StickyAnnotArgs.StickyNote = ContentText;
- PDFViewer.CreatePageAnnot(AnnotCommandArgs.PageIndex, StickyAnnotArgs);
- ViewContentViewModel.IsNoteAdd = false;
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- if(StickyAnnotArgs != null && string.IsNullOrEmpty(StickyAnnotArgs.Content))
- {
- PDFViewer.RemovePageAnnot(StickyAnnotArgs.PageIndex, StickyAnnotArgs.AnnotIndex);
- }
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out ViewContentViewModel);
- navigationContext.Parameters.TryGetValue<StickyAnnotArgs>(ParameterNames.StickyAnnotArgs, out StickyAnnotArgs);
- navigationContext.Parameters.TryGetValue<AnnotCommandArgs>(ParameterNames.AnnotCommandArgs, out AnnotCommandArgs);
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- SetToolParam();
- AuthorText = Settings.Default.AppProperties.Description.Author;
- DateText = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
- }
- private void SetToolParam()
- {
- if(PDFViewer != null && StickyAnnotArgs != null && string.IsNullOrEmpty(StickyAnnotArgs.Content))
- {
- PDFViewer.SetToolParam(StickyAnnotArgs);
- }
- }
- }
- }
|