MeasureControl.xaml.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using Compdfkit_Tools.Helper;
  2. using Compdfkit_Tools.PDFControl;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using ComPDFKitViewer.PdfViewer;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. namespace Compdfkit_Tools.Measure
  21. {
  22. /// <summary>
  23. /// MeasureControl.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class MeasureControl : UserControl
  26. {
  27. public MeasurePropertyControl measurePropertyControl = new MeasurePropertyControl();
  28. private CPDFDisplaySettingsControl displaySettingsControl;
  29. private PDFViewControl PdfViewControl = new PDFViewControl();
  30. private PanelState panelState = PanelState.GetInstance();
  31. public MeasureControl()
  32. {
  33. InitializeComponent();
  34. }
  35. #region Init PDFViewer
  36. public void InitWithPDFViewer(PDFViewControl pdfViewControl, CPDFViewer pdfViewer)
  37. {
  38. PdfViewControl=pdfViewControl;
  39. PdfViewControl.PDFView = pdfViewer;
  40. PDFMeasureTool.InitWithPDFViewer(pdfViewer, measurePropertyControl);
  41. FloatPageTool.InitWithPDFViewer(pdfViewer);
  42. PDFGrid.Child = PdfViewControl;
  43. panelState.PropertyChanged -= PanelState_PropertyChanged;
  44. panelState.PropertyChanged += PanelState_PropertyChanged;
  45. }
  46. public void SetSettingsControl(CPDFDisplaySettingsControl cPDFDisplaySettingsControl)
  47. {
  48. displaySettingsControl = cPDFDisplaySettingsControl;
  49. }
  50. public void ClearAllToolState()
  51. {
  52. PDFMeasureTool.ClearAllToolState();
  53. }
  54. public void ClearViewerControl()
  55. {
  56. PDFGrid.Child = null;
  57. BotaContainer.Child = null;
  58. PropertyContainer.Child = null;
  59. displaySettingsControl=null;
  60. }
  61. private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
  62. {
  63. if (e.PropertyName == nameof(PanelState.IsLeftPanelExpand))
  64. {
  65. ExpandLeftPanel(panelState.IsLeftPanelExpand);
  66. }
  67. else if (e.PropertyName == nameof(PanelState.RightPanel))
  68. {
  69. if (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel)
  70. {
  71. ExpandRightPropertyPanel(measurePropertyControl, Visibility.Visible);
  72. }
  73. else if (panelState.RightPanel == PanelState.RightPanelState.ViewSettings)
  74. {
  75. ExpandRightPropertyPanel(displaySettingsControl, Visibility.Visible);
  76. }
  77. else
  78. {
  79. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  80. }
  81. }
  82. }
  83. #endregion
  84. #region Expand and collapse Panel
  85. public void ExpandRightPropertyPanel(Visibility visible)
  86. {
  87. ExpandRightPropertyPanel(measurePropertyControl, visible);
  88. }
  89. public void ExpandNullRightPropertyPanel(Visibility visible)
  90. {
  91. ExpandRightPropertyPanel(null, visible);
  92. }
  93. public void ExpandViewSettings(Visibility visible)
  94. {
  95. SetViewSettings(displaySettingsControl, visible);
  96. }
  97. private void ExpandRightPropertyPanel(UIElement propertytPanel, Visibility visible)
  98. {
  99. PropertyContainer.Width = 260;
  100. PropertyContainer.Child = propertytPanel;
  101. PropertyContainer.Visibility = visible;
  102. }
  103. private void SetViewSettings(CPDFDisplaySettingsControl displaySettingsControl,Visibility visibility)
  104. {
  105. PropertyContainer.Child = displaySettingsControl;
  106. PropertyContainer.Visibility = visibility;
  107. }
  108. public void ExpandLeftPanel(bool isExpand)
  109. {
  110. BotaContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  111. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  112. if (isExpand)
  113. {
  114. BodyGrid.ColumnDefinitions[0].Width = new GridLength(320);
  115. BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
  116. }
  117. else
  118. {
  119. BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
  120. BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
  121. }
  122. }
  123. #endregion
  124. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  125. {
  126. }
  127. }
  128. }