Browse Source

ComPDFKit(win) - 多次加载文档后BOTA自我复制问题、切到Docs Editor模式时隐藏按钮

liuaoran 1 year ago
parent
commit
b1b6fe613c

+ 1 - 2
Demo/Examples/AnnotationViewControl/MainWindow.xaml.cs

@@ -28,7 +28,7 @@ namespace AnnotationViewControl
         private PDFViewControl pdfViewer;
         private PDFViewControl passwordViewer;
         private AnnotationControl annotationControl = new AnnotationControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
+        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
         
         private bool _canSave = false;
         public bool CanSave
@@ -90,7 +90,6 @@ namespace AnnotationViewControl
             ViewSettingBtn.IsChecked = false;
             botaBarControl.InitWithPDFViewer(annotationControl.PdfViewControl.PDFView);
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            botaBarControl.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
             annotationControl.SetBOTAContainer(botaBarControl);
             annotationControl.InitialPDFViewControl(annotationControl.PdfViewControl);
         }

+ 1 - 2
Demo/Examples/ContentEditorViewControl/MainWindow.xaml.cs

@@ -28,7 +28,7 @@ namespace ContentEditorViewControl
         private PDFViewControl pdfViewer;
 
         private ContentEditControl contentEditControl = new ContentEditControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
+        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
 
         public bool CanUndo
         {
@@ -108,7 +108,6 @@ namespace ContentEditorViewControl
             PDFGrid.Child = contentEditControl;
             botaBarControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            botaBarControl.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
             contentEditControl.SetBOTAContainer(botaBarControl);
             contentEditControl.InitWithPDFViewer(pdfViewer.PDFView);
         }

+ 2 - 3
Demo/Examples/DocsEditControl/MainWindow.xaml.cs

@@ -25,7 +25,7 @@ namespace DocsEditControl
         private PDFViewControl pdfViewer;
         private PDFViewControl passwordViewer;
         private PageEditControl pageEditControl = new PageEditControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
+        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
 
         public bool CanUndo
         {
@@ -107,8 +107,7 @@ namespace DocsEditControl
 
             ViewSettingBtn.IsChecked = false;
             botaBarControl.InitWithPDFViewer(pdfViewer.PDFView);
-            botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            botaBarControl.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
+            botaBarControl.SelectBotaTool(BOTATools.Thumbnail); 
         }
 
         private void PageEditControlRefreshAnnotList(object sender, EventArgs e)

+ 1 - 2
Demo/Examples/FormViewControl/MainWindow.xaml.cs

@@ -28,7 +28,7 @@ namespace FormViewControl
         private PDFViewControl pdfViewer;
         private PDFViewControl passwordViewer;
         private FormControl formControl = new FormControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
+        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
         
         private bool _canSave = false;
         public bool CanSave
@@ -90,7 +90,6 @@ namespace FormViewControl
             ViewSettingBtn.IsChecked = false;
             botaBarControl.InitWithPDFViewer(formControl.PdfViewControl.PDFView);
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            botaBarControl.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
             formControl.SetBOTAContainer(botaBarControl);
             formControl.InitialPDFViewControl(formControl.PdfViewControl);
         }

+ 7 - 7
Demo/Examples/PDFViewer_new/MainPage.xaml

@@ -18,7 +18,7 @@
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </UserControl.Resources>
-    <Grid> 
+    <Grid>
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="Auto"></RowDefinition>
@@ -79,7 +79,7 @@
                         </Button.ToolTip>
                     </Button>
 
-                    <ToggleButton Name="LeftToolPanelButton" Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="{Binding LeftToolPanelButtonIsChecked, Mode=TwoWay}" Click="LeftToolPanelButton_Click">
+                    <ToggleButton Name="LeftToolPanelButton" Margin="13,0,0,0" BorderThickness="0" Width="30" Height="30" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" IsChecked="{Binding LeftToolPanelButtonIsChecked, Mode=TwoWay}" Click="LeftToolPanelButton_Click" Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}">
                         <ToggleButton.Content>
                             <Path Fill="#43474D" Width="30" Height="30">
                                 <Path.Data>
@@ -114,9 +114,9 @@
                         </ToggleButton.Content>
                     </ToggleButton>
 
-                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
+                    <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"  Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}"></Line>
 
-                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
+                    <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"  Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}"></cpdftools:CPDFScalingControl>
                 </StackPanel>
 
                 <ComboBox Name="ModeComboBox" Style="{StaticResource ComboBoxStyle1}" Width="130" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E" SelectionChanged="ComboBox_SelectionChanged">
@@ -129,7 +129,7 @@
 
                 <StackPanel Orientation="Horizontal" Grid.Column="2">
 
-                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent" Click="ExpandSearchBtn_Click">
+                    <Button BorderThickness="0" Width="40" Height="40" Style="{StaticResource LightButtonStyle}" Background="Transparent"  Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}" Click="ExpandSearchBtn_Click">
                         <Button.Content>
                             <Path Fill="#43474D">
                                 <Path.Data>
@@ -146,7 +146,7 @@
                         </Button.ToolTip>
                     </Button>
 
-                    <ToggleButton  x:Name="RightPanelButton" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="RightPanelButton_Click" IsChecked="{Binding RightToolPanelButtonIsChecked, Mode=TwoWay}">
+                    <ToggleButton  x:Name="RightPanelButton" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}" Background="Transparent" Click="RightPanelButton_Click" IsChecked="{Binding RightToolPanelButtonIsChecked, Mode=TwoWay}"  Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}">
                         <ToggleButton.Content>
                             <Path Fill="#43474D" Width="30" Height="30">
                                 <Path.Data>
@@ -159,7 +159,7 @@
                         </ToggleButton.ToolTip>
                     </ToggleButton>
 
-                    <ToggleButton Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}"  Background="Transparent" IsChecked="{Binding ViewSettingBtnIsChecked, Mode=TwoWay}" Click="ViewSettingBtn_Click">
+                    <ToggleButton Name="ViewSettingBtn" BorderThickness="0" Width="40" Height="40" Style="{StaticResource ToggleButtonStyle}"  Background="Transparent" IsChecked="{Binding ViewSettingBtnIsChecked, Mode=TwoWay}"  Visibility="{Binding NotDocsEditorVisible, Mode=OneWay}" Click="ViewSettingBtn_Click">
                         <ToggleButton.Content>
                             <Path Stroke="#43474D" VerticalAlignment="Center" StrokeThickness="2">
                                 <Path.Data>

+ 18 - 3
Demo/Examples/PDFViewer_new/MainPage.xaml.cs

@@ -26,7 +26,7 @@ namespace PDFViewer_new
         private FormControl formControl = new FormControl();
         private ContentEditControl contentEditControl = new ContentEditControl();
         private PageEditControl pageEditControl = new PageEditControl();
-        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
+        private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
         private CPDFDisplaySettingsControl displaySettingsControl = new CPDFDisplaySettingsControl();
 
         public event Func<string[], bool> CheckExistBeforeOpenFileEvent;
@@ -82,6 +82,19 @@ namespace PDFViewer_new
             }
         }
 
+        private Visibility _notDocsEditorVisible = Visibility.Visible;
+        public Visibility NotDocsEditorVisible
+        {
+            get => _notDocsEditorVisible;
+            
+            set
+            {
+                _notDocsEditorVisible = value;
+                OnPropertyChanged();
+            }
+        }
+
+
         public MainPage()
         {
             InitializeComponent();
@@ -124,9 +137,8 @@ namespace PDFViewer_new
             CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.PDFView.ZoomFactor * 100)));
 
             ViewSettingBtn.IsChecked = false;
-            botaBarControl.InitWithPDFViewer(pdfViewer.PDFView);
+            botaBarControl.InitWithPDFViewer(pdfViewer.PDFView); 
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            botaBarControl.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
             displaySettingsControl.InitWithPDFViewer(pdfViewer.PDFView);
             LoadCustomControl();
             panelState.PropertyChanged -= PanelState_PropertyChanged;
@@ -270,6 +282,7 @@ namespace PDFViewer_new
                 else
                 {
                     pdfViewer = passwordViewer;
+                    LoadDocument(); 
                     FileChangeEvent?.Invoke(null, EventArgs.Empty);
                 }
             }
@@ -319,6 +332,7 @@ namespace PDFViewer_new
             else if (currentMode == "Docs Editor")
             {
                 pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
+                NotDocsEditorVisible = Visibility.Visible;
             }
 
             if (item.Content as string == "Viewer")
@@ -400,6 +414,7 @@ namespace PDFViewer_new
                 pageEditControl.PDFViewControl = pdfViewer;
                 pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
                 PDFGrid.Child = pageEditControl;
+                NotDocsEditorVisible = Visibility.Collapsed;
             }
             currentMode = item.Content as string;
             RightToolPanelButtonIsChecked = false;