CPDFOpactiyUI.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /// OpactiyControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class CPDFOpacityUI : UserControl, INotifyPropertyChanged
  22. {
  23. private int _opacityValue = 100;
  24. public int OpacityValue
  25. {
  26. get
  27. {
  28. return _opacityValue;
  29. }
  30. set
  31. {
  32. _opacityValue = value;
  33. OnPropertyChanged(nameof(OpacityValue));
  34. OnOpacityChanged();
  35. }
  36. }
  37. //public event EventHandler<string> SetCustomOpacityEvent;
  38. //public event EventHandler<string> SetPresetOpacityEvent;
  39. //public event EventHandler<int> SliderValueChangedEvent;
  40. //public event EventHandler<int> SliderDragCompleted;
  41. public event EventHandler OpacityChanged;
  42. public event PropertyChangedEventHandler PropertyChanged;
  43. public CPDFOpacityUI()
  44. {
  45. InitializeComponent();
  46. this.DataContext = this;
  47. InitPresetNumberArray();
  48. }
  49. public void InitPresetNumberArray()
  50. {
  51. List<int> list = new List<int>();
  52. list.Add(25);
  53. list.Add(50);
  54. list.Add(75);
  55. list.Add(100);
  56. DropDownNumberBoxControl.InitPresetNumberArray(list);
  57. }
  58. private void OnOpacityChanged()
  59. {
  60. OpacityChanged?.Invoke(this, EventArgs.Empty);
  61. }
  62. protected void OnPropertyChanged(string propertyName)
  63. {
  64. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  65. }
  66. }
  67. }