CPDFLineStyleUI.xaml.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. public event EventHandler LineStyleChanged;
  44. public event PropertyChangedEventHandler PropertyChanged;
  45. public CPDFLineStyleUI()
  46. {
  47. InitializeComponent();
  48. this.DataContext = this;
  49. }
  50. private void RadioButton_Click(object sender, RoutedEventArgs e)
  51. {
  52. RadioButton radioButton = sender as RadioButton;
  53. if (radioButton.Tag.ToString() == "Solid")
  54. {
  55. DashStyle.IsSolid = true;
  56. }
  57. else
  58. {
  59. DashStyle.IsSolid = false;
  60. DashStyle.DashSpacing = DashSpacing;
  61. }
  62. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  63. }
  64. public void OnDashSpacingChanged()
  65. {
  66. LineStyleChanged?.Invoke(this, EventArgs.Empty);
  67. }
  68. protected void OnPropertyChanged(string propertyName)
  69. {
  70. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  71. }
  72. }
  73. }