CPDFLineStyleUI.xaml.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Compdfkit_Tools.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Drawing.Drawing2D;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using DashStyle = System.Windows.Media.DashStyle;
  19. namespace Compdfkit_Tools.Common
  20. {
  21. /// <summary>
  22. /// CPDFLineStyleUI.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class CPDFLineStyleUI : UserControl, INotifyPropertyChanged
  25. {
  26. private CPDFDashData _dashStyle = new CPDFDashData();
  27. public CPDFDashData DashStyle
  28. {
  29. get => _dashStyle;
  30. set => _dashStyle = value;
  31. }
  32. private int _dashSpacing = 1;
  33. public int DashSpacing
  34. {
  35. get => _dashSpacing;
  36. set
  37. {
  38. _dashSpacing = value;
  39. DashStyle.DashSpacing = _dashSpacing;
  40. OnDashSpacingChanged();
  41. }
  42. }
  43. private bool _isSolid = true;
  44. public bool IsSolid {
  45. get => _isSolid;
  46. set {
  47. _isSolid = value;
  48. DashStyle.IsSolid = value;
  49. }
  50. }
  51. public event EventHandler LineStyleChanged;
  52. public event PropertyChangedEventHandler PropertyChanged;
  53. public CPDFLineStyleUI()
  54. {
  55. InitializeComponent();
  56. this.DataContext = this;
  57. }
  58. private void RadioButton_Click(object sender, RoutedEventArgs e)
  59. {
  60. RadioButton radioButton = sender as RadioButton;
  61. if (radioButton.Tag.ToString() == "Solid")
  62. {
  63. IsSolid = true;
  64. }
  65. else
  66. {
  67. IsSolid = false;
  68. DashStyle.DashSpacing = DashSpacing;
  69. }
  70. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  71. }
  72. public void OnDashSpacingChanged()
  73. {
  74. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  75. }
  76. protected void OnPropertyChanged(string propertyName)
  77. {
  78. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  79. }
  80. }
  81. }