CPDFViewModeControl.xaml.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using ComPDFKitViewer;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. namespace Compdfkit_Tools.PDFControl
  7. {
  8. public partial class CPDFViewModeControl : UserControl
  9. {
  10. public PDFViewControl ViewControl;
  11. public string CurrentContinuousMode = "Continuous";
  12. public string CurrentViewMode = "Single";
  13. public Dictionary<Tuple<string, string>, ViewModes> GetViewMode = new Dictionary<Tuple<string, string>, ViewModes>();
  14. public CPDFViewModeControl()
  15. {
  16. InitializeComponent();
  17. CPDFViewModeUI.Loaded += CPDFViewModeUI_Loaded;
  18. }
  19. public void InitWithPDFViewer(PDFViewControl viewControl)
  20. {
  21. this.ViewControl = viewControl;
  22. }
  23. private void CPDFViewModeUI_Loaded(object sender, RoutedEventArgs e)
  24. {
  25. GetViewMode.Clear();
  26. GetViewMode.Add(Tuple.Create("Continuous", "Single"), ViewModes.SingleContinuous);
  27. GetViewMode.Add(Tuple.Create("Continuous", "Double"), ViewModes.DoubleContinuous);
  28. GetViewMode.Add(Tuple.Create("Continuous", "Book"), ViewModes.BookContinuous);
  29. GetViewMode.Add(Tuple.Create("Discontinuous", "Single"), ViewModes.Single);
  30. GetViewMode.Add(Tuple.Create("Discontinuous", "Double"), ViewModes.Double);
  31. GetViewMode.Add(Tuple.Create("Discontinuous", "Book"), ViewModes.Book);
  32. CPDFViewModeUI.SetContinuousEvent += CPDFViewModeUI_SetContinuousEvent;
  33. CPDFViewModeUI.SetViewModeEvent += CPDFViewModeUI_SetViewModeEvent;
  34. }
  35. private void CPDFViewModeUI_SetContinuousEvent(object sender, string e)
  36. {
  37. CurrentContinuousMode = (sender as RadioButton).Tag as string;
  38. if (ViewControl != null && ViewControl.PDFViewTool != null)
  39. {
  40. CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
  41. pdfViewer?.SetViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
  42. }
  43. }
  44. private void CPDFViewModeUI_SetViewModeEvent(object sender, string e)
  45. {
  46. CurrentViewMode = (sender as RadioButton).Tag as string;
  47. if (ViewControl != null && ViewControl.PDFViewTool != null)
  48. {
  49. CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
  50. pdfViewer?.SetViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
  51. }
  52. }
  53. }
  54. }