Jelajahi Sumber

splitview - 窗口缩放时对splitview区域的大小修改

sunhaonan 11 bulan lalu
induk
melakukan
c0f382ff1a

+ 24 - 0
Demo/Examples/Compdfkit_Tools/PDFView/PDFViewControl/PDFViewControl.xaml.cs

@@ -45,6 +45,9 @@ namespace Compdfkit_Tools.PDFControl
 
         #region Properties
 
+        private double splitWidthScale = 0.5;
+        private double splitHeightScale = 0.5;
+
         public bool CustomSignHandle { get; set; }
 
         private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
@@ -89,6 +92,7 @@ namespace Compdfkit_Tools.PDFControl
             splitToolManager.MouseLeftButtonDownHandler -= PDFToolManager_MouseLeftButtonDownHandler;
             splitToolManager.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler;
             splitToolManager.MouseMoveHandler -= PDFToolManager_MouseMoveHandler;
+            splitToolManager.AnnotDefaultEditedHandler -= PDFToolManager_AnnotDefaultEditedHandler;
 
             splitViewerTool.SizeChanged += SplitViewerTool_SizeChanged;
             splitViewerTool.GetCPDFViewer().MouseWheelZoomHandler += SplitPDFViewControl_MouseWheelZoomHandler;
@@ -137,6 +141,14 @@ namespace Compdfkit_Tools.PDFControl
 
         private void SplitViewerTool_SizeChanged(object sender, SizeChangedEventArgs e)
         {
+            if (VerticalView.Visibility == Visibility.Visible)
+            {
+                splitWidthScale = VerticalView.ActualWidth / ViewToolGrid.ActualWidth;
+            }
+            if (HorizontalView.Visibility == Visibility.Visible)
+            {
+                splitHeightScale = HorizontalView.ActualHeight / ViewToolGrid.ActualHeight;
+            }
             splitViewerTool.GetCPDFViewer().UpDateRenderFrame();
         }
 
@@ -329,6 +341,18 @@ namespace Compdfkit_Tools.PDFControl
             HorizontalView.Child = null;
         }
 
+        public void WindowSizeChange()
+        {
+            if(VerticalView.Visibility == Visibility.Visible)
+            {
+                ViewToolGrid.ColumnDefinitions[2].Width = new GridLength(ViewToolGrid.ActualWidth * splitWidthScale);
+            }
+            if(HorizontalView.Visibility == Visibility.Visible)
+            {
+                ViewToolGrid.RowDefinitions[2].Height = new GridLength(ViewToolGrid.ActualHeight * splitHeightScale);
+            }
+        }
+
         private void PDFView_GotFocus(object sender, RoutedEventArgs e)
         {
             switch((sender as Border).Tag)

+ 8 - 0
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -146,6 +146,9 @@ namespace PDFViewer
                     return;
                 }
 
+                SizeChanged -= MainPage_SizeChanged;
+                SizeChanged += MainPage_SizeChanged;
+
                 //viewControl.PDFView.Load();
                 //viewControl.PDFView.SetShowLink(true);
 
@@ -178,6 +181,11 @@ namespace PDFViewer
             }
         }
 
+        private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
+        {
+            viewControl.WindowSizeChange();
+        }
+
         private void DisplaySettingsControl_SplitModeChanged(object sender, Compdfkit_Tools.PDFControlUI.CPDFViewModeUI.SplitMode e)
         {
             viewControl.SetSplitViewMode(e);