Browse Source

ComPDFKit(windows) -form的FieldName的命名统一

zhuyi 1 year ago
parent
commit
6ad072df21

+ 12 - 6
compdfkit_demo_windows/compdfkit/compdfkit-tools/Form/FormBarControl.xaml.cs

@@ -359,6 +359,11 @@ namespace compdfkit_tools.Form
         #endregion
 
         #region Create Form
+        private string GetTime()
+        {
+            DateTime dateTime = DateTime.Now;
+            return " " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
+        }
 
         private void CreateTextBox()
         {
@@ -367,7 +372,7 @@ namespace compdfkit_tools.Form
             textArgs.LineWidth = 1;
             textArgs.FontName = "Helvetica";
             textArgs.LineColor = Colors.Black;
-            textArgs.FieldName = "Text";
+            textArgs.FieldName = "Text"+ GetTime();
             pdfViewer.SetToolParam(textArgs);
         }
 
@@ -379,7 +384,7 @@ namespace compdfkit_tools.Form
             radioArgs.BorderStyle = C_BORDER_STYLE.BS_SOLID;
             radioArgs.LineColor = Colors.Black;
             radioArgs.LineWidth = 2;
-            radioArgs.FieldName = "Radio Button";
+            radioArgs.FieldName = "Radio button" + GetTime();
             pdfViewer.SetToolParam(radioArgs);
         }
 
@@ -391,7 +396,7 @@ namespace compdfkit_tools.Form
             checkBoxArgs.BorderStyle = C_BORDER_STYLE.BS_SOLID;
             checkBoxArgs.LineColor = Colors.Black;
             checkBoxArgs.LineWidth = 1;
-            checkBoxArgs.FieldName = "CheckBox";
+            checkBoxArgs.FieldName = "Checkbox" + GetTime();
             pdfViewer.SetToolParam(checkBoxArgs);
         }
 
@@ -401,7 +406,7 @@ namespace compdfkit_tools.Form
             WidgetComboBoxArgs dropDownArgs = new WidgetComboBoxArgs();
             dropDownArgs.LineColor = Colors.Black;
             dropDownArgs.LineWidth = 1;
-            dropDownArgs.FieldName = "ComboBox";
+            dropDownArgs.FieldName = "Combobox" + GetTime();
             pdfViewer.SetToolParam(dropDownArgs);
         }
 
@@ -411,7 +416,7 @@ namespace compdfkit_tools.Form
             WidgetListBoxArgs listArgs = new WidgetListBoxArgs();
             listArgs.LineColor = Colors.Black;
             listArgs.LineWidth = 1;
-            listArgs.FieldName = "List";
+            listArgs.FieldName = "List" + GetTime();
             pdfViewer.SetToolParam(listArgs);
         }
 
@@ -425,7 +430,7 @@ namespace compdfkit_tools.Form
             ActionDict[C_ACTION_TYPE.ACTION_TYPE_URI] = @"https://www.compdf.com";
             pushButtonArgs.ActionDict = ActionDict;
             pushButtonArgs.LineColor = Colors.Black;
-            pushButtonArgs.FieldName = "Button";
+            pushButtonArgs.FieldName = "Button" + GetTime();
             pdfViewer.SetToolParam(pushButtonArgs);
         }
 
@@ -435,6 +440,7 @@ namespace compdfkit_tools.Form
             WidgetSignArgs signArgs = new WidgetSignArgs();
             signArgs.LineWidth = 1;
             signArgs.LineColor = Colors.Black;
+            signArgs.FieldName= "Signature" + GetTime();
             pdfViewer.SetToolParam(signArgs);
         }
 

+ 40 - 0
compdfkit_demo_windows/compdfkit/form-ctrl-demo/MainWindow.xaml.cs

@@ -701,6 +701,11 @@ namespace form_ctrl_demo
                 }
             }
         }
+        private string GetTime()
+        {
+            DateTime dateTime = DateTime.Now;
+            return " " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
+        }
 
         private void PDFView_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
         {
@@ -709,6 +714,41 @@ namespace form_ctrl_demo
                 AnnotEditEvent editEvent = e[e.Count - 1];
                 if (editEvent.EditAction == ActionType.Add)
                 {
+                    if (pdfViewControl.PDFView.ToolManager.CurrentAnnotArgs != null)
+                    {
+                        WidgetArgs widgetArgs = pdfViewControl.PDFView.ToolManager.CurrentAnnotArgs as WidgetArgs;
+                        if (widgetArgs != null)
+                        {
+                            switch (widgetArgs.WidgeType)
+                            {
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
+                                    widgetArgs.FieldName = "Button" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX:
+                                    widgetArgs.FieldName = "Checkbox" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
+                                    widgetArgs.FieldName = "Radio button" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:
+                                    widgetArgs.FieldName = "Text" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
+                                    widgetArgs.FieldName = "Combobox" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
+                                    widgetArgs.FieldName = "List" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
+                                    widgetArgs.FieldName = "Signature" + GetTime();
+                                    break;
+                                case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN:
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
                     pdfViewControl.PDFView.SelectAnnotation(editEvent.PageIndex, editEvent.AnnotIndex);
                 }
                 else if (editEvent.EditAction==ActionType.Del)