Przeglądaj źródła

compdfkit(win) - 颜色控件设置颜色错误

liuaoran 1 rok temu
rodzic
commit
11cf817273

+ 11 - 5
Demo/Examples/Compdfkit_Tools/Edit/PDFContentEditControl.xaml.cs

@@ -22,11 +22,10 @@ namespace Compdfkit_Tools.Edit
     /// </summary>
     public partial class PDFContentEditControl : UserControl
     {
-        private UIElement contentEditPanel = null;
-        private UIElement tempContentEditPanel = null;
-
         private PDFImageEditControl PDFImageEditControl = new PDFImageEditControl();
         private PDFTextEditControl PDFTextEditControl = new PDFTextEditControl();
+        private PDFTextEditControl tempPDFTextEditControl = null;
+        private PDFEditEvent editEvent = null;
 
         public CPDFViewer PDFView { get; private set; }
         public PDFEditEvent EditEvent { get; set; }
@@ -51,12 +50,19 @@ namespace Compdfkit_Tools.Edit
             }
             else
             {
-                PDFTextEditControl tempPDFTextEditControl = new PDFTextEditControl();
-                tempPDFTextEditControl.SetPDFTextEditData(editEvent);
+                tempPDFTextEditControl = new PDFTextEditControl();
+                this.editEvent = editEvent;
+                tempPDFTextEditControl.Loaded += TempPDFTextEditControl_Loaded;
                 ContentEditContainer.Child = tempPDFTextEditControl;
             }
         }
 
+        private void TempPDFTextEditControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            tempPDFTextEditControl.SetPDFTextEditData(editEvent);
+
+        }
+
         public void ClearContentControl()
         {
             ContentEditContainer.Child = null;

+ 1 - 0
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -1233,6 +1233,7 @@ namespace PDFViewer
         /// </summary>
         private void PDFView_PDFEditActiveHandler(object sender, ComPDFKitViewer.PDFEditEvent e)
         {
+            PropertyContainer.Child = pdfContentEditControl;
             lastPDFEditEvent = e;
             if ((bool)ViewSettingBtn.IsChecked)
             {

+ 44 - 14
Demo/Examples/Samples/AnnotationImportExportTest/AnnotationImportExportTest.cs

@@ -15,10 +15,13 @@ namespace AnnotationImportExportTest
 
         static void Main(string[] args)
         {
+
             Console.WriteLine("Running header and footer test sample…\r\n");
-            SDKLicenseHelper.LicenseVerify();
 
+            #region Preparation work
 
+            SDKLicenseHelper.LicenseVerify();
+             
             if (!Directory.Exists(outputPath))
             {
                 Directory.CreateDirectory(outputPath);
@@ -28,6 +31,10 @@ namespace AnnotationImportExportTest
                 Directory.CreateDirectory(tempPath);
             }
 
+            #endregion
+
+            #region Sample 1: Export Annotation 
+
             CPDFDocument annotationsDocument = CPDFDocument.InitWithFilePath("Annotations.pdf"); 
             if (ExportAnnotaiton(annotationsDocument))
             {
@@ -38,9 +45,12 @@ namespace AnnotationImportExportTest
                 Console.WriteLine("Export annotaiton failed.");
             } 
             Console.WriteLine("--------------------");
+            
+            #endregion
 
-            CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
+            #region Sample 2: Import Annotations
 
+            CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf"); 
             if (ImportAnnotaiton(document))
             {
                 Console.WriteLine("Import annotaiton done.");
@@ -50,11 +60,43 @@ namespace AnnotationImportExportTest
                 Console.WriteLine("Import annotaiton failed.");
             }
             Console.WriteLine("--------------------");
+            
+            #endregion
+
+            //---------- Finished ----------
             Console.WriteLine("Done");
             Console.WriteLine("--------------------");
             Console.ReadLine();
         }
 
+        /// <summary>
+        ///  Export the annotations in the document to XFDF format.
+        ///  Parameters in function "ImportAnnotationFromXFDFPath":
+        ///  1. The path to the exported XFDF file
+        ///  2. The path for storing temporary files. 
+        /// </summary>
+        /// <param name="document">A document with multiple annotations</param>
+        /// <returns></returns>
+        static private bool ExportAnnotaiton(CPDFDocument document)
+        {
+            var path = outputPath + "//ExportAnnotationTest.xfdf";
+            if (document.ExportAnnotationToXFDFPath(path, tempPath))
+            {
+                return false;
+            }
+            Console.WriteLine("Xfdf file in " + path);
+
+            return true;
+        }
+
+        /// <summary>
+        ///  Importing XFDF into the document.
+        ///  Parameters in function "ImportAnnotationFromXFDFPath":
+        ///  1. The path to the XFDF file for importing.
+        ///  2. The path for storing temporary files.  
+        /// </summary>
+        /// <param name="document">A document without annotations used for importing XFDF.</param>
+        /// <returns></returns>
         static private bool ImportAnnotaiton(CPDFDocument document)
         {
             var path = outputPath + "//ImportAnnotationTest.pdf";
@@ -70,17 +112,5 @@ namespace AnnotationImportExportTest
             Console.WriteLine("Browse the changed file in " + path); 
             return true;
         }
-
-        static private bool ExportAnnotaiton(CPDFDocument document)
-        {
-            var path = outputPath+ "//ExportAnnotationTest.xfdf";
-            if (document.ExportAnnotationToXFDFPath(path, tempPath)) 
-            {
-                return false;
-            }
-            Console.WriteLine("Xfdf file in " + path);
-
-            return true;
-        }
     }
 }