Преглед на файлове

Merge remote-tracking branch 'origin/compdfkit_demo_win_rebuild' into compdfkit_demo_win_rebuild

TangJinZhou преди 9 месеца
родител
ревизия
0b6f736f25

+ 16 - 0
Demo/Examples/Annotations/Annotations.csproj

@@ -94,6 +94,18 @@
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Tool\ComPDFKit.Tool.csproj">
+      <Project>{a061ee7a-6704-4bd9-86ee-48ed5df75e2f}</Project>
+      <Name>ComPDFKit.Tool</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{783263cf-0da3-4095-9df8-2c4a6b3ff908}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit_windows\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Compdfkit_Tools\Compdfkit_Tools.csproj">
       <Project>{9363bcb1-3a67-446a-8093-5708b86bf418}</Project>
       <Name>Compdfkit_Tools</Name>
@@ -107,6 +119,10 @@
       <Link>license_key_windows.txt</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <Content Include="..\..\..\..\x64\ComPDFKit.dll">
+      <Link>x64\ComPDFKit.dll</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="..\TestFile\ComPDFKit_Annotations_Sample_File.pdf">
       <Link>ComPDFKit_Annotations_Sample_File.pdf</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

Файловите разлики са ограничени, защото са твърде много
+ 3 - 2
Demo/Examples/Annotations/App.xaml.cs


+ 73 - 67
Demo/Examples/Annotations/MainWindow.xaml.cs

@@ -3,8 +3,6 @@ using Compdfkit_Tools.Data;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
 using ComPDFKitViewer;
-using ComPDFKitViewer.AnnotEvent;
-using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using System;
 using System.Collections.Generic;
@@ -21,6 +19,7 @@ using System.Windows.Controls.Primitives;
 using System.Windows.Input;
 using System.Windows.Media.Imaging;
 using Compdfkit_Tools.PDFView;
+using ComPDFKit.Tool;
 
 namespace AnnotationViewControl
 {
@@ -100,50 +99,60 @@ namespace AnnotationViewControl
         private void LoadDefaultDocument()
         {
             string defaultFilePath = "ComPDFKit_Annotations_Sample_File.pdf";
-            pdfViewer.PDFView.InitDocument(defaultFilePath);
+            pdfViewer.InitDocument(defaultFilePath);
             LoadDocument();
         }
 
         private void LoadDocument()
         {
-            pdfViewer.PDFView.Load();
-            pdfViewer.PDFView.SetShowLink(true);
-            
-            pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
-            pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
-            PDFGrid.Child = annotationControl;
-            
-            annotationControl.PDFViewControl = pdfViewer;
-            annotationControl.InitWithPDFViewer(pdfViewer.PDFView);
-            annotationControl.ClearAllToolState();
-            annotationControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
-
-            annotationControl.OnCanSaveChanged -= AnnotationControl_OnCanSaveChanged;
-            annotationControl.OnCanSaveChanged += AnnotationControl_OnCanSaveChanged;
-            annotationControl.OnAnnotEditHandler -= PdfAnnotationControl_RefreshAnnotList;
-            annotationControl.OnAnnotEditHandler += PdfAnnotationControl_RefreshAnnotList;
-            
-            annotationControl.PDFViewControl.PDFView.SetFormFieldHighlight(true);
-            PasswordUI.Closed -= PasswordUI_Closed;
-            PasswordUI.Canceled -= PasswordUI_Canceled;
-            PasswordUI.Confirmed -= PasswordUI_Confirmed;
-            PasswordUI.Closed += PasswordUI_Closed;
-            PasswordUI.Canceled += PasswordUI_Canceled;
-            PasswordUI.Confirmed += PasswordUI_Confirmed;
-            ModeComboBox.SelectedIndex = 1;
-            annotationControl.PDFViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-            CPDFSaclingControl.InitWithPDFViewer(annotationControl.PDFViewControl.PDFView);
-            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(annotationControl.PDFViewControl.PDFView.ZoomFactor * 100)));
-
-            ViewSettingBtn.IsChecked = false;
-            botaBarControl.InitWithPDFViewer(annotationControl.PDFViewControl.PDFView);
-            botaBarControl.AddBOTAContent(new []{BOTATools.Thumbnail , BOTATools.Outline , BOTATools.Bookmark , BOTATools.Annotation , BOTATools.Search});
-            botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
-            annotationControl.SetBOTAContainer(botaBarControl);
-            annotationControl.InitialPDFViewControl(annotationControl.PDFViewControl);
-            
-            panelState.PropertyChanged -= PanelState_PropertyChanged;
-            panelState.PropertyChanged += PanelState_PropertyChanged;
+            if (pdfViewer != null && pdfViewer.PDFViewTool != null)
+            {
+                CPDFViewer viewer = pdfViewer.PDFViewTool.GetCPDFViewer();
+                CPDFDocument pdfDoc = viewer?.GetDocument();
+                if (pdfDoc == null)
+                {
+                    return;
+                }
+
+                //pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
+                //pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
+                PDFGrid.Child = annotationControl;
+
+                annotationControl.PDFViewControl = pdfViewer;
+                regularViewerControl.PdfViewControl = pdfViewer;
+                annotationControl.InitWithPDFViewer(pdfViewer);
+                annotationControl.ClearAllToolState();
+                annotationControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
+
+                annotationControl.OnCanSaveChanged -= AnnotationControl_OnCanSaveChanged;
+                annotationControl.OnCanSaveChanged += AnnotationControl_OnCanSaveChanged;
+                annotationControl.OnAnnotEditHandler -= PdfAnnotationControl_RefreshAnnotList;
+                annotationControl.OnAnnotEditHandler += PdfAnnotationControl_RefreshAnnotList;
+
+                //annotationControl.PDFViewControl.PDFView.SetFormFieldHighlight(true);
+                PasswordUI.Closed -= PasswordUI_Closed;
+                PasswordUI.Canceled -= PasswordUI_Canceled;
+                PasswordUI.Confirmed -= PasswordUI_Confirmed;
+                PasswordUI.Closed += PasswordUI_Closed;
+                PasswordUI.Canceled += PasswordUI_Canceled;
+                PasswordUI.Confirmed += PasswordUI_Confirmed;
+                ModeComboBox.SelectedIndex = 1;
+                //annotationControl.PDFViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
+                CPDFSaclingControl.InitWithPDFViewer(annotationControl.PDFViewControl);
+                //CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(annotationControl.PDFViewControl.PDFView.ZoomFactor * 100)));
+
+                ViewSettingBtn.IsChecked = false;
+                botaBarControl.InitWithPDFViewer(annotationControl.PDFViewControl);
+                botaBarControl.AddBOTAContent(new[]
+                {
+                    BOTATools.Thumbnail, BOTATools.Outline, BOTATools.Bookmark, BOTATools.Annotation, BOTATools.Search
+                });
+                botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
+                annotationControl.SetBOTAContainer(botaBarControl);
+                annotationControl.InitialPDFViewControl(annotationControl.PDFViewControl);
+                panelState.PropertyChanged -= PanelState_PropertyChanged;
+                panelState.PropertyChanged += PanelState_PropertyChanged;
+            }
         }
         
         private void OpenFile()
@@ -151,9 +160,9 @@ namespace AnnotationViewControl
             string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && annotationControl.PDFViewControl != null)
             {
-                if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+                if (pdfViewer != null && pdfViewer.PDFToolManager != null)
                 {
-                    string oldFilePath = pdfViewer.PDFView.Document.FilePath;
+                    string oldFilePath = pdfViewer.PDFToolManager.GetDocument().FilePath;
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
@@ -161,14 +170,14 @@ namespace AnnotationViewControl
                 }
 
                 passwordViewer = new PDFViewControl();
-                passwordViewer.PDFView.InitDocument(filePath);
-                if (passwordViewer.PDFView.Document == null)
+                passwordViewer.InitDocument(filePath);
+                if (passwordViewer.PDFToolManager.GetDocument() == null)
                 {
                     MessageBox.Show("Open File Failed");
                     return;
                 }
 
-                if (passwordViewer.PDFView.Document.IsLocked)
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked)
                 {
                     PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
                     PasswordUI.ClearPassword();
@@ -177,7 +186,7 @@ namespace AnnotationViewControl
                 }
                 else
                 {
-                    pdfViewer.PDFView.Document.Release();
+                    pdfViewer?.PDFToolManager?.GetDocument().Release();
                     pdfViewer = passwordViewer;
                     LoadDocument();
                 }
@@ -190,10 +199,10 @@ namespace AnnotationViewControl
 
         private void PasswordUI_Confirmed(object sender, string e)
         {
-            if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
+            if (passwordViewer != null && passwordViewer.PDFToolManager != null && passwordViewer.PDFToolManager.GetDocument() != null)
             {
-                passwordViewer.PDFView.Document.UnlockWithPassword(e);
-                if (passwordViewer.PDFView.Document.IsLocked == false)
+                passwordViewer.PDFToolManager.GetDocument().UnlockWithPassword(e);
+                if (passwordViewer.PDFToolManager.GetDocument().IsLocked == false)
                 {
                     PasswordUI.SetShowError("", Visibility.Collapsed);
                     PasswordUI.ClearPassword();
@@ -234,9 +243,8 @@ namespace AnnotationViewControl
         
         private void LoadCustomControl()
         {
-            regularViewerControl.PdfViewControl = pdfViewer;
-            regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
-            regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
+            regularViewerControl.InitWithPDFViewer(pdfViewer);
+            regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
             regularViewerControl.SetBOTAContainer(null);
             regularViewerControl.SetBOTAContainer(botaBarControl);
             regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
@@ -277,7 +285,7 @@ namespace AnnotationViewControl
         private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
         {
             SaveFile();
-            pdfViewer.PDFView.UndoManager.CanSave = false;
+            pdfViewer.PDFViewTool.IsDocumentModified = false;
         }
 
         private void OpenFile_Click(object sender, RoutedEventArgs e)
@@ -310,24 +318,22 @@ namespace AnnotationViewControl
 
             if (item.Content as string == "Viewer")
             {
-                if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
+                if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFViewTool != null)
                 {
                     PDFGrid.Child = regularViewerControl;
-                    regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
-                    regularViewerControl.PdfViewControl = pdfViewer;
-                    regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
+                    regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
+                    regularViewerControl.InitWithPDFViewer(pdfViewer);
                     regularViewerControl.SetBOTAContainer(botaBarControl);
                     regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
                 }
             }
             else if (item.Content as string == "Annotation")
             {
-                if (annotationControl.PDFViewControl != null && annotationControl.PDFViewControl.PDFView != null)
+                if (annotationControl.PDFViewControl != null && annotationControl.PDFViewControl.PDFViewTool != null)
                 {
                     PDFGrid.Child = annotationControl;
-                    annotationControl.PDFViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
-                    annotationControl.PDFViewControl = pdfViewer;
-                    annotationControl.InitWithPDFViewer(pdfViewer.PDFView);
+                    annotationControl.PDFViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
+                    annotationControl.InitWithPDFViewer(pdfViewer);
                     annotationControl.SetBOTAContainer(botaBarControl);
                     annotationControl.SetDisplaySettingsControl(displaySettingsControl);
                 }
@@ -339,7 +345,7 @@ namespace AnnotationViewControl
         {
             PasswordUI.Visibility = Visibility.Collapsed;
             FileInfoUI.Visibility = Visibility.Visible;
-            FileInfoControl.InitWithPDFViewer(pdfViewer.PDFView);
+            FileInfoControl.InitWithPDFViewer(pdfViewer);
             PopupBorder.Visibility = Visibility.Visible;
         }
 
@@ -392,9 +398,9 @@ namespace AnnotationViewControl
         public void SaveAsFile()
         {
             {
-                if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+                if (pdfViewer != null && pdfViewer.PDFToolManager != null && pdfViewer.PDFToolManager.GetDocument() != null)
                 {
-                    CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewer.PDFToolManager.GetDocument();
                     SaveFileDialog saveDialog = new SaveFileDialog();
                     saveDialog.Filter = "(*.pdf)|*.pdf";
                     saveDialog.DefaultExt = ".pdf";
@@ -413,11 +419,11 @@ namespace AnnotationViewControl
         /// </summary>
         private void SaveFile()
         {
-            if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
+            if (pdfViewer != null && pdfViewer.PDFToolManager != null && pdfViewer.PDFToolManager.GetDocument() != null)
             {
                 try
                 {
-                    CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
+                    CPDFDocument pdfDoc = pdfViewer.PDFToolManager.GetDocument();
                     if (pdfDoc.WriteToLoadedPath())
                     {
                         return;

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Annotation/AnnotationControl/AnnotationControl.xaml.cs

@@ -125,7 +125,7 @@ namespace Compdfkit_Tools.PDFControl
             BotaContainer.Child = null;
             PropertyContainer.Child = null;
             displaySettingsControl = null;
-            PDFViewControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE);
+            PDFViewControl?.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE);
         }
 
         public void SetBOTAContainer(CPDFBOTABarControl botaControl)

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

@@ -36,15 +36,19 @@ namespace Compdfkit_Tools.PDFControl
             CPDFScalingUI.ScaleIncreaseEvent -= PDFScalingControl_ScaleIncreaseEvent;
             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;
+            
+            if (ViewControl != null)
+            {
+                ViewControl.MouseWheelZoomHandler -= PDFControl_MouseWheelZoomHandler;
+                ViewControl.FocusPDFViewToolChanged -= ViewControl_FocusPDFViewToolChanged;
+                ViewControl.MouseWheelZoomHandler += PDFControl_MouseWheelZoomHandler;
+                ViewControl.FocusPDFViewToolChanged += ViewControl_FocusPDFViewToolChanged;
+            }
         }
 
         private void ViewControl_FocusPDFViewToolChanged(object sender, EventArgs e)