StickyNoteProperty.xaml.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using ComPDFKitViewer.AnnotEvent;
  2. using Microsoft.Office.Interop.Excel;
  3. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Markup;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace PDF_Master.Views.PropertyPanel.AnnotPanel
  21. {
  22. /// <summary>
  23. /// StickyNoteProperty.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class StickyNoteProperty : UserControl
  26. {
  27. private StickyNotePropertyViewModel ViewModel => DataContext as StickyNotePropertyViewModel;
  28. public StickyNoteProperty()
  29. {
  30. InitializeComponent();
  31. cusColor.SelectedColorHandler += cusColor_SelectedColor;
  32. }
  33. private void ViewModel_LoadPropertyHandler(object sender, object e)
  34. {
  35. var item = e as AnnotHandlerEventArgs;
  36. switch (item.EventType)
  37. {
  38. case AnnotArgsType.AnnotHighlight:
  39. {
  40. var annot = item as TextHighlightAnnotArgs;
  41. if (annot != null)
  42. {
  43. cusColor.SelectedColor = annot.Color;
  44. SlidOpacity.SetSliOpacity(annot.Transparency);
  45. }
  46. break;
  47. }
  48. case AnnotArgsType.AnnotUnderline:
  49. {
  50. var annot = item as TextUnderlineAnnotArgs;
  51. if (annot != null)
  52. {
  53. cusColor.SelectedColor = annot.Color;
  54. SlidOpacity.SetSliOpacity(annot.Transparency);
  55. }
  56. break;
  57. }
  58. case AnnotArgsType.AnnotStrikeout:
  59. {
  60. var annot = item as TextStrikeoutAnnotArgs;
  61. if (annot != null)
  62. {
  63. cusColor.SelectedColor = annot.Color;
  64. SlidOpacity.SetSliOpacity(annot.Transparency);
  65. }
  66. break;
  67. }
  68. }
  69. }
  70. private void SlidOpacity_SelectedValue(object sender, double e)
  71. {
  72. //if (ViewModel != null)
  73. //{
  74. // ViewModel.SelectedValueChangedCommand?.Execute(e);
  75. //}
  76. }
  77. private void cusColor_SelectedColor(object sender, Color e)
  78. {
  79. if (ViewModel != null)
  80. {
  81. ViewModel.SelectedColorChangedCommand?.Execute(e);
  82. }
  83. }
  84. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  85. {
  86. if (ViewModel != null)
  87. {
  88. var converter = TypeDescriptor.GetConverter(typeof(Geometry));
  89. switch (ViewModel.strOtherTag)
  90. {
  91. case "Comment":
  92. BtnComment.IsChecked = true;
  93. var dataComment = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  94. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataComment);
  95. break;
  96. case "Note":
  97. BtnNote.IsChecked = true;
  98. var dataNote = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  99. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataNote);
  100. break;
  101. case "Key":
  102. BtnKey.IsChecked = true;
  103. var dataKey = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  104. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataKey);
  105. break;
  106. case "Help":
  107. BtnHelp.IsChecked = true;
  108. var dataHelp = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  109. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataHelp);
  110. break;
  111. case "Insert":
  112. BtnInsert.IsChecked = true;
  113. var dataInsert = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  114. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataInsert);
  115. break;
  116. case "Paragraph":
  117. BtnParagraph.IsChecked = true;
  118. var dataParagraph = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  119. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataParagraph);
  120. break;
  121. case "NewParagraph":
  122. BtnNewParagraph.IsChecked = true;
  123. var dataNewParagraph = ViewModel.StickyNoteTypes[ViewModel.strOtherTag];
  124. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(dataNewParagraph);
  125. break;
  126. case "None":
  127. BtnComment.IsChecked = false;
  128. BtnNote.IsChecked = false;
  129. BtnKey.IsChecked = false;
  130. BtnHelp.IsChecked = false;
  131. BtnInsert.IsChecked = false;
  132. BtnParagraph.IsChecked = false;
  133. BtnNewParagraph.IsChecked = false;
  134. break;
  135. default:
  136. BtnComment.IsChecked = true;
  137. var datacomment = ViewModel.StickyNoteTypes["Comment"];
  138. ViewModel.ExmpleData = (Geometry)converter.ConvertFrom(datacomment);
  139. break;
  140. }
  141. if (ViewModel.IsFirst)
  142. {
  143. //暂时解决方案,让其先等于高保真所需的默认值,然后在变为注释setting默认颜色值
  144. ViewModel.SharpCurrentColor = App.Current.FindResource("color.sys.layout.divider.note") as Brush;
  145. ViewModel.SharpColor = ViewModel.SharpColor;
  146. ViewModel.IsFirst = false;
  147. }
  148. }
  149. // cusColor.SelectedColorHandler -= cusColor_SelectedColor;
  150. // cusColor.SelectedColorHandler += cusColor_SelectedColor;
  151. // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
  152. // SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
  153. // ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
  154. // ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
  155. }
  156. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  157. {
  158. // cusColor.SelectedColorHandler -= cusColor_SelectedColor;
  159. // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
  160. // ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
  161. }
  162. }
  163. }