12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.Model;
- using PDF_Office.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_Office.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)
- {
- }
- 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);
- AuthorText = Settings.Default.AppProperties.Description.Author;
- DateText = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
- }
- }
- }
|