TextAnnotProperty.xaml.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using PDF_Office.Properties;
  4. using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
  5. using PDFSettings;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace PDF_Office.Views.PropertyPanel.AnnotPanel
  21. {
  22. /// <summary>
  23. /// TextAnnotProperty.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class TextAnnotProperty : UserControl
  26. {
  27. private TextAnnotPropertyViewModel ViewModel =>DataContext as TextAnnotPropertyViewModel;
  28. public TextAnnotProperty()
  29. {
  30. InitializeComponent();
  31. cusColor.SelectedColorHandler += cusColor_SelectedColor;
  32. SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
  33. ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
  34. }
  35. private void ViewModel_LoadPropertyHandler(object sender, object e)
  36. {
  37. var item = e as AnnotHandlerEventArgs;
  38. switch (item.EventType)
  39. {
  40. case AnnotArgsType.AnnotHighlight:
  41. {
  42. var annot = item as TextHighlightAnnotArgs;
  43. if (annot != null)
  44. {
  45. cusColor.SetSelectedColor(annot.Color);
  46. SlidOpacity.SetSliOpacity(annot.Transparency);
  47. }
  48. break;
  49. }
  50. case AnnotArgsType.AnnotUnderline:
  51. {
  52. var annot = item as TextUnderlineAnnotArgs;
  53. if (annot != null)
  54. {
  55. cusColor.SetSelectedColor(annot.Color);
  56. SlidOpacity.SetSliOpacity(annot.Transparency);
  57. }
  58. break;
  59. }
  60. case AnnotArgsType.AnnotStrikeout:
  61. {
  62. var annot = item as TextStrikeoutAnnotArgs;
  63. if (annot != null)
  64. {
  65. cusColor.SetSelectedColor(annot.Color);
  66. SlidOpacity.SetSliOpacity(annot.Transparency);
  67. }
  68. break;
  69. }
  70. }
  71. }
  72. private void SlidOpacity_SelectedValue(object sender, double e)
  73. {
  74. if (ViewModel != null)
  75. {
  76. ViewModel.SelectedValueChangedCommand?.Execute(e);
  77. }
  78. }
  79. private void cusColor_SelectedColor(object sender, Color e)
  80. {
  81. if (ViewModel != null)
  82. {
  83. ViewModel.SelectedColorChangedCommand?.Execute(e);
  84. }
  85. }
  86. private void OpacitySlider_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
  87. {
  88. }
  89. private void OpacitySlider_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
  90. {
  91. }
  92. private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
  93. {
  94. }
  95. private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
  96. {
  97. if(ViewModel != null)
  98. {
  99. ViewModel.SelectedColorChangedCommand?.Execute(e.Value);
  100. }
  101. }
  102. }
  103. }