CPDFCloudStyleControl.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using ComPDFKit.PDFAnnotation;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Reflection;
  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 ComPDFKit.Controls.Common
  18. {
  19. /// <summary>
  20. /// Interaction logic for CPDFCloudStyleControl.xaml
  21. /// </summary>
  22. public partial class CPDFCloudStyleControl : UserControl
  23. {
  24. private const string streat = "Streat";
  25. private const string cloud1 = "Cloud1";
  26. private const string cloud2 = "Cloud2";
  27. private bool isChecked = false;
  28. public event EventHandler<CPDFBorderEffector> LineShapeChanged;
  29. private CPDFBorderEffector _borderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_TWO);
  30. public CPDFBorderEffector BorderEffector
  31. {
  32. get
  33. {
  34. return _borderEffector;
  35. }
  36. set
  37. {
  38. _borderEffector = value;
  39. rdoStreat.Checked -= rdoShape_Checked;
  40. rdoCloud1.Checked -= rdoShape_Checked;
  41. rdoCloud2.Checked -= rdoShape_Checked;
  42. if (_borderEffector == null)
  43. {
  44. rdoStreat.IsChecked = true;
  45. }
  46. else if (_borderEffector.BorderType == C_BORDER_TYPE.C_BORDER_TYPE_Cloud)
  47. {
  48. if (_borderEffector.BorderIntensity == C_BORDER_INTENSITY.C_INTENSITY_TWO)
  49. {
  50. rdoCloud1.IsChecked = true;
  51. }
  52. else if (_borderEffector.BorderIntensity == C_BORDER_INTENSITY.C_INTENSITY_ONE)
  53. {
  54. rdoCloud2.IsChecked = true;
  55. }
  56. else
  57. {
  58. rdoStreat.IsChecked = true;
  59. }
  60. }
  61. else
  62. {
  63. rdoStreat.IsChecked = true;
  64. }
  65. // 恢复事件处理程序
  66. rdoStreat.Checked += rdoShape_Checked;
  67. rdoCloud1.Checked += rdoShape_Checked;
  68. rdoCloud2.Checked += rdoShape_Checked;
  69. }
  70. }
  71. public CPDFCloudStyleControl()
  72. {
  73. DataContext = this;
  74. InitializeComponent();
  75. }
  76. private void rdoShape_Checked(object sender, RoutedEventArgs e)
  77. {
  78. switch ((sender as RadioButton).Tag)
  79. {
  80. case streat:
  81. BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT, C_BORDER_INTENSITY.C_INTENSITY_ZERO);
  82. break;
  83. case cloud1:
  84. BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_TWO);
  85. break;
  86. case cloud2:
  87. BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_ONE);
  88. break;
  89. }
  90. LineShapeChanged?.Invoke(this, BorderEffector);
  91. }
  92. }
  93. }