Forráskód Böngészése

splitview - 更新选中pdfViewTool的缩放和页码信息,处理splitView初始化,补充遗漏代码

sunhaonan 11 hónapja
szülő
commit
a975244797

+ 7 - 0
Demo/Examples/Compdfkit_Tools/Common/BaseControl/PageNumberControl.xaml.cs

@@ -30,11 +30,18 @@ namespace Compdfkit_Tools.Common
                 if (pdfView != null)
                 {
                     pdfView.DrawChanged -= PdfView_InfoChanged;
+                    pdfView.FocusPDFViewToolChanged -= PdfView_FocusPDFViewToolChanged;
                     pdfView.DrawChanged += PdfView_InfoChanged;
+                    pdfView.FocusPDFViewToolChanged += PdfView_FocusPDFViewToolChanged;
                 }
             }
         }
 
+        private void PdfView_FocusPDFViewToolChanged(object sender, EventArgs e)
+        {
+            PageRangeText.Text = $"{pdfView.GetCPDFViewer().CurrentRenderFrame.PageIndex+1}/{pdfView.GetCPDFViewer().GetDocument().PageCount}";
+        }
+
         private void PdfView_InfoChanged(object sender, EventArgs e)
         {
             if (sender is CPDFViewerTool)

+ 8 - 0
Demo/Examples/Compdfkit_Tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs

@@ -36,12 +36,20 @@ namespace Compdfkit_Tools.PDFControl
             CPDFScalingUI.ScaleDecreaseEvent -= PDFScalingControl_ScaleDecreaseEvent;
             CPDFScalingUI.SetPresetScaleEvent -= CPDFScalingUI_SetPresetScaleEvent;
             ViewControl.MouseWheelZoomHandler -= PDFControl_MouseWheelZoomHandler;
+            ViewControl.FocusPDFViewToolChanged -= ViewControl_FocusPDFViewToolChanged;
 
             CPDFScalingUI.SetScaleEvent += PDFScalingControl_SetScaleEvent;
             CPDFScalingUI.ScaleIncreaseEvent += PDFScalingControl_ScaleIncreaseEvent;
             CPDFScalingUI.ScaleDecreaseEvent += PDFScalingControl_ScaleDecreaseEvent;
             CPDFScalingUI.SetPresetScaleEvent += CPDFScalingUI_SetPresetScaleEvent;
             ViewControl.MouseWheelZoomHandler += PDFControl_MouseWheelZoomHandler;
+            ViewControl.FocusPDFViewToolChanged += ViewControl_FocusPDFViewToolChanged;
+        }
+
+        private void ViewControl_FocusPDFViewToolChanged(object sender, EventArgs e)
+        {
+            CPDFViewer pdfViewer = ViewControl.GetCPDFViewer();
+            SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
         }
 
         private void CPDFScalingUI_Unloaded(object sender, RoutedEventArgs e)

+ 1 - 1
Demo/Examples/Compdfkit_Tools/PDFView/PDFViewControl/PDFViewControl.xaml

@@ -19,7 +19,7 @@
         <Border Tag="ViewerTool" GotFocus="PDFView_GotFocus" MinWidth="20" MinHeight="20" x:Name="PDFView" Grid.Row="0" Grid.Column="0"/>
         <GridSplitter x:Name="VerticalSplitter" ResizeDirection="Columns" HorizontalAlignment="Stretch" Grid.Column="1" Width="15" Background="LightGray" Visibility="Collapsed"/>
         <GridSplitter x:Name="HorizontalSplitter" ResizeDirection="Rows" VerticalAlignment="Stretch" Grid.Row="1" Width="{Binding ElementName=ViewToolGrid,Path=ActualWidth}" Height="15" Background="LightGray" Visibility="Collapsed"/>
-        <Border Tag="SplitViewerTool" GotFocus="PDFView_GotFocus" MinWidth="20" x:Name="VerticalView" Grid.Row="0" Grid.Column="2" Visibility="Collapsed"/>
+        <Border Tag="SplitViewerTool" GotFocus="PDFView_GotFocus" MinWidth="20" x:Name="VerticalView" Grid.Row="0" Grid.Column="2"/>
         <Border Tag="SplitViewerTool" GotFocus="PDFView_GotFocus" MinHeight="20" x:Name="HorizontalView" Grid.Column="0" Grid.Row="2" Visibility="Collapsed"/>
     </Grid>
 </UserControl>

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

@@ -54,6 +54,7 @@ namespace Compdfkit_Tools.PDFControl
             InitializeComponent();
             viewerTool = new CPDFViewerTool();
             toolManager = new CPDFToolManager(viewerTool);
+            Loaded += PDFViewControl_Loaded;
             PDFViewTool = viewerTool;
             PDFToolManager = toolManager;
             PDFToolManager.SetToolType(CPDFToolManager.ToolType.Viewer);
@@ -64,6 +65,7 @@ namespace Compdfkit_Tools.PDFControl
 
             FocusPDFViewTool = viewerTool;
             PDFView.Child = PDFViewTool;
+            VerticalView.Child = splitViewerTool;
 
             PDFViewTool.SizeChanged -= PDFViewTool_SizeChanged;
             PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler -= PDFViewControl_MouseWheelZoomHandler;
@@ -92,6 +94,12 @@ namespace Compdfkit_Tools.PDFControl
             splitToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
             splitToolManager.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
             splitToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
+
+        }
+
+        private void PDFViewControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            RemoveSplitViewerTool();
         }
 
         private void PDFViewTool_DrawChanged(object sender, EventArgs e)

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

@@ -343,6 +343,7 @@ namespace PDFViewer
             }
             else if (currentMode == "Content Editor")
             {
+                displaySettingsControl.SetVisibilityWhenContentEdit(Visibility.Visible);
                 contentEditControl.ClearViewerControl();
                 contentEditControl.ClearPDFEditState();
             }
@@ -411,6 +412,7 @@ namespace PDFViewer
             {
                 contentEditControl.PdfViewControl = viewControl;
                 contentEditControl.InitWithPDFViewer(viewControl);
+                displaySettingsControl.SetVisibilityWhenContentEdit(Visibility.Collapsed);
                 if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl!= null)
                 {
                     //viewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);