CPDFViewModeControl.xaml.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using ComPDFKitViewer.PdfViewer;
  2. using System;
  3. using System.Collections.Generic;
  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.PDFControl
  17. {
  18. public partial class CPDFViewModeControl : UserControl
  19. {
  20. public CPDFViewer pdfViewer;
  21. public string CurrentContinuousMode = "Continuous";
  22. public string CurrentViewMode = "Single";
  23. public Dictionary<Tuple<string, string>, ComPDFKitViewer.ViewMode> GetViewMode = new Dictionary<Tuple<string, string>, ComPDFKitViewer.ViewMode>();
  24. public CPDFViewModeControl()
  25. {
  26. InitializeComponent();
  27. CPDFViewModeUI.Loaded += CPDFViewModeUI_Loaded;
  28. }
  29. public void InitWithPDFViewer(CPDFViewer pdfViewer)
  30. {
  31. this.pdfViewer = pdfViewer;
  32. }
  33. private void CPDFViewModeUI_Loaded(object sender, RoutedEventArgs e)
  34. {
  35. GetViewMode.Clear();
  36. GetViewMode.Add(Tuple.Create("Continuous", "Single"), ComPDFKitViewer.ViewMode.SingleContinuous);
  37. GetViewMode.Add(Tuple.Create("Continuous", "Double"), ComPDFKitViewer.ViewMode.DoubleContinuous);
  38. GetViewMode.Add(Tuple.Create("Continuous", "Book"), ComPDFKitViewer.ViewMode.BookContinuous);
  39. GetViewMode.Add(Tuple.Create("Discontinuous", "Single"), ComPDFKitViewer.ViewMode.Single);
  40. GetViewMode.Add(Tuple.Create("Discontinuous", "Double"), ComPDFKitViewer.ViewMode.Double);
  41. GetViewMode.Add(Tuple.Create("Discontinuous", "Book"), ComPDFKitViewer.ViewMode.Book);
  42. CPDFViewModeUI.SetContinuousEvent += CPDFViewModeUI_SetContinuousEvent;
  43. CPDFViewModeUI.SetViewModeEvent += CPDFViewModeUI_SetViewModeEvent;
  44. }
  45. private void CPDFViewModeUI_SetContinuousEvent(object sender, string e)
  46. {
  47. CurrentContinuousMode = (sender as RadioButton).Tag as string;
  48. pdfViewer.ChangeViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
  49. }
  50. private void CPDFViewModeUI_SetViewModeEvent(object sender, string e)
  51. {
  52. CurrentViewMode = (sender as RadioButton).Tag as string;
  53. pdfViewer.ChangeViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
  54. }
  55. }
  56. }