CPDFDrawModeControl.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using ComPDFKitViewer;
  2. using System.Collections.Generic;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. namespace ComPDFKit.Controls.PDFControl
  6. {
  7. public partial class CPDFDrawModeControl : UserControl
  8. {
  9. public PDFViewControl ViewControl;
  10. public Dictionary<string, DrawMode> GetDrawMode = new Dictionary<string, DrawMode>();
  11. public CPDFDrawModeControl()
  12. {
  13. InitializeComponent();
  14. CPDFDrawModeUI.Loaded += CPDFDrawModeUI_Loaded;
  15. }
  16. private void CPDFDrawModeUI_Loaded(object sender, RoutedEventArgs e)
  17. {
  18. GetDrawMode.Clear();
  19. GetDrawMode.Add("Normal", DrawMode.Normal);
  20. GetDrawMode.Add("Soft", DrawMode.Soft);
  21. GetDrawMode.Add("Dark", DrawMode.Dark);
  22. GetDrawMode.Add("Green", DrawMode.Green);
  23. GetDrawMode.Add("Custom", DrawMode.Custom);
  24. CPDFDrawModeUI.SetDrawModeEvent -= CPDFDrawModeUI_SetDrawModeEvent;
  25. CPDFDrawModeUI.SetDrawModeEvent += CPDFDrawModeUI_SetDrawModeEvent;
  26. }
  27. private void CPDFDrawModeUI_SetDrawModeEvent(object sender, string e)
  28. {
  29. if(ViewControl != null && ViewControl.PDFViewTool!=null)
  30. {
  31. CPDFViewer pdfViewer=ViewControl.PDFViewTool.GetCPDFViewer();
  32. pdfViewer?.SetDrawModes(GetDrawMode[(sender as RadioButton).Tag as string]);
  33. }
  34. }
  35. public void InitWithPDFViewer(PDFViewControl viewControl)
  36. {
  37. this.ViewControl = viewControl;
  38. }
  39. }
  40. }