Pārlūkot izejas kodu

Form - 更新属性

chenrongqian 2 gadi atpakaļ
vecāks
revīzija
320da20fe4

+ 54 - 0
PDF Office/Helper/UpdateAttributeHelper.cs

@@ -0,0 +1,54 @@
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Helper
+{
+    /// <summary>
+    /// 更新属性
+    /// </summary>
+    public class UpdateAttributeHelper
+    {
+        private AnnotAttribEvent annotAttribEvent;
+        private AnnotEditEvent annotEditEvent;
+        public UpdateAttributeHelper(AnnotAttribEvent Event)
+        {
+            annotAttribEvent = Event;
+        }
+
+        public UpdateAttributeHelper(AnnotEditEvent Event)
+        {
+            annotEditEvent = Event;
+        }
+
+        public void UpdateAttrib(AnnotAttrib attrib, object updateData)
+        {
+            if (annotAttribEvent != null)
+            {
+                annotAttribEvent.UpdateAttrib(attrib, updateData);
+            }
+
+            if (annotEditEvent != null)
+            {
+
+            }
+        }
+
+        public void UpdateAnnot()
+        {
+            if (annotAttribEvent != null)
+            {
+                annotAttribEvent.UpdateAnnot();
+            }
+
+            if (annotEditEvent != null && annotEditEvent.EditAnnotArgs != null)
+            {
+                annotEditEvent.EditAnnotArgs.UpdateAnnotByEventArgs();
+            }
+        }
+    }
+}

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -271,6 +271,7 @@
     <Compile Include="Helper\SetterAction.cs" />
     <Compile Include="Helper\SettingHelper.cs" />
     <Compile Include="Helper\ToolMethod.cs" />
+    <Compile Include="Helper\UpdateAttributeHelper.cs" />
     <Compile Include="Model\AnnotPanel\Signature.cs" />
     <Compile Include="Model\BOTA\AnnotationHandlerEventArgs.cs" />
     <Compile Include="Model\AnnotPanel\Stamp.cs" />

+ 1 - 0
PDF Office/ViewModels/Form/ButtonPropertyViewModel.cs

@@ -119,6 +119,7 @@ namespace PDF_Office.ViewModels.Form
                 pushButtonArgs.Text = "PushButton";
 
                 this.pushButtonArgs = pushButtonArgs;
+                PDFViewer.SetToolParam(pushButtonArgs);
             }
             else
             {

+ 9 - 40
PDF Office/ViewModels/Form/FormsToolContentViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -14,38 +15,6 @@ using System.Windows;
 
 namespace PDF_Office.ViewModels.Form
 {
-    public class UpdateAttributeEvent
-    {
-        private AnnotAttribEvent annotAttribEvent;
-        private AnnotEditEvent annotEditEvent;
-        public UpdateAttributeEvent(AnnotAttribEvent Event)
-        {
-            annotAttribEvent = Event;
-        }
-
-        public UpdateAttributeEvent(AnnotEditEvent Event)
-        {
-            annotEditEvent = Event;
-        }
-
-        public void UpdateAttrib(AnnotAttrib attrib, object updateData)
-        {
-            if(annotAttribEvent != null)
-            {
-                annotAttribEvent.UpdateAttrib(attrib, updateData);
-            }
-
-            if (annotEditEvent != null)
-            {
-               
-            }
-        }
-
-        public void UpdateAnnot()
-        {
-
-        }
-    }
     public class FormsToolContentViewModel : BindableBase, INavigationAware
     {
         #region 属性
@@ -147,7 +116,7 @@ namespace PDF_Office.ViewModels.Form
             }
         }
 
-        private void AddToPropertyPanel(string type, WidgetArgs widget = null, AnnotAttribEvent e = null)
+        private void AddToPropertyPanel(string type, WidgetArgs widget = null, UpdateAttributeHelper e = null)
         {
             if (btnToProperty.ContainsKey(type))
             {
@@ -262,25 +231,25 @@ namespace PDF_Office.ViewModels.Form
             switch (widgetArgs.WidgeType)
             {
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:
-                    AddToPropertyPanel("Text", widgetArgs,e);
+                    AddToPropertyPanel("Text", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX:
-                    AddToPropertyPanel("CheckBox", widgetArgs, e);
+                    AddToPropertyPanel("CheckBox", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
-                    AddToPropertyPanel("RadioButton", widgetArgs, e);
+                    AddToPropertyPanel("RadioButton", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
-                    AddToPropertyPanel("ListBox", widgetArgs, e);
+                    AddToPropertyPanel("ListBox", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
-                    AddToPropertyPanel("Combox", widgetArgs, e);
+                    AddToPropertyPanel("Combox", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
-                    AddToPropertyPanel("Button", widgetArgs, e);
+                    AddToPropertyPanel("Button", widgetArgs, new UpdateAttributeHelper(e));
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
-                    AddToPropertyPanel("Sign", widgetArgs, e);
+                    AddToPropertyPanel("Sign", widgetArgs, new UpdateAttributeHelper(e));
                     break;
 
             }

+ 4 - 2
PDF Office/ViewModels/Form/TextFieldPropertyViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -60,7 +61,7 @@ namespace PDF_Office.ViewModels.Form
         #region 变量
         private CPDFViewer PDFViewer;
         private WidgetTextBoxArgs textBoxArgs;
-        public AnnotAttribEvent AttribEvent;
+        public UpdateAttributeHelper AttribEvent;
         #endregion
 
         #region 初始化
@@ -147,6 +148,7 @@ namespace PDF_Office.ViewModels.Form
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
             navigationContext.Parameters.TryGetValue<WidgetTextBoxArgs>("WidgetArgs", out textBoxArgs);
            
             GetWidgeText();
@@ -195,7 +197,7 @@ namespace PDF_Office.ViewModels.Form
                     break;
 
                 case FormAttributeType.ToolTip:
-                  
+                    AttribEvent?.UpdateAttrib(AnnotAttrib.Tooltip, ToolTipStr);
                     break;
 
                 case FormAttributeType.IsSolid: