Pārlūkot izejas kodu

compdfkit(win) - 重写文档时调整了samples一些顺序

liuaoran 1 gadu atpakaļ
vecāks
revīzija
29423a80b3

+ 7 - 0
Demo/Examples/ContentEditor/ContentEditor.csproj

@@ -52,6 +52,7 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -123,6 +124,12 @@
   <ItemGroup>
     <Resource Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="..\license_key_windows.txt">
+      <Link>license_key_windows.txt</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\ComPDFKit.NetFramework.1.10.0\build\ComPDFKit.NetFramework.targets" Condition="Exists('..\packages\ComPDFKit.NetFramework.1.10.0\build\ComPDFKit.NetFramework.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 28 - 26
Demo/Examples/ContentEditor/MainWindow.xaml.cs

@@ -29,10 +29,10 @@ namespace ContentEditorViewControl
     /// <summary>
     /// Interaction logic for MainWindow.xaml
     /// </summary>
-   public partial class MainWindow: Window, INotifyPropertyChanged
+    public partial class MainWindow : Window, INotifyPropertyChanged
     {
         #region Properties
-        
+
         private PanelState panelState = PanelState.GetInstance();
         private CPDFDisplaySettingsControl displaySettingsControl = new CPDFDisplaySettingsControl();
         private RegularViewerControl regularViewerControl = new RegularViewerControl();
@@ -42,7 +42,7 @@ namespace ContentEditorViewControl
         private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl();
         public event PropertyChangedEventHandler PropertyChanged;
         private string currentMode = "Viewer";
-        
+
         private bool _canSave = false;
         public bool CanSave
         {
@@ -54,7 +54,7 @@ namespace ContentEditorViewControl
                 OnPropertyChanged();
             }
         }
-        
+
         public bool LeftToolPanelButtonIsChecked
         {
             get => panelState.IsLeftPanelExpand;
@@ -64,7 +64,7 @@ namespace ContentEditorViewControl
                 OnPropertyChanged();
             }
         }
-        
+
         public bool ViewSettingBtnIsChecked
         {
             get
@@ -77,7 +77,7 @@ namespace ContentEditorViewControl
                 OnPropertyChanged();
             }
         }
-        
+
         public bool RightToolPanelButtonIsChecked
         {
             get
@@ -95,6 +95,7 @@ namespace ContentEditorViewControl
         {
             InitializeComponent();
             DataContext = this;
+            pdfViewer.PDFView.SetFormFieldHighlight(tr);
         }
 
         #region Load document
@@ -110,11 +111,11 @@ namespace ContentEditorViewControl
         {
             pdfViewer.PDFView.Load();
             pdfViewer.PDFView.SetShowLink(true);
-            
+
             pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
             pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
             PDFGrid.Child = contentEditControl;
-            
+
             contentEditControl.PdfViewControl = pdfViewer;
             contentEditControl.InitWithPDFViewer(pdfViewer.PDFView);
             InitialPDFViewControl();
@@ -123,7 +124,7 @@ namespace ContentEditorViewControl
             contentEditControl.OnCanSaveChanged += ControlOnCanSaveChanged;
             contentEditControl.OnAnnotEditHandler -= PdfContentEditControlRefreshAnnotList;
             contentEditControl.OnAnnotEditHandler += PdfContentEditControlRefreshAnnotList;
-            
+
             contentEditControl.PdfViewControl.PDFView.SetFormFieldHighlight(true);
             PasswordUI.Closed -= PasswordUI_Closed;
             PasswordUI.Canceled -= PasswordUI_Canceled;
@@ -139,14 +140,14 @@ namespace ContentEditorViewControl
 
             ViewSettingBtn.IsChecked = false;
             botaBarControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
-            botaBarControl.AddBOTAContent(new []{BOTATools.Thumbnail , BOTATools.Outline , BOTATools.Bookmark , BOTATools.Annotation , BOTATools.Search});
+            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);
             panelState.PropertyChanged -= PanelState_PropertyChanged;
             panelState.PropertyChanged += PanelState_PropertyChanged;
         }
-        
+
         private void OpenFile()
         {
             string filePath = CommonHelper.GetExistedPathOrEmpty();
@@ -184,9 +185,9 @@ namespace ContentEditorViewControl
                 }
             }
         }
-        
+
         #endregion
-        
+
         #region Password
 
         private void PasswordUI_Confirmed(object sender, string e)
@@ -223,7 +224,7 @@ namespace ContentEditorViewControl
         }
 
         #endregion
-        
+
         #region Load Unload custom control
 
         private void Window_Loaded(object sender, RoutedEventArgs e)
@@ -232,20 +233,20 @@ namespace ContentEditorViewControl
             LoadDefaultDocument();
         }
         #endregion
-        
+
         #region Annotation
 
         private void InitialPDFViewControl()
         {
             contentEditControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
         }
-          
+
         #endregion
-        
+
         #region Event handle
 
         private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
-        { 
+        {
             if (e.Key == "Zoom")
             {
                 CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
@@ -257,7 +258,7 @@ namespace ContentEditorViewControl
             SaveFile();
             pdfViewer.PDFView.UndoManager.CanSave = false;
         }
-        
+
         private void OpenFile_Click(object sender, RoutedEventArgs e)
         {
             OpenFile();
@@ -266,6 +267,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));
         }
 
         private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -276,12 +278,12 @@ namespace ContentEditorViewControl
                 return;
             }
             ClearPanelState();
-            
+
             if (currentMode == "Viewer")
             {
                 regularViewerControl.ClearViewerControl();
             }
-            else if(currentMode == "Content Edit")
+            else if (currentMode == "Content Edit")
             {
                 contentEditControl.ClearViewerControl();
             }
@@ -333,14 +335,14 @@ namespace ContentEditorViewControl
                 ((sender as ToggleButton).IsChecked == true) ?
                     PanelState.RightPanelState.ViewSettings : PanelState.RightPanelState.None;
         }
-        
+
         private void RightPanelButton_Click(object sender, RoutedEventArgs e)
         {
             panelState.RightPanel =
                 ((sender as ToggleButton).IsChecked == true) ?
                     PanelState.RightPanelState.PropertyPanel : PanelState.RightPanelState.None;
         }
-        
+
         private void ClearPanelState()
         {
             LeftToolPanelButtonIsChecked = false;
@@ -354,7 +356,7 @@ namespace ContentEditorViewControl
             LeftToolPanelButtonIsChecked = true;
             botaBarControl.SelectBotaTool(BOTATools.Search);
         }
-        
+
         private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "RightPanel")
@@ -373,7 +375,7 @@ namespace ContentEditorViewControl
         {
             this.CanSave = e;
         }
-        
+
         private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
         {
             PopupBorder.Visibility = Visibility.Collapsed;
@@ -382,7 +384,7 @@ namespace ContentEditorViewControl
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
-        
+
         #endregion
 
         #region Save file

+ 17 - 1
Demo/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs

@@ -2,6 +2,7 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFPage;
+using ComPDFKitViewer.PdfViewer;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
@@ -64,8 +65,8 @@ namespace AnnotationTest
         static private void CreateFreetextAnnotation(CPDFDocument document)
         {
             CPDFPage page = document.PageAtIndex(0);
-            string str = "ComPDFKit Samples";
             CPDFFreeTextAnnotation freeText = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT) as CPDFFreeTextAnnotation;
+            string str = "ComPDFKit Samples";
             freeText.SetContent(str);
             freeText.SetRect(new CRect(0, 100, 160, 0));
             CTextAttribute textAttribute = new CTextAttribute();
@@ -279,6 +280,17 @@ namespace AnnotationTest
             image.UpdateAp();
         }
 
+
+        private static void CreateLinkAnnotation(CPDFDocument document)
+        {
+            CPDFPage page = document.PageAtIndex(0); 
+            CPDFDestination dest = new CPDFDestination();
+            dest.PageIndex = 1;
+            CPDFLinkAnnotation link = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_LINK) as CPDFLinkAnnotation;
+            link.SetRect(new CRect(0, 50, 50, 0));
+            link.SetDestination(document, dest);
+        }
+
         /// <summary>
         /// Create annotations
         /// </summary>
@@ -294,6 +306,7 @@ namespace AnnotationTest
             CreateSoundAnnotation(document);
             CreateMarkupAnnotation(document);
             CreateStampAnnotation(document);
+            CreateLinkAnnotation(document);
             string path = Path.Combine(outputPath, "CreateAnnotsTest.pdf");
             if (!document.WriteToFilePath(path))
             {
@@ -303,6 +316,7 @@ namespace AnnotationTest
             return true;
         }
 
+
         /// <summary>
         /// Delete the first annotation
         /// </summary>
@@ -310,6 +324,8 @@ namespace AnnotationTest
         /// <returns></returns>
         static private bool DeleteAnnotations(CPDFDocument document)
         {
+
+
             CPDFPage page = document.PageAtIndex(0);
 
             List<CPDFAnnotation> annotList = page.GetAnnotations();

+ 2 - 2
Demo/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj

@@ -114,10 +114,10 @@
     </BootstrapperPackage>
   </ItemGroup>
   <ItemGroup>
-    <Resource Include="..\..\..\license_key_windows.txt">
+    <None Include="..\..\..\license_key_windows.txt">
       <Link>license_key_windows.txt</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Resource>
+    </None>
     <Content Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 9 - 5
Demo/Examples/Samples/OutlineTest/CS/OutlineTest.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFDocument.Action;
 using System;
 using System.Collections.Generic;
 using System.IO; 
@@ -121,8 +122,7 @@ namespace OutlineTest
                     TraverseOutline(childList);
                 }
                 else
-                {
-                    var i = outlineList.IndexOf(outline);
+                { 
                     if (outlineList.IndexOf(outline)+1 == outlineList.Count)
                     {
                         outlineCounter--;
@@ -153,9 +153,13 @@ namespace OutlineTest
         {
             CPDFOutline outline = document.GetOutlineRoot();
             CPDFOutline childOutline = null;
-            outline.InsertChildAtIndex(document, 0, ref childOutline); 
-            childOutline.SetTitle("New outline");
-
+            outline.InsertChildAtIndex(document, 0, ref childOutline);
+            CPDFGoToAction gotoAction = new CPDFGoToAction();
+            CPDFDestination dest = new CPDFDestination();
+            dest.PageIndex = 1;
+            gotoAction.SetDestination(document, dest);
+            childOutline.SetAction(gotoAction);
+            childOutline.SetTitle("New outline"); 
             PrintOutline(document);
             return true;
         }

+ 2 - 2
Demo/Examples/Samples/TextSearchTest/CS/TextSearchTest.csproj

@@ -73,10 +73,10 @@
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
-    <Resource Include="..\..\..\license_key_windows.txt">
+    <None Include="..\..\..\license_key_windows.txt">
       <Link>license_key_windows.txt</Link>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Resource>
+    </None>
     <Content Include="ComPDFKit_Logo.ico" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />