123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using ComPDFKit.NativeMethod;
- using ComPDFKitViewer.PdfViewer;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace compdfkit_tools.PDFControlUI
- {
- /// <summary>
- /// pdfpageturning.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFPageTurningUI : UserControl, INotifyPropertyChanged
- {
- public Key EnsureKey { get; set; }
- /// <summary>
- /// 跳转指定页事件
- /// </summary>
- public event EventHandler<int> GoToSpecificPageEvent;
- /// <summary>
- /// 跳转下一页事件
- /// </summary>
- public event EventHandler GoToNextPageEvent;
- /// <summary>
- /// 跳转上一页事件
- /// </summary>
- public event EventHandler GoToPreviousPageEvent;
- /// <summary>
- /// 跳转首页
- /// </summary>
- public event EventHandler GoToFirstPageEvent;
- /// <summary>
- /// 跳转末页
- /// </summary>
- public event EventHandler GotoLastPageEvent;
- /// <summary>
- /// 当前页码
- /// </summary>
- private int _pageIndex = 1;
- public int PageIndex
- {
- get { return _pageIndex; }
- set
- {
- if (_pageIndex != value)
- {
- _pageIndex = value;
- OnPropertyChanged(nameof(PageIndex));
- }
- }
- }
- public CPDFPageTurningUI()
- {
- InitializeComponent();
- DataContext = this;
- }
- /// <summary>
- /// 回车跳转指定页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PageIndexTexBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == EnsureKey)
- {
- GoToSpecificPageEvent?.Invoke(sender, PageIndex);
- }
- }
- private void GoToPreviousPageButton_Click(object sender, RoutedEventArgs e)
- {
- GoToPreviousPageEvent?.Invoke(sender, e);
- }
- private void GoToNextPageButton_Click(object sender, RoutedEventArgs e)
- {
- GoToNextPageEvent?.Invoke(sender, e);
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged(string propertyName)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
|