StickyNoteProperty.xaml.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using ComPDFKitViewer.AnnotEvent;
  2. using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Office.Views.PropertyPanel.AnnotPanel
  18. {
  19. /// <summary>
  20. /// StickyNoteProperty.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class StickyNoteProperty : UserControl
  23. {
  24. private StickyNotePropertyViewModel ViewModel => DataContext as StickyNotePropertyViewModel;
  25. public StickyNoteProperty()
  26. {
  27. InitializeComponent();
  28. }
  29. private void ViewModel_LoadPropertyHandler(object sender, object e)
  30. {
  31. var item = e as AnnotHandlerEventArgs;
  32. switch (item.EventType)
  33. {
  34. case AnnotArgsType.AnnotHighlight:
  35. {
  36. var annot = item as TextHighlightAnnotArgs;
  37. if (annot != null)
  38. {
  39. cusColor.SelectedColor = annot.Color;
  40. SlidOpacity.SetSliOpacity(annot.Transparency);
  41. }
  42. break;
  43. }
  44. case AnnotArgsType.AnnotUnderline:
  45. {
  46. var annot = item as TextUnderlineAnnotArgs;
  47. if (annot != null)
  48. {
  49. cusColor.SelectedColor = annot.Color;
  50. SlidOpacity.SetSliOpacity(annot.Transparency);
  51. }
  52. break;
  53. }
  54. case AnnotArgsType.AnnotStrikeout:
  55. {
  56. var annot = item as TextStrikeoutAnnotArgs;
  57. if (annot != null)
  58. {
  59. cusColor.SelectedColor = annot.Color;
  60. SlidOpacity.SetSliOpacity(annot.Transparency);
  61. }
  62. break;
  63. }
  64. }
  65. }
  66. private void SlidOpacity_SelectedValue(object sender, double e)
  67. {
  68. //if (ViewModel != null)
  69. //{
  70. // ViewModel.SelectedValueChangedCommand?.Execute(e);
  71. //}
  72. }
  73. private void cusColor_SelectedColor(object sender, Color e)
  74. {
  75. //if (ViewModel != null)
  76. //{
  77. // ViewModel.SelectedColorChangedCommand?.Execute(e);
  78. //}
  79. }
  80. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  81. {
  82. if(ViewModel != null)
  83. {
  84. switch(ViewModel.strOtherTag)
  85. {
  86. case "Comment":
  87. BtnComment.IsChecked = true;
  88. break;
  89. case "Note":
  90. BtnNote.IsChecked = true;
  91. break;
  92. case "Key":
  93. BtnKey.IsChecked = true;
  94. break;
  95. case "Help":
  96. BtnHelp.IsChecked = true;
  97. break;
  98. case "Insert":
  99. BtnInsert.IsChecked = true;
  100. break;
  101. case "Paragraph":
  102. BtnParagraph.IsChecked = true;
  103. break;
  104. case "NewParagraph":
  105. BtnNewParagraph.IsChecked = true;
  106. break;
  107. case "None":
  108. BtnComment.IsChecked = false;
  109. BtnNote.IsChecked = false;
  110. BtnKey.IsChecked = false;
  111. BtnHelp.IsChecked = false;
  112. BtnInsert.IsChecked = false;
  113. BtnParagraph.IsChecked = false;
  114. BtnNewParagraph.IsChecked = false;
  115. break;
  116. default:
  117. BtnComment.IsChecked = true;
  118. break;
  119. }
  120. }
  121. // cusColor.SelectedColorHandler -= cusColor_SelectedColor;
  122. // cusColor.SelectedColorHandler += cusColor_SelectedColor;
  123. // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
  124. // SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
  125. // ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
  126. // ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
  127. }
  128. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  129. {
  130. // cusColor.SelectedColorHandler -= cusColor_SelectedColor;
  131. // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
  132. // ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
  133. }
  134. }
  135. }