AnnotToolContentViewModel.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using ComPDFKitViewer.PdfViewer;
  4. using PDF_Office.CustomControl;
  5. using PDF_Office.Helper;
  6. using PDF_Office.Model;
  7. using PDFSettings;
  8. using Prism.Commands;
  9. using Prism.Mvvm;
  10. using Prism.Regions;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows;
  17. using System.Windows.Controls;
  18. using System.Windows.Media;
  19. namespace PDF_Office.ViewModels.Tools
  20. {
  21. public class AnnotToolContentViewModel : BindableBase, INavigationAware
  22. {
  23. private CPDFViewer PDFViewer;
  24. private ViewContentViewModel viewContentViewModel;
  25. public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
  26. public AnnotToolContentViewModel()
  27. {
  28. MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
  29. }
  30. private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
  31. public void BtnMyTools_Click(CustomIconToggleBtn annotBtn)
  32. {
  33. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  34. UserControl propertyPanel = null;
  35. switch (annotBtn.Tag.ToString())
  36. {
  37. case "SnapshotEdit":
  38. break;
  39. case "HighLight":
  40. TextHighlightAnnotArgs highlightArgs = new TextHighlightAnnotArgs();
  41. highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
  42. highlightArgs.Transparency = 0.5;
  43. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
  44. if (annotProperty != null)
  45. {
  46. highlightArgs.Color = annotProperty.ForgoundColor;
  47. highlightArgs.Transparency = annotProperty.Opacity;
  48. highlightArgs.Content = annotProperty.NoteText;
  49. }
  50. annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
  51. annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
  52. annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
  53. /* TextAnnotProperty textAnnotProperty = new TextAnnotProperty();
  54. textAnnotProperty.DataChanged += AnnotPropertyPanel_DataChanged;
  55. textAnnotProperty.DefaultStored += AnnotProperty_DefaultStored;
  56. textAnnotProperty.SetAnnotType(highlightArgs.EventType);
  57. textAnnotProperty.SetSelectedColor(highlightArgs.Color);
  58. textAnnotProperty.SetSelectOpacity(highlightArgs.Transparency);
  59. textAnnotProperty.SetNoteContent(highlightArgs.Content);
  60. textAnnotProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(highlightArgs, annotAttribsList);
  61. propertyPanel = textAnnotProperty;
  62. annotArgs = highlightArgs;*/
  63. if (!ToolExpandDict.ContainsKey("HighLight"))
  64. {
  65. ToolExpandDict["HighLight"] = true;
  66. // viewCtrl.PropRow.Width = new GridLength(256 + (int)SystemParameters.ScrollWidth);
  67. }
  68. break;
  69. case "UnderLine":
  70. break;
  71. case "Squiggly":
  72. break;
  73. case "Strikeout":
  74. break;
  75. case "Freehand":
  76. break;
  77. case "Freetext":
  78. break;
  79. case "StickyNote":
  80. break;
  81. case "Rect":
  82. break;
  83. case "Circle":
  84. break;
  85. case "Arrow":
  86. break;
  87. case "Line":
  88. break;
  89. case "Stamp":
  90. break;
  91. case "Image":
  92. break;
  93. case "Signature":
  94. break;
  95. case "Link":
  96. break;
  97. }
  98. }
  99. public bool IsNavigationTarget(NavigationContext navigationContext)
  100. {
  101. return true;
  102. }
  103. public void OnNavigatedFrom(NavigationContext navigationContext)
  104. {
  105. }
  106. public void OnNavigatedTo(NavigationContext navigationContext)
  107. {
  108. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  109. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  110. if (PDFViewer != null)
  111. {
  112. }
  113. }
  114. }
  115. }