Procházet zdrojové kódy

compdfkit(win) - 内容编辑项目调整

weixiangjie před 9 měsíci
rodič
revize
d4c350c88a

+ 24 - 0
Demo/Examples/Compdfkit_Tools/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs

@@ -661,6 +661,8 @@ namespace Compdfkit_Tools.PDFControl
             switch (e.hitTestType)
             {
                 case MouseHitTestType.TextEdit:
+                    CreateTextEditMenu(sender,ref ContextMenu);
+                    break;
                 case MouseHitTestType.ImageEdit:
                     CreateImageEditMenu(sender, ref ContextMenu);
                     break;
@@ -670,6 +672,28 @@ namespace Compdfkit_Tools.PDFControl
             }
             PdfViewControl.SetRightMenu(ContextMenu);
         }
+
+        private void CreateTextEditMenu(object sender, ref ContextMenu menu)
+        {
+            int index = -1;
+            CPDFEditTextArea textArea =
+                PdfViewControl.PDFToolManager.GetSelectedEditAreaObject(ref index) as CPDFEditTextArea;
+            if (textArea != null)
+            {
+                if (PdfViewControl.PDFToolManager.GetDocument().GetPermissionsInfo().AllowsCopying)
+                {
+                    menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
+                }
+                menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
+                menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
+                menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+            }
+            else
+            {
+                menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
+            }
+        }
+
         private void CreateImageEditMenu(object sender, ref ContextMenu menu)
         {
             int index = -1;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 3 - 2
Demo/Examples/ContentEditor/App.xaml.cs


+ 15 - 9
Demo/Examples/ContentEditor/ContentEditor.csproj

@@ -106,12 +106,18 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\license_key_windows.xml">
-      <Link>license_key_windows.xml</Link>
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-  </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>
@@ -121,10 +127,10 @@
     <Resource Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\license_key_windows.xml">
-      <Link>license_key_windows.xml</Link>
+    <Content Include="..\..\..\..\x64\ComPDFKit.dll">
+      <Link>x64\ComPDFKit.dll</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
+    </Content>
     <Content Include="..\TestFile\ComPDFKit_Sample_File_Windows.pdf">
       <Link>ComPDFKit_Sample_File_Windows.pdf</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

+ 41 - 47
Demo/Examples/ContentEditor/MainWindow.xaml.cs

@@ -11,6 +11,9 @@ using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
+using Compdfkit_Tools.PDFControlUI;
+using ComPDFKit.PDFPage;
+using ComPDFKit.Tool;
 
 namespace ContentEditorViewControl
 {
@@ -90,19 +93,15 @@ namespace ContentEditorViewControl
         private void LoadDefaultDocument()
         {
             string defaultFilePath = "ComPDFKit_Sample_File_Windows.pdf";
-            viewControl.PDFView.InitDocument(defaultFilePath);
+            viewControl.InitDocument(defaultFilePath);
             LoadDocument();
         }
 
         private void LoadDocument()
         {
-            viewControl.PDFView.Load();
-            viewControl.PDFView.SetShowLink(true);
-            
-            viewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
-            viewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
             PDFGrid.Child = contentEditControl;
             
+            regularViewerControl.PdfViewControl = viewControl;
             contentEditControl.PdfViewControl = viewControl;
             contentEditControl.InitWithPDFViewer(viewControl);
             InitialPDFViewControl();
@@ -112,7 +111,6 @@ namespace ContentEditorViewControl
             contentEditControl.OnAnnotEditHandler -= PdfContentEditControlRefreshAnnotList;
             contentEditControl.OnAnnotEditHandler += PdfContentEditControlRefreshAnnotList;
 
-            contentEditControl.PdfViewControl.PDFView.SetFormFieldHighlight(true);
             PasswordUI.Closed -= PasswordUI_Closed;
             PasswordUI.Canceled -= PasswordUI_Canceled;
             PasswordUI.Confirmed -= PasswordUI_Confirmed;
@@ -121,16 +119,16 @@ namespace ContentEditorViewControl
             PasswordUI.Confirmed += PasswordUI_Confirmed;
 
             ViewComboBox.SelectedIndex = 1;
-            contentEditControl.PdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
-            CPDFSaclingControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
-            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(contentEditControl.PdfViewControl.PDFView.ZoomFactor * 100)));
+            contentEditControl.PdfViewControl.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
+            CPDFSaclingControl.InitWithPDFViewer(contentEditControl.PdfViewControl);
+            CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(contentEditControl.PdfViewControl.GetCPDFViewer().GetZoom() * 100)));
 
             ViewSettingBtn.IsChecked = false;
-            botaBarControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
+            botaBarControl.InitWithPDFViewer(contentEditControl.PdfViewControl);
             botaBarControl.AddBOTAContent(new[] { BOTATools.Thumbnail, BOTATools.Outline, BOTATools.Bookmark, BOTATools.Annotation, BOTATools.Search });
             botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
             contentEditControl.SetBOTAContainer(botaBarControl);
-            displaySettingsControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
+            displaySettingsControl.InitWithPDFViewer(contentEditControl.PdfViewControl);
             panelState.PropertyChanged -= PanelState_PropertyChanged;
             panelState.PropertyChanged += PanelState_PropertyChanged;
         }
@@ -140,9 +138,9 @@ namespace ContentEditorViewControl
             string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && contentEditControl.PdfViewControl != null)
             {
-                if (viewControl.PDFView != null && viewControl.PDFView.Document != null)
+                if (viewControl.PDFToolManager != null && viewControl.PDFToolManager.GetDocument() != null)
                 {
-                    string oldFilePath = viewControl.PDFView.Document.FilePath;
+                    string oldFilePath = viewControl.PDFToolManager.GetDocument().FilePath;
                     if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
@@ -150,14 +148,14 @@ namespace ContentEditorViewControl
                 }
 
                 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();
@@ -166,7 +164,7 @@ namespace ContentEditorViewControl
                 }
                 else
                 {
-                    viewControl.PDFView.Document.Release();
+                    viewControl.PDFToolManager.GetDocument().Release();
                     viewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -183,8 +181,8 @@ namespace ContentEditorViewControl
             {
                 CPDFViewer pdfViewer=passwordViewer.PDFViewTool.GetCPDFViewer();
 
-                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();
@@ -255,7 +253,7 @@ namespace ContentEditorViewControl
         private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
         {
             panelState.IsLeftPanelExpand = (sender as ToggleButton).IsChecked == true;
-            pdfViewer.PDFView.GoToPage(pageIndex: 1, new Point(100, 100));
+            contentEditControl.PdfViewControl.GetCPDFViewer().GoToPage(PageIndex: 1, new Point(100, 100));
         }
 
         private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -269,7 +267,7 @@ namespace ContentEditorViewControl
 
             if (currentMode == "Viewer")
             {
-               // regularViewerControl.ClearViewerControl();
+                regularViewerControl.ClearViewerControl();
             }
             else if (currentMode == "Content Edit")
             {
@@ -277,34 +275,30 @@ namespace ContentEditorViewControl
             }
             if ((string)item.Content == "Viewer")
             {
-                //if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
-                //{
-                //    PDFGrid.Child = regularViewerControl;
-                //    regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
-                //    regularViewerControl.PdfViewControl = viewControl;
-                //    regularViewerControl.InitWithPDFViewer(viewControl.PDFView);
-                //    regularViewerControl.SetBOTAContainer(botaBarControl);
-                //    regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
-                //}
+                if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFViewTool != null)
+                {
+                    PDFGrid.Child = regularViewerControl;
+                    regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
+                    regularViewerControl.PdfViewControl = viewControl;
+                    regularViewerControl.InitWithPDFViewer(viewControl);
+                    regularViewerControl.SetBOTAContainer(botaBarControl);
+                    regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
+                }
             }
             else if ((string)item.Content == "Content Edit")
             {
-                //if (contentEditControl.PdfViewControl != null && contentEditControl.PdfViewControl.PDFView != null)
-                //{
-                //    viewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
-                //    viewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
-                //    viewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                //    viewControl.PDFView?.SetSplitMode(SplitMode.None);
-
-                //    PDFGrid.Child = contentEditControl;
-                //    contentEditControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.PDFEdit);
-                //    contentEditControl.PdfViewControl = viewControl;
-                //    contentEditControl.InitWithPDFViewer(viewControl.PDFView);
-                //    contentEditControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
-                //    contentEditControl.OnCanSaveChanged += ControlOnCanSaveChanged;
-                //    contentEditControl.SetBOTAContainer(botaBarControl);
-                //    contentEditControl.SetDisplaySettingsControl(displaySettingsControl);
-                //}
+                contentEditControl.PdfViewControl = viewControl;
+                contentEditControl.InitWithPDFViewer(viewControl);
+                displaySettingsControl.SetVisibilityWhenContentEdit(Visibility.Collapsed);
+                if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl!= null)
+                {
+                    PDFGrid.Child = contentEditControl;
+                    viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.ContentEdit);
+                    contentEditControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
+                    contentEditControl.OnCanSaveChanged += ControlOnCanSaveChanged;
+                    contentEditControl.SetBOTAContainer(botaBarControl);
+                    contentEditControl.SetDisplaySettingsControl(displaySettingsControl);
+                }
             }
             currentMode = item.Content as string;
         }