Kaynağa Gözat

PDFView(Windows) - 修复打开新文档右侧属性面板无效;页码固定显示

liyuxuan 1 yıl önce
ebeveyn
işleme
1a8d1e6fd2

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

@@ -179,7 +179,7 @@
                     </ToggleButton>
                     
                     <!--页面显示-->
-                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                    <ToggleButton Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
                         <ToggleButton.Content>
                             <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
                                 <Path.Data>
@@ -318,13 +318,11 @@
                     </Grid.RowDefinitions>
                     <cpdftools:CPDFAnnotationBarControl x:Name="AnnotationBarControl" Loaded="AnnotationBarControl_Loaded" Unloaded="AnnotationBarControl_Unloaded" Grid.ColumnSpan="2"/>
                     <!--PDFViewer-->
-                    <Border Grid.Row="1" x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}" MouseMove="PDFGrid_MouseMove" Grid.ColumnSpan="2"></Border>
+                    <Border Grid.Row="1" x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}" Grid.ColumnSpan="2"></Border>
 
-                    <Border Grid.Row="1" Background="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Left" CornerRadius="5" Width="100" Height="36" Margin="590,0,0,30"
-                        MouseEnter="Border_MouseEnter"  />
                     <!--页码工具-->
                     <Border Grid.Row="1" Name="FloatPageTool" Background="#CC000000" VerticalAlignment="Bottom" HorizontalAlignment="Left"
-                        Margin="590,0,0,20" CornerRadius="5" Width="100" Height="36" Visibility="Collapsed">
+                        Margin="590,0,0,20" CornerRadius="5" Width="100" Height="36">
                         <Grid>
                             <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="auto"></ColumnDefinition>

+ 12 - 10
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs

@@ -83,6 +83,9 @@ namespace viewer_ctrl_demo
                 ((CPDFBookmarkControl)currentBotaTool).LoadBookmark();
             }
 
+            ViewSettingBtn.IsChecked = false;
+            PropertyContainer.Child = null;
+            PropertyContainer.Visibility = Visibility.Collapsed;
             ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
 
             InitialPDFViewControl(pdfViewControl);
@@ -487,16 +490,6 @@ namespace viewer_ctrl_demo
             }
         }
 
-        private void Border_MouseEnter(object sender, MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Visible;
-        }
-
-        private void PDFGrid_MouseMove(object sender, MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Collapsed;
-        }
-
         private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton toggleButton = sender as ToggleButton;
@@ -580,6 +573,15 @@ namespace viewer_ctrl_demo
                 string filePath = CommonHelper.GetFilePathOrEmpty();
                 if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
                 {
+                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                    {
+                        string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                        if (oldFilePath.ToLower() == filePath.ToLower())
+                        {
+                            return;
+                        }
+                    }
+
                     passwordViewer = new PDFViewControl();
                     passwordViewer.PDFView.InitDocument(filePath);
                     if (passwordViewer.PDFView.Document == null)

+ 6 - 7
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml

@@ -180,7 +180,7 @@
                     </ToggleButton>
                     
                     <!--页面显示-->
-                    <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                    <ToggleButton  Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
                         <ToggleButton.Content>
                             <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
                                 <Path.Data>
@@ -332,8 +332,9 @@
                                 <StackPanel Orientation="Horizontal">
                                     <Path Fill="#273C62" VerticalAlignment="Center">
                                         <Path.Data>
-                                            M1.25 0H0.5V0.75V13.25V14H1.25H17.75H18.5V13.25V7H17V12.5H2V1.5H12.5V0H1.25ZM11.5 5V2.5H3.5V5H5V4H6.75V10H6V11.5H9V10H8.25V4H10V5H11.5ZM15.75 
-                                3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
+                                            M1.5 0H0.75V0.75V13.25V14H1.5H18H18.75V13.25V7H17.25V12.5H17.2147L11.8718 7.81776L9.56428 10.25L5.29496 6.75L2.25 9.95948V1.5H12.75V0H1.5ZM13.5 5.25C13.5 
+                                            6.07843 12.8284 6.75 12 6.75C11.1716 6.75 10.5 6.07843 10.5 5.25C10.5 4.42157 11.1716 3.75 12 3.75C12.8284 3.75 13.5 4.42157 13.5 5.25ZM15.75 
+                                            3.75H13.5V2.25H15.75V0H17.25V2.25H19.5V3.75H17.25V6H15.75V3.75Z
                                         </Path.Data>
                                     </Path>
                                     <TextBlock  FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0">Add Picture</TextBlock>
@@ -368,13 +369,11 @@
                     </Border>
 
                     <!--PDFViewer-->
-                    <Border Grid.Row="1" x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}" MouseMove="PDFGrid_MouseMove"></Border>
+                    <Border Grid.Row="1" x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}"></Border>
 
-                    <Border Grid.Row="1" Background="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Center" CornerRadius="5" Width="100" Height="36" Margin="0,0,0,30"
-                        MouseEnter="Border_MouseEnter"  />
                     <!--页码工具-->
                     <Border Grid.Row="1" Name="FloatPageTool" Background="#CC000000" VerticalAlignment="Bottom" HorizontalAlignment="Center"
-                        Margin="0,0,0,20" CornerRadius="5" Width="100" Height="36" Visibility="Collapsed">
+                        Margin="0,0,0,20" CornerRadius="5" Width="100" Height="36">
                         <Grid>
                             <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="auto"></ColumnDefinition>

+ 27 - 24
compdfkit_demo_windows/compdfkit/edit-ctrl-demo/MainWindow.xaml.cs

@@ -90,13 +90,6 @@ namespace edit_ctrl_demo
         {
             LoadDefaultDocument();
             BindZoomLevel();
-          
-            if(pdfViewControl!=null)
-            {
-                pdfViewControl.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
-                pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
-                pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
-            }
         }
 
         private void BindZoomLevel()
@@ -119,6 +112,13 @@ namespace edit_ctrl_demo
             PasswordUI.Canceled += PasswordUI_Canceled;
             PasswordUI.Confirmed += PasswordUI_Confirmed;
 
+            pdfViewControl.PDFView.PDFEditActiveHandler -= PDFView_PDFEditActiveHandler;
+            pdfViewControl.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
+            pdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
+            pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+            pdfViewControl.PDFView.PDFEditCommandHandler -= PDFView_PDFEditCommandHandler;
+            pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
+
             UIElement currentBotaTool = GetBotaTool();
             if (currentBotaTool is CPDFSearchControl)
             {
@@ -138,6 +138,9 @@ namespace edit_ctrl_demo
                 ((CPDFBookmarkControl)currentBotaTool).LoadBookmark();
             }
 
+            ViewSettingBtn.IsChecked = false;
+            PropertyContainer.Child = null;
+            PropertyContainer.Visibility = Visibility.Collapsed;
             ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
 
             SetEditMode();
@@ -481,16 +484,6 @@ namespace edit_ctrl_demo
             }
         }
 
-        private void Border_MouseEnter(object sender, MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Visible;
-        }
-
-        private void PDFGrid_MouseMove(object sender, MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Collapsed;
-        }
-
         private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton toggleButton = sender as ToggleButton;
@@ -575,6 +568,15 @@ namespace edit_ctrl_demo
                 string filePath = CommonHelper.GetFilePathOrEmpty();
                 if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
                 {
+                    if(pdfViewControl.PDFView!=null && pdfViewControl.PDFView.Document!=null)
+                    {
+                        string oldFilePath=pdfViewControl.PDFView.Document.FilePath;
+                        if (oldFilePath.ToLower() == filePath.ToLower())
+                        {
+                            return;
+                        }
+                    }
+
                     passwordViewer = new PDFViewControl();
                     passwordViewer.PDFView.InitDocument(filePath);
                     if (passwordViewer.PDFView.Document == null)
@@ -732,12 +734,12 @@ namespace edit_ctrl_demo
             editCommand.PopupMenu = new ContextMenu();
             if (lastPDFEditEvent != null)
             {
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "复制", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "剪切", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "删除", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "粘贴", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
+                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
+                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
                 MenuItem propertyMenu = new MenuItem();
-                propertyMenu.Header = "属性";
+                propertyMenu.Header = "Property";
                 propertyMenu.Click += (o, p) =>
                 {
                     if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditText)
@@ -745,16 +747,17 @@ namespace edit_ctrl_demo
                         PDFTextEditControl textEditControl = new PDFTextEditControl();
                         textEditControl.SetPDFTextEditData(lastPDFEditEvent);
                         PropertyContainer.Child = textEditControl;
+                        PropertyContainer.Visibility = Visibility.Visible;
                     }
                 };
                 editCommand.PopupMenu.Items.Add(propertyMenu);
             }
             else
             {
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "粘贴", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
                 if(editCommand.TextAreaCopied)
                 {
-                    editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "粘贴样式", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
+                    editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste And Match Style", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
                 }
             }
         }

+ 4 - 6
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml

@@ -165,7 +165,7 @@
                         </Button>
 
                         <!--页面显示-->
-                        <ToggleButton BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
+                        <ToggleButton Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="ViewSettingBtn_Click">
                             <ToggleButton.Content>
                                 <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
                                     <Path.Data>
@@ -283,13 +283,11 @@
 
                 <Grid Grid.Column="2" >
                     <!--PDFViewer-->
-                    <Border x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}" MouseMove="PDFGrid_MouseMove"></Border>
-
-                    <Border Background="Transparent" VerticalAlignment="Bottom" HorizontalAlignment="Center" CornerRadius="5" Width="100" Height="36" Margin="0,0,0,30"
-                        MouseEnter="Border_MouseEnter"  />
+                    <Border x:Name="PDFGrid" Background="{StaticResource color.bg.mainpage}"></Border>
+                    
                     <!--页码工具-->
                     <Border Name="FloatPageTool" Background="#CC000000" VerticalAlignment="Bottom" HorizontalAlignment="Center"
-                        Margin="0,0,0,20" CornerRadius="5" Width="100" Height="36" Visibility="Collapsed">
+                        Margin="0,0,0,20" CornerRadius="5" Width="100" Height="36" >
                         <Grid>
                             <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="auto"></ColumnDefinition>

+ 13 - 11
compdfkit_demo_windows/compdfkit/viewer-ctrl-demo/MainWindow.xaml.cs

@@ -82,6 +82,9 @@ namespace viewer_ctrl_demo
                 ((CPDFBookmarkControl)currentBotaTool).LoadBookmark();
             }
 
+            ViewSettingBtn.IsChecked = false;
+            PropertyContainer.Child = null;
+            PropertyContainer.Visibility = Visibility.Collapsed;
             ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
 
         }
@@ -437,17 +440,7 @@ namespace viewer_ctrl_demo
                 BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
             }
         }
-
-        private void Border_MouseEnter(object sender,MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Visible;
-        }
-
-        private void PDFGrid_MouseMove(object sender, MouseEventArgs e)
-        {
-            FloatPageTool.Visibility = Visibility.Collapsed;
-        }
-
+  
         private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton toggleButton=sender as ToggleButton;
@@ -531,6 +524,15 @@ namespace viewer_ctrl_demo
                 string filePath = CommonHelper.GetFilePathOrEmpty();
                 if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
                 {
+                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                    {
+                        string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                        if (oldFilePath.ToLower() == filePath.ToLower())
+                        {
+                            return;
+                        }
+                    }
+
                     passwordViewer = new PDFViewControl();
                     passwordViewer.PDFView.InitDocument(filePath);
                     if(passwordViewer.PDFView.Document == null)