CPDThicknessUI.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. _thickness = value;
  21. DropDownNumberBoxControl.SelectValueItem(_thickness);
  22. OnPropertyChanged(nameof(Thickness));
  23. OnThicknessChanged();
  24. }
  25. }
  26. public CPDFThicknessUI()
  27. {
  28. InitializeComponent();
  29. this.DataContext = this;
  30. InitPresetNumberArray();
  31. }
  32. public void InitPresetNumberArray()
  33. {
  34. List<int> list = new List<int>();
  35. for(int i = 1; i <= 10;i++)
  36. {
  37. list.Add(i);
  38. }
  39. DropDownNumberBoxControl.InitPresetNumberArray(list);
  40. }
  41. private void OnThicknessChanged()
  42. {
  43. ThicknessChanged?.Invoke(this, EventArgs.Empty);
  44. }
  45. protected void OnPropertyChanged(string propertyName)
  46. {
  47. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  48. }
  49. }
  50. }