CPDThicknessUI.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Windows.Controls;
  5. namespace Compdfkit_Tools.Common
  6. {
  7. public partial class CPDFThicknessUI : UserControl, INotifyPropertyChanged
  8. {
  9. public event PropertyChangedEventHandler PropertyChanged;
  10. public event EventHandler ThicknessChanged;
  11. private int _thickness = 1;
  12. public int Thickness
  13. {
  14. get
  15. {
  16. return _thickness;
  17. }
  18. set
  19. {
  20. if (_thickness != value)
  21. {
  22. _thickness = value;
  23. DropDownNumberBoxControl.SelectValueItem(_thickness);
  24. OnPropertyChanged(nameof(Thickness));
  25. OnThicknessChanged();
  26. }
  27. }
  28. }
  29. public CPDFThicknessUI()
  30. {
  31. InitializeComponent();
  32. this.DataContext = this;
  33. InitPresetNumberArray();
  34. }
  35. public void InitPresetNumberArray()
  36. {
  37. List<int> list = new List<int>();
  38. for(int i = 1; i <= 10;i++)
  39. {
  40. list.Add(i);
  41. }
  42. DropDownNumberBoxControl.InitPresetNumberArray(list);
  43. }
  44. private void OnThicknessChanged()
  45. {
  46. ThicknessChanged?.Invoke(this, EventArgs.Empty);
  47. }
  48. protected void OnPropertyChanged(string propertyName)
  49. {
  50. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  51. }
  52. }
  53. }