CPDThicknessUI.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace Compdfkit_Tools.Common
  17. {
  18. /// <summary>
  19. /// CPDFBorderWidthUI.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class CPDFThicknessUI : UserControl, INotifyPropertyChanged
  22. {
  23. public event PropertyChangedEventHandler PropertyChanged;
  24. public event EventHandler ThicknessChanged;
  25. private int _thickness = 1;
  26. public int Thickness
  27. {
  28. get
  29. {
  30. return _thickness;
  31. }
  32. set
  33. {
  34. _thickness = value;
  35. DropDownNumberBoxControl.SelectValueItem(_thickness);
  36. OnPropertyChanged(nameof(Thickness));
  37. OnThicknessChanged();
  38. }
  39. }
  40. public CPDFThicknessUI()
  41. {
  42. InitializeComponent();
  43. this.DataContext = this;
  44. InitPresetNumberArray();
  45. }
  46. public void InitPresetNumberArray()
  47. {
  48. List<int> list = new List<int>();
  49. for(int i = 1; i <= 10;i++)
  50. {
  51. list.Add(i);
  52. }
  53. DropDownNumberBoxControl.InitPresetNumberArray(list);
  54. }
  55. private void OnThicknessChanged()
  56. {
  57. ThicknessChanged?.Invoke(this, EventArgs.Empty);
  58. }
  59. protected void OnPropertyChanged(string propertyName)
  60. {
  61. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  62. }
  63. }
  64. }