CPDFScalingUI.xaml.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using compdfkit_tools.Common;
  2. using ComPDFKitViewer.PdfViewer;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace compdfkit_tools.PDFControlUI
  20. {
  21. /// <summary>
  22. /// PDFScalingControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class CPDFScalingUI : UserControl, INotifyPropertyChanged
  25. {
  26. public CPDFViewer PDFView { get; set; }
  27. private int _scale = 100;
  28. public int Scale
  29. {
  30. get { return _scale; }
  31. set
  32. {
  33. if (_scale != value)
  34. {
  35. _scale = value;
  36. OnPropertyChanged(nameof(Scale));
  37. }
  38. }
  39. }
  40. public event EventHandler<string> SetScaleEvent;
  41. public event EventHandler<string> SetPresetScaleEvent;
  42. public event EventHandler ScaleIncreaseEvent;
  43. public event EventHandler ScaleDecreaseEvent;
  44. public CPDFScalingUI()
  45. {
  46. InitializeComponent();
  47. DataContext = this;
  48. DropDownNumberBoxControl.InputEnterEvent += DropDownNumberBoxControl_InputEnterEvent;
  49. DropDownNumberBoxControl.SetPresetEvent += DropDownNumberBoxControl_SetPresetEvent;
  50. InitPresetNumberArray();
  51. }
  52. private void DropDownNumberBoxControl_SetPresetEvent(object sender, string e)
  53. {
  54. SetPresetScaleEvent?.Invoke(this, e);
  55. }
  56. public void InitPresetNumberArray()
  57. {
  58. List<int> list = new List<int>();
  59. list.Add(25);
  60. list.Add(50);
  61. list.Add(100);
  62. list.Add(200);
  63. list.Add(400);
  64. list.Add(800);
  65. list.Add(1600);
  66. DropDownNumberBoxControl.InitPresetNumberArray(list);
  67. }
  68. private void DropDownNumberBoxControl_InputEnterEvent(object sender, string e)
  69. {
  70. SetScaleEvent?.Invoke(this,e);
  71. }
  72. private void ScaleDecreaseButton_Click(object sender, RoutedEventArgs e)
  73. {
  74. ScaleDecreaseEvent?.Invoke(this,e);
  75. }
  76. private void ScaleIncreaseButton_Click(object sender, RoutedEventArgs e)
  77. {
  78. ScaleIncreaseEvent?.Invoke(this,e);
  79. }
  80. public event PropertyChangedEventHandler PropertyChanged;
  81. protected void OnPropertyChanged(string propertyName)
  82. {
  83. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  84. }
  85. }
  86. }