MeasureControl.xaml.cs 4.7 KB

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