StickyNotePopupViewModel.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.Model;
  4. using PDF_Office.Properties;
  5. using Prism.Commands;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
  14. {
  15. internal class StickyNotePopupViewModel : BindableBase, INavigationAware
  16. {
  17. private string authorText;
  18. public string AuthorText
  19. {
  20. get { return authorText; }
  21. set
  22. {
  23. SetProperty(ref authorText, value);
  24. }
  25. }
  26. private string dateText;
  27. public string DateText
  28. {
  29. get { return dateText; }
  30. set
  31. {
  32. SetProperty(ref dateText, value);
  33. }
  34. }
  35. private string contentText;
  36. public string ContentText
  37. {
  38. get { return contentText; }
  39. set
  40. {
  41. SetProperty(ref contentText, value);
  42. }
  43. }
  44. private ViewContentViewModel ViewContentViewModel;
  45. private StickyAnnotArgs StickyAnnotArgs;
  46. private AnnotCommandArgs AnnotCommandArgs;
  47. private CPDFViewer PDFViewer;
  48. public DelegateCommand<object> ContentTextLostFocus { get; set; }
  49. public StickyNotePopupViewModel()
  50. {
  51. ContentTextLostFocus = new DelegateCommand<object>(ContentText_LostFocus);
  52. }
  53. private void ContentText_LostFocus(object obj)
  54. {
  55. if (ViewContentViewModel == null || StickyAnnotArgs == null || PDFViewer == null || AnnotCommandArgs == null)
  56. {
  57. return;
  58. }
  59. if (string.IsNullOrEmpty(ContentText))
  60. {
  61. ViewContentViewModel.IsNoteAdd = false;
  62. return;
  63. }
  64. StickyAnnotArgs.StickyNote = ContentText;
  65. PDFViewer.CreatePageAnnot(AnnotCommandArgs.PageIndex, StickyAnnotArgs);
  66. ViewContentViewModel.IsNoteAdd = false;
  67. }
  68. public bool IsNavigationTarget(NavigationContext navigationContext)
  69. {
  70. return true;
  71. }
  72. public void OnNavigatedFrom(NavigationContext navigationContext)
  73. {
  74. }
  75. public void OnNavigatedTo(NavigationContext navigationContext)
  76. {
  77. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out ViewContentViewModel);
  78. navigationContext.Parameters.TryGetValue<StickyAnnotArgs>(ParameterNames.StickyAnnotArgs, out StickyAnnotArgs);
  79. navigationContext.Parameters.TryGetValue<AnnotCommandArgs>(ParameterNames.AnnotCommandArgs, out AnnotCommandArgs);
  80. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  81. AuthorText = Settings.Default.AppProperties.Description.Author;
  82. DateText = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
  83. }
  84. }
  85. }