Explorar el Código

ComPDFKit(windows) - 可输入缩放

liuaoran hace 1 año
padre
commit
018f70e582
Se han modificado 17 ficheros con 306 adiciones y 444 borrados
  1. 1 29
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml
  2. 3 61
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs
  3. 2 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs
  4. 3 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/DropDownNumberBoxControl.xaml.cs
  5. 2 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml
  6. 57 7
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs
  7. 123 7
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml
  8. 69 14
      compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml.cs
  9. 1 27
      compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml
  10. 4 59
      compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml.cs
  11. 1 28
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml
  12. 3 62
      compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml.cs
  13. 2 29
      compdfkit_demo_windows/compdfkit/form-ctrl-demo/MainWindow.xaml
  14. 3 43
      compdfkit_demo_windows/compdfkit/form-ctrl-demo/MainWindow.xaml.cs
  15. 0 1
      compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/MainWindow.xaml
  16. 1 30
      compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml
  17. 31 43
      compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml.cs

+ 1 - 29
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml

@@ -114,35 +114,7 @@
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
 
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
-                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
-                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
-
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
-                                <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
-
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
                 </StackPanel>
 
                 <!--中间工具栏-->

+ 3 - 61
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs

@@ -85,20 +85,6 @@ namespace viewer_ctrl_demo
         {
             pdfAnnotationControl = new CPDFAnnotationControl();
             LoadDefaultDocument();
-            BindZoomLevel();
-        }
-
-        private void BindZoomLevel()
-        {
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Actual size" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Suitable width" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Single page size" });
-            foreach (double zoomLevel in zoomLevelList)
-            {
-                ComboBoxItem zoomItem = new ComboBoxItem();
-                zoomItem.Content = zoomLevel + "%";
-                ZoomComboBox.Items.Add(zoomItem);
-            }
         }
 
         private void LoadDocument()
@@ -121,6 +107,8 @@ namespace viewer_ctrl_demo
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
 
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
@@ -148,7 +136,6 @@ namespace viewer_ctrl_demo
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
 
             InitialPDFViewControl(pdfViewControl);
             FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
@@ -454,7 +441,7 @@ namespace viewer_ctrl_demo
 
             if (e.Key == "Zoom")
             {
-                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+                CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
             }
         }
 
@@ -704,51 +691,6 @@ namespace viewer_ctrl_demo
             }
         }
 
-        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (selectItem.Content.ToString() == "Actual size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
-                }
-                else if (selectItem.Content.ToString() == "Suitable width")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-                }
-                else if (selectItem.Content.ToString() == "Single page size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
-                }
-                else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                }
-                ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-            }
-        }
-
-        private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
-
-        private void ZoomOutBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
-
         private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);

+ 2 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs

@@ -42,8 +42,9 @@ namespace compdfkit_tools.PDFControl
         {
             pdfViewer = newPDFView;
             pdfViewer.AnnotActiveHandler -= PdfViewer_AnnotActiveHandler;
-
             pdfViewer.AnnotActiveHandler += PdfViewer_AnnotActiveHandler;
+
+            
         }
 
         private void PdfViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)

+ 3 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/DropDownNumberBoxControl.xaml.cs

@@ -72,8 +72,10 @@ namespace compdfkit_tools.Common
 
         public void InitPresetNumberArray(List<int> presetNumber)
         {
-          
             List<string> array = new List<string>();
+            array.Add("Actual size");
+            array.Add("Suitable width");
+            array.Add("Single page size");
             for (int i = 0; i < presetNumber.Count; i++)
             {
                 array.Add(presetNumber[i].ToString());

+ 2 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml

@@ -6,8 +6,8 @@
              xmlns:local="clr-namespace:compdfkit_tools.PDFControl"
              xmlns:pdftoolsui="clr-namespace:compdfkit_tools.PDFControlUI"
              mc:Ignorable="d" 
-              d:DesignHeight="30" d:DesignWidth="162">
+             d:DesignHeight="30" d:DesignWidth="162">
     <Grid Height="30" Width="162">
-        <pdftoolsui:CPDFScalingUI x:Name="CPDFScalingUI"></pdftoolsui:CPDFScalingUI>
+        <pdftoolsui:CPDFScalingUI x:Name="CPDFScalingUI" Loaded="PDFScalingControl_Loaded" Unloaded="CPDFScalingUI_Unloaded"></pdftoolsui:CPDFScalingUI>
     </Grid>
 </UserControl>

+ 57 - 7
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs

@@ -1,4 +1,5 @@
 using compdfkit_tools.Common;
+using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
 using System;
 using System.Collections.Generic;
@@ -27,7 +28,6 @@ namespace compdfkit_tools.PDFControl
         public CPDFScalingControl()
         {
             InitializeComponent();
-            CPDFScalingUI.Loaded += PDFScalingControl_Loaded;
         }
 
         public void InitWithPDFViewer(CPDFViewer pdfViewer)
@@ -43,6 +43,13 @@ namespace compdfkit_tools.PDFControl
             CPDFScalingUI.SetPresetScaleEvent += CPDFScalingUI_SetPresetScaleEvent;
         }
 
+        private void CPDFScalingUI_Unloaded(object sender, RoutedEventArgs e)
+        {
+            CPDFScalingUI.SetScaleEvent -= PDFScalingControl_SetScaleEvent;
+            CPDFScalingUI.ScaleIncreaseEvent -= PDFScalingControl_ScaleIncreaseEvent;
+            CPDFScalingUI.ScaleDecreaseEvent -= PDFScalingControl_ScaleDecreaseEvent;
+            CPDFScalingUI.SetPresetScaleEvent -= CPDFScalingUI_SetPresetScaleEvent;
+        }
 
         private void PDFScalingControl_ScaleDecreaseEvent(object sender, EventArgs e)
         {
@@ -50,8 +57,19 @@ namespace compdfkit_tools.PDFControl
             {
                 return;
             }
-            CPDFScalingUI.Scale -= 10;
-            pdfViewer.Zoom((double)(CPDFScalingUI.Scale) / 100);
+            if (pdfViewer.ZoomFactor < 3)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.1);
+            }
+            else if (pdfViewer.ZoomFactor < 6)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.2);
+            }
+            else if (pdfViewer.ZoomFactor <= 10)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.3);
+            }
+            SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
         }
 
         private void PDFScalingControl_ScaleIncreaseEvent(object sender, EventArgs e)
@@ -60,8 +78,19 @@ namespace compdfkit_tools.PDFControl
             {
                 return;
             }
-            CPDFScalingUI.Scale += 10;
-            pdfViewer.Zoom((double)(CPDFScalingUI.Scale) / 100);
+            if (pdfViewer.ZoomFactor < 3)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.1);
+            }
+            else if (pdfViewer.ZoomFactor < 6)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.2);
+            }
+            else if (pdfViewer.ZoomFactor <= 10)
+            {
+                pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.3);
+            }
+            SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
         }
 
         private void PDFScalingControl_SetScaleEvent(object sender, string e)
@@ -73,17 +102,38 @@ namespace compdfkit_tools.PDFControl
             if (!string.IsNullOrEmpty(e))
             {
                 pdfViewer.Zoom(double.Parse(e) / 100);
+                SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
             }
         }
 
-
         private void CPDFScalingUI_SetPresetScaleEvent(object sender, string e)
         {
             if (pdfViewer == null || pdfViewer.Document == null)
             {
                 return;
             }
-            pdfViewer.Zoom(double.Parse(e) / 100);
+            if (e == "Actual size")
+            {
+                pdfViewer.ChangeFitMode(FitMode.FitSize);
+            }
+            else if (e == "Suitable width")
+            {
+                pdfViewer.ChangeFitMode(FitMode.FitWidth);
+            }
+            else if (e == "Single page size")
+            {
+                pdfViewer.ChangeFitMode(FitMode.FitHeight);
+            }
+            else
+            {
+                pdfViewer.Zoom(double.Parse(e) / 100);
+            }
+            SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
+        }
+
+        public void SetZoomTextBoxText(string value)
+        {
+            CPDFScalingUI.SetZoomTextBoxText(value);
         }
     }
 }

+ 123 - 7
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml

@@ -3,7 +3,6 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:compdfkit_tools.PDFControlUI"
              xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
              d:DesignHeight="30" d:DesignWidth="162">
@@ -13,18 +12,135 @@
                 <ResourceDictionary Source="pack://application:,,,/compdfkit-assets;component/Styles/ToggleButtonStyle.xaml"></ResourceDictionary>
                 <ResourceDictionary Source="pack://application:,,,/compdfkit-assets;component/Styles/ButtonStyle.xaml"></ResourceDictionary>
             </ResourceDictionary.MergedDictionaries>
+            <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
+            <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
+            <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
+            <Style x:Key="LimitedNumberBoxWithUnit" TargetType="{x:Type TextBox}">
+                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
+                <Setter Property="BorderBrush" Value="Transparent"/>
+                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+                <Setter Property="BorderThickness" Value="1"/>
+                <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
+                <Setter Property="HorizontalContentAlignment" Value="Left"/>
+                <Setter Property="VerticalContentAlignment" Value="Center"/>
+                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+                <Setter Property="AllowDrop" Value="true"/>
+                <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
+                <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type TextBox}">
+                            <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
+                                <Grid>
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="11"/>
+                                    </Grid.ColumnDefinitions>
+                                    <ScrollViewer Grid.Column="0" x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Margin="5,0,0,0"/>
+                                    <TextBlock Grid.Column="1" Text="%" HorizontalAlignment="Right" VerticalAlignment="Center"/>
+                                </Grid>
+                            </Border>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
+            <Style x:Key="TransparentToggleButton" TargetType="{x:Type ToggleButton}">
+                <Setter Property="Background" Value="Transparent"/>
+                <Setter Property="BorderBrush" Value="Transparent"/>
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type ToggleButton}">
+                            <Border x:Name="border"
+                  Background="{TemplateBinding Background}"
+                  BorderBrush="{TemplateBinding BorderBrush}"
+                  BorderThickness="{TemplateBinding BorderThickness}"
+                  Padding="{TemplateBinding Padding}">
+                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                              RecognizesAccessKey="True"/>
+                            </Border>
+                            <ControlTemplate.Triggers>
+                                <Trigger Property="IsChecked" Value="True">
+                                    <Setter TargetName="border" Property="Opacity" Value="0"/>
+                                </Trigger>
+                                <Trigger Property="IsMouseOver" Value="True">
+                                    <Setter TargetName="border" Property="Opacity" Value="0"/>
+                                </Trigger>
+                                <Trigger Property="IsPressed" Value="True">
+                                    <Setter TargetName="border" Property="Opacity" Value="0"/>
+                                </Trigger>
+                            </ControlTemplate.Triggers>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
+
+            <Style x:Key="PresetComboBox" TargetType="{x:Type ComboBox}">
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type ComboBox}">
+                            <Border x:Name="border" BorderBrush="{StaticResource TextBox.Static.Border}" BorderThickness="1" Background="#FFFFFF">
+                                <Grid>
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition></ColumnDefinition>
+                                        <ColumnDefinition Width="15"></ColumnDefinition>
+                                    </Grid.ColumnDefinitions>
+                                    <Grid Grid.Column="1">
+                                        <Path Fill="#CDCDCD" Stroke="#CDCDCD" Grid.Column="1" Height="4.8" Width="7.38" Stretch="Fill">
+                                            <Path.Data>
+                                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
+                                            </Path.Data>
+                                        </Path>
+                                       
+                                    </Grid>
+                                    <Grid Grid.Column="0" Grid.ColumnSpan="2">
+                                        <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
+                                              ClickMode="Press" Style="{StaticResource TransparentToggleButton}"></ToggleButton>
+                                        <Popup Name="popup"
+                                   IsOpen="{TemplateBinding IsDropDownOpen}"
+                                   Placement="Bottom" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="1">
+                                            <Border MinWidth="{TemplateBinding ActualWidth}"
+                                        MaxHeight="{TemplateBinding MaxDropDownHeight}">
+                                                <ScrollViewer MaxHeight="{TemplateBinding MaxDropDownHeight}"
+                                                  HorizontalScrollBarVisibility="Auto"
+                                                  VerticalScrollBarVisibility="Auto">
+                                                    <Border BorderBrush ="LightGray" BorderThickness="1">
+                                                        <StackPanel Background="#FFFFFF" MinHeight="20"
+                                                    IsItemsHost="True"/>
+                                                    </Border>
+                                                </ScrollViewer>
+                                            </Border>
+                                        </Popup>
+                                    </Grid>
+                                </Grid>
+                            </Border>
+                            <ControlTemplate.Triggers>
+                                <Trigger Property="IsMouseOver" Value="true">
+                                    <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
+                                </Trigger>
+                            </ControlTemplate.Triggers>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
+
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid Height="30" Width="160" HorizontalAlignment="Left">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="72"></ColumnDefinition>
-            <ColumnDefinition Width="73"></ColumnDefinition>
-            <ColumnDefinition Width="17"/>
+            <ColumnDefinition Width="*"></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <StackPanel Orientation="Horizontal" Height="30">
-            <cpdfcommon:DropDownNumberBoxControl x:Name="DropDownNumberBoxControl" Height="30" Width=" 72" Maxium="1600" Minimum="0" Text="{Binding Scale,Mode=TwoWay}"></cpdfcommon:DropDownNumberBoxControl>
-        </StackPanel>
-        <StackPanel Grid.Column="1" Orientation="Horizontal" Grid.ColumnSpan="2">
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="1*"></ColumnDefinition>
+                <ColumnDefinition Width="20"></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <ComboBox Grid.ColumnSpan="2" x:Name="ZoomComboBox" Background="#FFFFFF" Style="{StaticResource PresetComboBox}" SelectionChanged="ZoomComboBox_SelectionChanged" ></ComboBox>
+            <TextBox x:Name="ZoomTextBox" Text="{Binding Text, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource LimitedNumberBoxWithUnit}" HorizontalContentAlignment="Center" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="TextBox_PreviewTextInput" PreviewKeyDown="TextBox_PreviewKeyDown" TextChanged="TextBox_TextChanged" LostFocus="ZoomTextBox_LostFocus">
+            </TextBox>
+        </Grid>
+        <StackPanel Grid.Column="1" Orientation="Horizontal" >
             <Button x:Name="ScaleDecreaseButton" Style="{StaticResource LightButtonStyle}" Height="30" Width="30" Margin="20,0,0,0" Background="Transparent" BorderThickness="0" Click="ScaleDecreaseButton_Click">
                 <Button.Content>
                     <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>

+ 69 - 14
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFScaling/PDFScalingUI/CPDFScalingUI.xaml.cs

@@ -6,6 +6,7 @@ using System.ComponentModel;
 using System.Linq;
 using System.Runtime.CompilerServices;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
@@ -16,6 +17,8 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using System.Xml.Linq;
+using static System.Net.Mime.MediaTypeNames;
 
 namespace compdfkit_tools.PDFControlUI
 {
@@ -26,6 +29,9 @@ namespace compdfkit_tools.PDFControlUI
     {
         public CPDFViewer PDFView { get; set; }
 
+        private string regixString = "[^0-9]+";
+
+
         private int _scale = 100;
         public int Scale
         {
@@ -40,20 +46,18 @@ namespace compdfkit_tools.PDFControlUI
             }
         }
 
+        private int[] zoomLevelList = { 10, 25, 50, 100, 150, 200, 300, 400, 500, 1000 };
 
         public event EventHandler<string> SetScaleEvent;
         public event EventHandler<string> SetPresetScaleEvent;
         public event EventHandler ScaleIncreaseEvent;
         public event EventHandler ScaleDecreaseEvent;
 
-
         public CPDFScalingUI()
         {
             InitializeComponent();
             DataContext = this;
-            DropDownNumberBoxControl.InputEnterEvent += DropDownNumberBoxControl_InputEnterEvent;
-            DropDownNumberBoxControl.SetPresetEvent += DropDownNumberBoxControl_SetPresetEvent;
-            InitPresetNumberArray();
+            BindZoomLevel();
         }
 
         private void DropDownNumberBoxControl_SetPresetEvent(object sender, string e)
@@ -61,17 +65,28 @@ namespace compdfkit_tools.PDFControlUI
             SetPresetScaleEvent?.Invoke(this, e);
         }
 
-        public void InitPresetNumberArray()
+        private void BindZoomLevel()
+        {
+            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Actual size" });
+            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Suitable width" });
+            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Single page size" });
+            foreach (double zoomLevel in zoomLevelList)
+            {
+                ComboBoxItem zoomItem = new ComboBoxItem();
+                zoomItem.Content = zoomLevel;
+                ZoomComboBox.Items.Add(zoomItem);
+            }
+        }
+
+        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            List<int> list = new List<int>();
-            list.Add(25);
-            list.Add(50);
-            list.Add(100);
-            list.Add(200);
-            list.Add(400);
-            list.Add(800);
-            list.Add(1600);
-            DropDownNumberBoxControl.InitPresetNumberArray(list);
+            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
+            SetPresetScaleEvent?.Invoke(this, selectItem.Content.ToString());
+        }
+
+        public void SetZoomTextBoxText(string value)
+        {
+            ZoomTextBox.Text = value;
         }
 
         private void DropDownNumberBoxControl_InputEnterEvent(object sender, string e)
@@ -94,5 +109,45 @@ namespace compdfkit_tools.PDFControlUI
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
+
+        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+            e.Handled = new Regex(regixString).IsMatch(e.Text);
+        }
+
+        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Enter)
+            {
+                SetScaleEvent?.Invoke(sender, ZoomTextBox.Text);
+            }
+            if ((e.KeyStates == Keyboard.GetKeyStates(Key.LeftCtrl) || e.KeyStates == Keyboard.GetKeyStates(Key.RightCtrl)) && e.KeyStates == Keyboard.GetKeyStates(Key.V))
+                e.Handled = true;
+            else
+                e.Handled = false;
+        }
+
+        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (!string.IsNullOrEmpty(ZoomTextBox.Text))
+            {
+                int num;
+                int.TryParse(ZoomTextBox.Text, out num);
+                if (num > 1000)
+                {
+                    ZoomTextBox.Text = 1000.ToString();
+                }
+
+                if (num < 1)
+                {
+                    ZoomTextBox.Text = 1.ToString();
+                }
+            }
+        }
+
+        private void ZoomTextBox_LostFocus(object sender, RoutedEventArgs e)
+        {
+            SetScaleEvent?.Invoke(sender, ZoomTextBox.Text);
+        }
     }
 }

+ 1 - 27
compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml

@@ -101,34 +101,8 @@
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
 
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
-                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
-                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
 
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
-                                <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
                 </StackPanel>
 
                 <!--中间工具栏-->

+ 4 - 59
compdfkit_demo_windows/compdfkit/compdfkit/MainWindow.xaml.cs

@@ -98,20 +98,6 @@ namespace compdfkit
         {
             pdfAnnotationControl = new CPDFAnnotationControl();
             LoadDefaultDocument();
-            BindZoomLevel();
-        }
-
-        private void BindZoomLevel()
-        {
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Actual size" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Suitable width" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Single page size" });
-            foreach (double zoomLevel in zoomLevelList)
-            {
-                ComboBoxItem zoomItem = new ComboBoxItem();
-                zoomItem.Content = zoomLevel + "%";
-                ZoomComboBox.Items.Add(zoomItem);
-            }
         }
 
         private void LoadDefaultDocument()
@@ -125,7 +111,7 @@ namespace compdfkit
         {
             if (e.Key == "Zoom")
             {
-                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+                CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
             }
         }
 
@@ -193,7 +179,8 @@ namespace compdfkit
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
-
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
             {
@@ -222,7 +209,6 @@ namespace compdfkit
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
         }
 
         private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -795,30 +781,7 @@ namespace compdfkit
             }
         }
 
-        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (selectItem.Content.ToString() == "Actual size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
-                }
-                else if (selectItem.Content.ToString() == "Suitable width")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-                }
-                else if (selectItem.Content.ToString() == "Single page size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
-                }
-                else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                }
-                ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-            }
-        }
+
 
         private double CheckZoomLevel(double zoom, bool IsGrowth)
         {
@@ -849,25 +812,7 @@ namespace compdfkit
             return standardZoom / 100;
         }
 
-        private void ZoomOutBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
 
-        private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
 
         private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
         {

+ 1 - 28
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml

@@ -125,34 +125,7 @@
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35" Visibility="Collapsed"></Line>
 
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
-                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
-                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
-
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
-                                <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
 
                 </StackPanel>
 

+ 3 - 62
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml.cs

@@ -109,32 +109,6 @@ namespace edit_ctrl_demo
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
         {
             LoadDefaultDocument();
-            BindZoomLevel();
-        }
-
-        private void BindZoomLevel()
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (selectItem.Content.ToString() == "Actual size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
-                }
-                else if (selectItem.Content.ToString() == "Suitable width")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-                }
-                else if (selectItem.Content.ToString() == "Single page size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
-                }
-                else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                }
-                ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-            }
         }
 
         private void LoadDocument()
@@ -159,7 +133,8 @@ namespace edit_ctrl_demo
             pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
             pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
             pdfViewControl.PDFView.SetFormFieldHighlight(true);
-
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
             {
@@ -183,7 +158,6 @@ namespace edit_ctrl_demo
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
 
             SetEditMode();
         }
@@ -369,7 +343,7 @@ namespace edit_ctrl_demo
         {
             if (e.Key == "Zoom")
             {
-                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+                CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
             }
         }
 
@@ -707,39 +681,6 @@ namespace edit_ctrl_demo
             }
         }
 
-        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                    ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-                }
-            }
-        }
-
-        private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
-
-        private void ZoomOutBtn_Click(object sender, RoutedEventArgs e)
-        {
-            if (pdfViewControl != null)
-            {
-                double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
-                pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
-            }
-        }
-
         private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);

+ 2 - 29
compdfkit_demo_windows/compdfkit/form-ctrl-demo/MainWindow.xaml

@@ -126,35 +126,8 @@
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35" Visibility="Collapsed"></Line>
 
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
-                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
-                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
-
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
-                                <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
-
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
+ 
                 </StackPanel>
 
                 <!--中间工具栏-->

+ 3 - 43
compdfkit_demo_windows/compdfkit/form-ctrl-demo/MainWindow.xaml.cs

@@ -72,20 +72,6 @@ namespace form_ctrl_demo
         {
             fromPropertyControl = new FromPropertyControl();
             LoadDefaultDocument();
-            BindZoomLevel();
-        }
-
-        private void BindZoomLevel()
-        {
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Actual size" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Suitable width" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Single page size" });
-            foreach (double zoomLevel in zoomLevelList)
-            {
-                ComboBoxItem zoomItem = new ComboBoxItem();
-                zoomItem.Content = zoomLevel + "%";
-                ZoomComboBox.Items.Add(zoomItem);
-            }
         }
 
         private void LoadDocument()
@@ -106,7 +92,8 @@ namespace form_ctrl_demo
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
-
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
             {
@@ -129,7 +116,6 @@ namespace form_ctrl_demo
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
             FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
             InitialPDFViewControl(pdfViewControl);
             SetFromMode();
@@ -330,7 +316,7 @@ namespace form_ctrl_demo
         {
             if (e.Key == "Zoom")
             {
-                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+                CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
             }
         }
 
@@ -584,30 +570,6 @@ namespace form_ctrl_demo
             }
         }
 
-        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (selectItem.Content.ToString() == "Actual size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
-                }
-                else if (selectItem.Content.ToString() == "Suitable width")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-                }
-                else if (selectItem.Content.ToString() == "Single page size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
-                }
-                else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                }
-                ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-            }
-        }
 
         private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
         {
@@ -615,7 +577,6 @@ namespace form_ctrl_demo
             {
                 double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
                 pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
             }
         }
 
@@ -625,7 +586,6 @@ namespace form_ctrl_demo
             {
                 double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
                 pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
             }
         }
 

+ 0 - 1
compdfkit_demo_windows/compdfkit/pageedit-ctrl-demo/MainWindow.xaml

@@ -3,7 +3,6 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:cpdftools="clr-namespace:compdfkit_tools.PDFControl;assembly=com.compdfkit.tools"
         xmlns:local="clr-namespace:pageedit_ctrl_demo"
         mc:Ignorable="d"
         Title="MainWindow" Height="450" Width="800">

+ 1 - 30
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml

@@ -110,36 +110,7 @@
                     </ToggleButton>
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
-
-                    <Grid>
-                        <ComboBox Name="ZoomComboBox" VerticalContentAlignment="Center" Width="72" Height="30" Foreground="#43474D" FontSize="14"
-                              SelectionChanged="ZoomComboBox_SelectionChanged" BorderBrush="#1E000000">
-                        </ComboBox>
-                        <TextBox Name="ZoomTextBox" IsHitTestVisible="False" Width="72" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
-                             IsReadOnly="True" Background="White" Padding="0,0,15,0">100%</TextBox>
-                        <Path Fill="#43474D" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0" IsHitTestVisible="False">
-                            <Path.Data>
-                                M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
-                            </Path.Data>
-                        </Path>
-                    </Grid>
-
-                    <Button Margin="20,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomOutBtn_Click" >
-                        <Button.Content>
-                            <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
-                        </Button.Content>
-                    </Button>
-
-                    <Button Margin="10,0,0,0" Width="30" Height="30" BorderThickness="0" Background="Transparent" Style="{StaticResource LightButtonStyle}" Click="ZoomInBtn_Click">
-                        <Button.Content>
-                            <Path Fill="#0E1114">
-                                <Path.Data>
-                                    M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
-                                </Path.Data>
-                            </Path>
-                        </Button.Content>
-                    </Button>
-
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
                 </StackPanel>
 
                 <!--中间工具栏-->

+ 31 - 43
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml.cs

@@ -12,6 +12,7 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
+using System.Net.NetworkInformation;
 using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Annotations;
@@ -53,20 +54,6 @@ namespace viewer_ctrl_demo
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)
         {
             LoadDefaultDocument();
-            BindZoomLevel();
-        }
-
-        private void BindZoomLevel()
-        {
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Actual size" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Suitable width" });
-            ZoomComboBox.Items.Add(new ComboBoxItem() { Content = "Single page size" });
-            foreach (double zoomLevel in zoomLevelList)
-            {
-                ComboBoxItem zoomItem = new ComboBoxItem();
-                zoomItem.Content = zoomLevel + "%";
-                ZoomComboBox.Items.Add(zoomItem);
-            }
         }
 
         private void LoadDocument()
@@ -85,7 +72,8 @@ namespace viewer_ctrl_demo
             PasswordUI.Closed += PasswordUI_Closed;
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
-
+            CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
             {
@@ -109,7 +97,7 @@ namespace viewer_ctrl_demo
             ViewSettingBtn.IsChecked = false;
             PropertyContainer.Child = null;
             PropertyContainer.Visibility = Visibility.Collapsed;
-            ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
+           // ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
         }
 
         private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
@@ -292,7 +280,7 @@ namespace viewer_ctrl_demo
         {
             if (e.Key == "Zoom")
             {
-                ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
+                CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
             }
         }
 
@@ -519,30 +507,30 @@ namespace viewer_ctrl_demo
             }
         }
 
-        private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
-            {
-                if (selectItem.Content.ToString() == "Actual size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
-                }
-                else if (selectItem.Content.ToString() == "Suitable width")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-                }
-                else if (selectItem.Content.ToString() == "Single page size")
-                {
-                    pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
-                }
-                else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
-                {
-                    pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
-                }
-                ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
-            }
-        }
+        //private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        //{
+        //    ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
+        //    if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
+        //    {
+        //        if (selectItem.Content.ToString() == "Actual size")
+        //        {
+        //            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitSize);
+        //        }
+        //        else if (selectItem.Content.ToString() == "Suitable width")
+        //        {
+        //            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
+        //        }
+        //        else if (selectItem.Content.ToString() == "Single page size")
+        //        {
+        //            pdfViewControl.PDFView.ChangeFitMode(FitMode.FitHeight);
+        //        }
+        //        else if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
+        //        {
+        //            pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
+        //        }
+        //        ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
+        //    }
+        //}
 
         private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
         {
@@ -550,7 +538,7 @@ namespace viewer_ctrl_demo
             {
                 double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
                 pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
+                //ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
             }
         }
 
@@ -560,7 +548,7 @@ namespace viewer_ctrl_demo
             {
                 double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
                 pdfViewControl.PDFView.Zoom(newZoom);
-                ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
+                //ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
             }
         }