CPDFDisplaySettingsControl.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Compdfkit_Tools.PDFControlUI;
  2. using ComPDFKitViewer;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. namespace Compdfkit_Tools.PDFControl
  7. {
  8. public partial class CPDFDisplaySettingsControl : UserControl
  9. {
  10. /// <summary>
  11. /// PDFViewer
  12. /// </summary>
  13. private PDFViewControl ViewControl;
  14. public CPDFDisplaySettingsControl()
  15. {
  16. InitializeComponent();
  17. Loaded += CPDFDisplaySettingsControl_Loaded;
  18. }
  19. private void CPDFDisplaySettingsControl_Loaded(object sender, RoutedEventArgs e)
  20. {
  21. ViewModeUI.ViewModeChanged += ViewModeUI_ViewModeChanged;
  22. //ViewModeUI.SplitModeChanged += ViewModeUI_SplitModeChanged;
  23. ViewModeUI.CropModeChanged += ViewModeUI_CropModeChanged;
  24. DrawModeUI.DrawModeChanged += DrawModeUI_DrawModeChanged;
  25. }
  26. private void ViewModeUI_CropModeChanged(object sender, bool e)
  27. {
  28. //ViewControl?.SetCropMode(e);
  29. }
  30. private void DrawModeUI_DrawModeChanged(object sender, DrawModeData e)
  31. {
  32. if(ViewControl!=null && ViewControl.PDFViewTool!=null)
  33. {
  34. CPDFViewer pdfViewer=ViewControl.PDFViewTool.GetCPDFViewer();
  35. if(pdfViewer!=null)
  36. {
  37. if (e.DrawMode != DrawModess.Custom)
  38. {
  39. pdfViewer?.SetDrawModes(e.DrawMode);
  40. pdfViewer?.UpDateRenderFrame();
  41. }
  42. else
  43. {
  44. pdfViewer?.SetDrawModes(e.DrawMode);
  45. pdfViewer?.SetPDFBackground(e.CustomColor);
  46. pdfViewer?.UpDateRenderFrame();
  47. }
  48. }
  49. }
  50. }
  51. //private void ViewModeUI_SplitModeChanged(object sender, SplitMode e)
  52. //{
  53. // ViewControl?.SetSplitMode(e);
  54. //}
  55. private void ViewModeUI_ViewModeChanged(object sender, ViewModes e)
  56. {
  57. if (ViewControl != null && ViewControl.PDFViewTool != null)
  58. {
  59. CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
  60. if (pdfViewer != null)
  61. {
  62. pdfViewer?.SetViewMode(e);
  63. pdfViewer?.UpDateRenderFrame();
  64. }
  65. }
  66. }
  67. public void InitWithPDFViewer(PDFViewControl viewControl)
  68. {
  69. ViewControl = viewControl;
  70. if(ViewControl != null && ViewControl.PDFViewTool!=null)
  71. {
  72. CPDFViewer pdfViewer= viewControl.PDFViewTool.GetCPDFViewer();
  73. if(pdfViewer != null)
  74. {
  75. ViewModeUI.SetViewModeUI(pdfViewer.GetViewMode());
  76. // ViewModeUI.SetSplitModeUI(ViewControl.Mode);
  77. //ViewModeUI.SetCropUI(ViewControl.IsCropMode());
  78. }
  79. }
  80. }
  81. public void SetVisibilityWhenContentEdit(Visibility visible)
  82. {
  83. ViewModeUI?.SetSplitContainerVisibility(visible);
  84. ViewModeUI?.SetCropContainerVisibility(visible);
  85. }
  86. }
  87. }