1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using ComPDFKitViewer;
- using System;
- using System.Collections.Generic;
- using System.Windows;
- using System.Windows.Controls;
- namespace Compdfkit_Tools.PDFControl
- {
- public partial class CPDFViewModeControl : UserControl
- {
- public PDFViewControl ViewControl;
- public string CurrentContinuousMode = "Continuous";
- public string CurrentViewMode = "Single";
- public Dictionary<Tuple<string, string>, ViewModes> GetViewMode = new Dictionary<Tuple<string, string>, ViewModes>();
-
- public CPDFViewModeControl()
- {
- InitializeComponent();
- CPDFViewModeUI.Loaded += CPDFViewModeUI_Loaded;
- }
- public void InitWithPDFViewer(PDFViewControl viewControl)
- {
- this.ViewControl = viewControl;
- }
- private void CPDFViewModeUI_Loaded(object sender, RoutedEventArgs e)
- {
- GetViewMode.Clear();
- GetViewMode.Add(Tuple.Create("Continuous", "Single"), ViewModes.SingleContinuous);
- GetViewMode.Add(Tuple.Create("Continuous", "Double"), ViewModes.DoubleContinuous);
- GetViewMode.Add(Tuple.Create("Continuous", "Book"), ViewModes.BookContinuous);
- GetViewMode.Add(Tuple.Create("Discontinuous", "Single"), ViewModes.Single);
- GetViewMode.Add(Tuple.Create("Discontinuous", "Double"), ViewModes.Double);
- GetViewMode.Add(Tuple.Create("Discontinuous", "Book"), ViewModes.Book);
- CPDFViewModeUI.SetContinuousEvent += CPDFViewModeUI_SetContinuousEvent;
- CPDFViewModeUI.SetViewModeEvent += CPDFViewModeUI_SetViewModeEvent;
- }
- private void CPDFViewModeUI_SetContinuousEvent(object sender, string e)
- {
- CurrentContinuousMode = (sender as RadioButton).Tag as string;
- if (ViewControl != null && ViewControl.PDFViewTool != null)
- {
- CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
- pdfViewer?.SetViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
- }
- }
- private void CPDFViewModeUI_SetViewModeEvent(object sender, string e)
- {
- CurrentViewMode = (sender as RadioButton).Tag as string;
- if (ViewControl != null && ViewControl.PDFViewTool != null)
- {
- CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
- pdfViewer?.SetViewMode(GetViewMode[Tuple.Create(CurrentContinuousMode, CurrentViewMode)]);
- }
- }
- }
- }
|