CPDFOpactiyUI.xaml.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 CPDFOpacityUI : UserControl, INotifyPropertyChanged
  8. {
  9. private int _opacityValue = 100;
  10. public int OpacityValue
  11. {
  12. get
  13. {
  14. return _opacityValue;
  15. }
  16. set
  17. {
  18. _opacityValue = value;
  19. DropDownNumberBoxControl?.SelectValueItem(OpacityValue);
  20. OnPropertyChanged(nameof(OpacityValue));
  21. OnOpacityChanged();
  22. }
  23. }
  24. public event EventHandler OpacityChanged;
  25. public event PropertyChangedEventHandler PropertyChanged;
  26. public CPDFOpacityUI()
  27. {
  28. InitializeComponent();
  29. this.DataContext = this;
  30. InitPresetNumberArray();
  31. }
  32. public void InitPresetNumberArray()
  33. {
  34. List<int> list = new List<int>();
  35. list.Add(25);
  36. list.Add(50);
  37. list.Add(75);
  38. list.Add(100);
  39. DropDownNumberBoxControl.InitPresetNumberArray(list);
  40. }
  41. private void OnOpacityChanged()
  42. {
  43. OpacityChanged?.Invoke(this, EventArgs.Empty);
  44. }
  45. protected void OnPropertyChanged(string propertyName)
  46. {
  47. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  48. }
  49. }
  50. }