CPDFPageTurningUI.xaml.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using ComPDFKit.NativeMethod;
  2. using ComPDFKitViewer.PdfViewer;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace compdfkit_tools.PDFControlUI
  19. {
  20. /// <summary>
  21. /// pdfpageturning.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class CPDFPageTurningUI : UserControl, INotifyPropertyChanged
  24. {
  25. public Key EnsureKey { get; set; }
  26. /// <summary>
  27. /// 跳转指定页事件
  28. /// </summary>
  29. public event EventHandler<int> GoToSpecificPageEvent;
  30. /// <summary>
  31. /// 跳转下一页事件
  32. /// </summary>
  33. public event EventHandler GoToNextPageEvent;
  34. /// <summary>
  35. /// 跳转上一页事件
  36. /// </summary>
  37. public event EventHandler GoToPreviousPageEvent;
  38. /// <summary>
  39. /// 跳转首页
  40. /// </summary>
  41. public event EventHandler GoToFirstPageEvent;
  42. /// <summary>
  43. /// 跳转末页
  44. /// </summary>
  45. public event EventHandler GotoLastPageEvent;
  46. /// <summary>
  47. /// 当前页码
  48. /// </summary>
  49. private int _pageIndex = 1;
  50. public int PageIndex
  51. {
  52. get { return _pageIndex; }
  53. set
  54. {
  55. if (_pageIndex != value)
  56. {
  57. _pageIndex = value;
  58. OnPropertyChanged(nameof(PageIndex));
  59. }
  60. }
  61. }
  62. public CPDFPageTurningUI()
  63. {
  64. InitializeComponent();
  65. DataContext = this;
  66. }
  67. /// <summary>
  68. /// 回车跳转指定页
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void PageIndexTexBox_KeyDown(object sender, KeyEventArgs e)
  73. {
  74. if (e.Key == EnsureKey)
  75. {
  76. GoToSpecificPageEvent?.Invoke(sender, PageIndex);
  77. }
  78. }
  79. private void GoToPreviousPageButton_Click(object sender, RoutedEventArgs e)
  80. {
  81. GoToPreviousPageEvent?.Invoke(sender, e);
  82. }
  83. private void GoToNextPageButton_Click(object sender, RoutedEventArgs e)
  84. {
  85. GoToNextPageEvent?.Invoke(sender, e);
  86. }
  87. public event PropertyChangedEventHandler PropertyChanged;
  88. protected void OnPropertyChanged(string propertyName)
  89. {
  90. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  91. }
  92. }
  93. }