CPDFLineStyleUI.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using ComPDFKit.Controls.Data;
  2. using System;
  3. using System.ComponentModel;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using DashStyle = System.Windows.Media.DashStyle;
  7. namespace ComPDFKit.Controls.Common
  8. {
  9. public partial class CPDFLineStyleUI : UserControl, INotifyPropertyChanged
  10. {
  11. private CPDFDashData _dashStyle = new CPDFDashData();
  12. public CPDFDashData DashStyle
  13. {
  14. get => _dashStyle;
  15. set => _dashStyle = value;
  16. }
  17. private int _dashSpacing = 1;
  18. public int DashSpacing
  19. {
  20. get => _dashSpacing;
  21. set
  22. {
  23. _dashSpacing = value;
  24. DashStyle.DashSpacing = _dashSpacing;
  25. OnDashSpacingChanged();
  26. }
  27. }
  28. private bool _isSolid = true;
  29. public bool IsSolid {
  30. get => _isSolid;
  31. set {
  32. _isSolid = value;
  33. DashStyle.IsSolid = value;
  34. }
  35. }
  36. public event EventHandler LineStyleChanged;
  37. public event PropertyChangedEventHandler PropertyChanged;
  38. public CPDFLineStyleUI()
  39. {
  40. InitializeComponent();
  41. this.DataContext = this;
  42. }
  43. private void RadioButton_Click(object sender, RoutedEventArgs e)
  44. {
  45. RadioButton radioButton = sender as RadioButton;
  46. if (radioButton.Tag.ToString() == "Solid")
  47. {
  48. IsSolid = true;
  49. }
  50. else
  51. {
  52. IsSolid = false;
  53. DashStyle.DashSpacing = DashSpacing;
  54. }
  55. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  56. }
  57. public void OnDashSpacingChanged()
  58. {
  59. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  60. }
  61. protected void OnPropertyChanged(string propertyName)
  62. {
  63. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  64. }
  65. }
  66. }