Explorar o código

Form - 通用属性、通用更改属性

chenrongqian %!s(int64=2) %!d(string=hai) anos
pai
achega
60bc3a74b8

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

@@ -25,6 +25,17 @@ namespace PDF_Office.Helper
             annotEditEvent = Event;
         }
 
+        public bool IsCreateForm()
+        {
+            if (annotEditEvent != null)
+            {
+                if(annotEditEvent.EditAction == ActionType.Add)
+                    return true;
+            }
+
+            return false;
+        }
+
         public void UpdateAttrib(AnnotAttrib attrib, object updateData)
         {
             if (annotAttribEvent != null)

+ 30 - 30
PDF Office/ViewModels/Form/ButtonPropertyViewModel.cs

@@ -60,8 +60,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
       
@@ -133,47 +133,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 30 - 30
PDF Office/ViewModels/Form/CheckBoxPropertyViewModel.cs

@@ -66,8 +66,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
         #endregion
@@ -130,47 +130,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 30 - 30
PDF Office/ViewModels/Form/ComboxPropertyViewModel.cs

@@ -58,8 +58,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
         #endregion
@@ -122,47 +122,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 259 - 92
PDF Office/ViewModels/Form/FormBaseVM.cs

@@ -1,75 +1,50 @@
-using Prism.Mvvm;
+using ComPDFKitViewer;
+using PDF_Office.Model.From;
+using Prism.Mvvm;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Media;
+using System.Windows;
+using PDF_Office.CustomControl.CompositeControl;
+using ComPDFKit.PDFAnnotation;
+using PDF_Office.Helper;
 
 namespace PDF_Office.ViewModels.Form
 {
-    public enum FormAttributeType
-    {
-        Name,
-        ToolTip,
-        IsReadOnly,
-        IsRequiredField,
-        IsLocked,
-        //外观
-        BorderThiness,
-        IsSolid,
-        WidthSize,
-        HeightSize,
-        BorderColor,
-        ContentColor,
-        FillColor,
-        FontFamily
-    }
-    public class ResetColor : BindableBase
-    {
-        private SolidColorBrush _borderColor;
-        public SolidColorBrush BorderColor
-        {
-            get { return _borderColor; }
-            set { SetProperty(ref _borderColor, value); }
-        }
-
-        private SolidColorBrush _fontColor;
-        public SolidColorBrush FontColor
-        {
-            get { return _fontColor; }
-            set { SetProperty(ref _fontColor, value); }
-        }
 
-
-        private SolidColorBrush _fillColor;
-        public SolidColorBrush FillColor
-        {
-            get { return _fillColor; }
-            set { SetProperty(ref _fillColor, value); }
-        }
-    }
     public class FormBaseVM : BindableBase
     {
-        #region 触发事件
-        public event EventHandler<FormAttributeType> ChangeValueHandler;
+        #region 变量
+        public UpdateAttributeHelper AttribEvent;
+        public bool IsCurrentWidget = false;
+        public bool isCreateWidget = false;
         #endregion
-
         #region 一般
+        //名称
+        private string _fieldName;
+        public string FieldName
+        {
+            get { return _fieldName; }
+            set { SetProperty(ref _fieldName, value); ChangeValue(AnnotAttrib.FieldName, value); }
+        }
+
         //提示
         private string _toolTipStr;
         public string ToolTipStr
         {
             get { return _toolTipStr; }
-            set { SetProperty(ref _toolTipStr, value); ChangeValueHandler?.Invoke(value, FormAttributeType.ToolTip); }
+            set { SetProperty(ref _toolTipStr, value); ChangeValue(AnnotAttrib.Tooltip, value); }
         }
 
-        //名称
-        private string _nameStr;
-        public string NameStr
+        //表单域
+        private FormFieldType _formField;
+        public FormFieldType FormField
         {
-            get { return _nameStr; }
-            set { SetProperty(ref _nameStr, value); ChangeValueHandler?.Invoke(value, FormAttributeType.Name); }
+            get { return _formField; }
+            set { SetProperty(ref _formField, value); ChangeValue(AnnotAttrib.FormField, value); }
         }
 
         //只读
@@ -77,7 +52,7 @@ namespace PDF_Office.ViewModels.Form
         public bool IsReadOnly
         {
             get { return _isReadOnly; }
-            set { SetProperty(ref _isReadOnly, value); ChangeValueHandler?.Invoke(value, FormAttributeType.IsReadOnly); }
+            set { SetProperty(ref _isReadOnly, value); ChangeValue(AnnotAttrib.ReadOnly, value); }
         }
 
         //必填
@@ -85,7 +60,7 @@ namespace PDF_Office.ViewModels.Form
         public bool IsRequiredField
         {
             get { return _isRequiredField; }
-            set { SetProperty(ref _isRequiredField, value); ChangeValueHandler?.Invoke(value, FormAttributeType.IsRequiredField); }
+            set { SetProperty(ref _isRequiredField, value); ChangeValue(AnnotAttrib.IsRequired, value); }
         }
 
         //锁定
@@ -93,18 +68,75 @@ namespace PDF_Office.ViewModels.Form
         public bool IsLocked
         {
             get { return _isLocked; }
-            set { SetProperty(ref _isLocked, value); ChangeValueHandler?.Invoke(value, FormAttributeType.IsLocked); }
+            set { SetProperty(ref _isLocked, value); ChangeValue(AnnotAttrib.Locked, value); }
         }
 
         #endregion
 
         #region 外观
+
+        #region 四个选项:颜色样式
+
+        private ResetColor _resetColorOne = new ResetColor();
+        public ResetColor ResetColorOne
+        {
+            get { return _resetColorOne; }
+            set { SetProperty(ref _resetColorOne, value); }
+        }
+
+        private ResetColor _resetColorTwo = new ResetColor();
+        public ResetColor ResetColorTwo
+        {
+            get { return _resetColorTwo; }
+            set { SetProperty(ref _resetColorTwo, value); }
+        }
+
+        private ResetColor _resetColorThree = new ResetColor();
+        public ResetColor ResetColorThree
+        {
+            get { return _resetColorThree; }
+            set { SetProperty(ref _resetColorThree, value); }
+        }
+
+        private ResetColor _resetColorForth = new ResetColor();
+        public ResetColor ResetColorForth
+        {
+            get { return _resetColorForth; }
+            set { SetProperty(ref _resetColorForth, value); }
+        }
+
+        #endregion
+
+        //边框颜色
+        private Color _borderColor = Colors.Transparent;
+        public Color BorderColor
+        {
+            get { return _borderColor; }
+            set { SetProperty(ref _borderColor, value); ChangeValue(AnnotAttrib.Color, value); }
+        }
+
+        //内容颜色
+        private Color _contentColor = Colors.Transparent;
+        public Color ContentColor
+        {
+            get { return _contentColor; }
+            set { SetProperty(ref _contentColor, value); ChangeValue(AnnotAttrib.FontColor, value); }
+        }
+
+        //填充颜色
+        private Color _fillColor = Colors.Transparent;
+        public Color FillColor
+        {
+            get { return _fillColor; }
+            set { SetProperty(ref _fillColor, value); ChangeValue(AnnotAttrib.FillColor, value); }
+        }
+
         //边框大小
         private double _borderThiness = 0;
         public double BorderThiness
         {
             get { return _borderThiness; }
-            set { SetProperty(ref _borderThiness, value); ChangeValueHandler?.Invoke(value, FormAttributeType.BorderThiness); }
+            set { SetProperty(ref _borderThiness, value); ChangeValue(AnnotAttrib.Thickness, value); }
         }
 
         //是否为实线条
@@ -115,7 +147,7 @@ namespace PDF_Office.ViewModels.Form
             set { SetProperty(ref _isSolid, value);  }
         }
 
-        //是否为实线条
+        //线条样式
         private ComPDFKit.PDFAnnotation.C_BORDER_STYLE _borderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID;
         public ComPDFKit.PDFAnnotation.C_BORDER_STYLE BorderStyle
         {
@@ -127,7 +159,78 @@ namespace PDF_Office.ViewModels.Form
                 else
                     IsSolid = false;
 
-                ChangeValueHandler?.Invoke(value, FormAttributeType.IsSolid); }
+                ChangeValue(AnnotAttrib.LineStyle, value);
+            }
+        }
+
+
+        private ComboDataItem _fontFamilyData;
+        public ComboDataItem FontFamilyData
+        {
+            get { return _fontFamilyData; }
+            set
+            {
+                SetProperty(ref _fontFamilyData, value);
+                ChangeValue(AnnotAttrib.FontFamily, _fontFamilyData.ValueStr);
+            }
+        }
+
+
+        private FontStyle _fontStyle;
+        public FontStyle FontStyleItem
+        {
+            get { return _fontStyle; }
+            set { SetProperty(ref _fontStyle, value); ChangeValue(AnnotAttrib.FontStyle, value); }
+        }
+
+        private FontWeight _fontWeight;
+        public FontWeight FontWeightItem
+        {
+            get { return _fontWeight; }
+            set { SetProperty(ref _fontWeight, value); ChangeValue(AnnotAttrib.FontWeight, value); }
+        }
+
+        private ComboDataItem _fontWeightStyleItem;
+        public ComboDataItem FontWeightStyleItem
+        {
+            get { return _fontWeightStyleItem; }
+            set { SetProperty(ref _fontWeightStyleItem, value);
+                if (_fontWeightStyleItem.ValueStr != null && string.IsNullOrEmpty((string)_fontWeightStyleItem.ValueStr) == false)
+                {
+                    switch ((string)_fontWeightStyleItem.ValueStr)
+                    {
+                        case "Regular":
+                            FontStyleItem = FontStyles.Normal;
+                            FontWeightItem = FontWeights.Normal;
+                            break;
+
+                        case "Bold":
+                            FontStyleItem = FontStyles.Normal;
+                            FontWeightItem = FontWeights.Bold;
+                            break;
+
+                        case "Italic":
+                            FontStyleItem = FontStyles.Italic;
+                            FontWeightItem = FontWeights.Normal;
+                            break;
+
+                        case "Bold Italic":
+                            FontStyleItem = FontStyles.Italic;
+                            FontWeightItem = FontWeights.Bold;
+                            break;
+                    }
+
+                }
+            }
+        }
+
+        private ComboDataItem _fontSizeData = new ComboDataItem(6);
+        public ComboDataItem FontSizeData
+        {
+            get { return _fontSizeData; }
+            set { SetProperty(ref _fontSizeData, value);
+                if(_fontSizeData != null)
+                ChangeValue(AnnotAttrib.FontSize, (int)_fontSizeData.Value); }
         }
 
         //宽大小
@@ -135,7 +238,7 @@ namespace PDF_Office.ViewModels.Form
         public double WidthSize
         {
             get { return _widthSize; }
-            set { SetProperty(ref _widthSize, value); ChangeValueHandler?.Invoke(value, FormAttributeType.WidthSize); }
+            set { SetProperty(ref _widthSize, value); ChangeValue(AnnotAttrib.Width, value); }
         }
 
         //高大小
@@ -143,67 +246,131 @@ namespace PDF_Office.ViewModels.Form
         public double HeightSize
         {
             get { return _heightSize; }
-            set { SetProperty(ref _heightSize, value); ChangeValueHandler?.Invoke(value, FormAttributeType.HeightSize); }
+            set { SetProperty(ref _heightSize, value); ChangeValue(AnnotAttrib.Height, value); }
         }
 
-        //边框颜色
-        private Color _borderColor = Colors.Transparent;
-        public Color BorderColor
+
+
+        #endregion
+
+        #region 选项
+
+
+        private C_TEXT_ALIGNMENT _textAlignment;
+        public C_TEXT_ALIGNMENT TextAlignmentItem
         {
-            get { return _borderColor; }
-            set { SetProperty(ref _borderColor, value); ChangeValueHandler?.Invoke(value, FormAttributeType.BorderColor); }
+            get { return _textAlignment; }
+            set { SetProperty(ref _textAlignment, value); ChangeValue(AnnotAttrib.TextAlign, value); }
         }
 
+        private ComboDataItem _fextAlignmentData = new ComboDataItem("Left", "Left");
+        public ComboDataItem TextAlignmentData
+        {
+            get { return _fextAlignmentData; }
+            set
+            {
+                SetProperty(ref _fextAlignmentData, value);
+                if (_fextAlignmentData != null && string.IsNullOrEmpty(_fextAlignmentData.ValueStr) == false)
+                {
+                    switch(_fextAlignmentData.ValueStr)
+                    {
+                        case "Left":
+                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
+                            break;
+                        case "Center":
+                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
+                            break;
+                        case "Right":
+                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
+                            break;
+                    }
+                }
+                   
+            }
+        }
 
-        //内容颜色
-        private Color _contentColor = Colors.Transparent;
-        public Color ContentColor
+        //内容
+        private string _content;
+        public string FormContent
         {
-            get { return _contentColor; }
-            set { SetProperty(ref _contentColor, value); ChangeValueHandler?.Invoke(value, FormAttributeType.ContentColor); }
+            get { return _content; }
+            set { SetProperty(ref _content, value); ChangeValue(AnnotAttrib.Text, value); }
+        }
+        //默认值
+        private string _defaultValue;
+        public string DefaultValue
+        {
+            get { return _defaultValue; }
+            set { SetProperty(ref _defaultValue, value); }
         }
 
-        //填充颜色
-        private Color _fillColor = Colors.Transparent;
-        public Color FillColor
+        //多行
+        private bool _isMultiline = false;
+        public bool IsMultiLine
         {
-            get { return _fillColor; }
-            set { SetProperty(ref _fillColor, value); ChangeValueHandler?.Invoke(value, FormAttributeType.FillColor); }
+            get { return _isMultiline; }
+            set { SetProperty(ref _isMultiline, value); ChangeValue(AnnotAttrib.IsMutilLine, value); }
         }
 
-        #endregion
+        //滚动显示长文本
+        private bool _isScrollText = false;
+        public bool IsScrollText
+        {
+            get { return _isScrollText; }
+            set { SetProperty(ref _isScrollText, value); ChangeValue(AnnotAttrib.ScrollFlag, value); }
+        }
 
-        #region 颜色样式
+        #endregion
 
-        private ResetColor _resetColorOne = new ResetColor();
-        public ResetColor ResetColorOne
+        private void ChangeValue(AnnotAttrib annotAttrib,object obj)
         {
-            get { return _resetColorOne; }
-            set { SetProperty(ref _resetColorOne, value); }
+       
+            if(AttribEvent != null && IsCurrentWidget && AttribEvent.IsCreateForm() == false)
+            {
+                AttribEvent.UpdateAttrib(annotAttrib, obj);
+                AttribEvent.UpdateAnnot();
+            }
         }
 
-        private ResetColor _resetColorTwo = new ResetColor();
-        public ResetColor ResetColorTwo
+        #region
+
+        public ResetColor InitResetColor(Color border, Color font, Color fill)
         {
-            get { return _resetColorTwo; }
-            set { SetProperty(ref _resetColorTwo, value); }
+            return new ResetColor()
+            {
+                BorderColor = new SolidColorBrush(border),
+                FontColor = new SolidColorBrush(font),
+                FillColor = new SolidColorBrush(fill)
+            };
         }
 
-        private ResetColor _resetColorThree = new ResetColor();
-        public ResetColor ResetColorThree
+        #endregion
+    }
+
+
+    public class ResetColor : BindableBase
+    {
+        private SolidColorBrush _borderColor;
+        public SolidColorBrush BorderColor
         {
-            get { return _resetColorThree; }
-            set { SetProperty(ref _resetColorThree, value); }
+            get { return _borderColor; }
+            set { SetProperty(ref _borderColor, value); }
         }
 
-        private ResetColor _resetColorForth = new ResetColor();
-        public ResetColor ResetColorForth
+        private SolidColorBrush _fontColor;
+        public SolidColorBrush FontColor
         {
-            get { return _resetColorForth; }
-            set { SetProperty(ref _resetColorForth, value); }
+            get { return _fontColor; }
+            set { SetProperty(ref _fontColor, value); }
         }
 
-        #endregion
+
+        private SolidColorBrush _fillColor;
+        public SolidColorBrush FillColor
+        {
+            get { return _fillColor; }
+            set { SetProperty(ref _fillColor, value); }
+        }
     }
 
 }

+ 30 - 30
PDF Office/ViewModels/Form/ListBoxPropertyViewModel.cs

@@ -91,8 +91,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
         #endregion
@@ -158,47 +158,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 31 - 31
PDF Office/ViewModels/Form/RadioButtonPropertyViewModel.cs

@@ -60,8 +60,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
         #endregion
@@ -105,7 +105,7 @@ namespace PDF_Office.ViewModels.Form
             if (radioButtonArgs == null)
             {
                 radioButtonArgs = new WidgetRadioButtonArgs();
-                radioButtonArgs.FieldName = NameStr;
+                //radioButtonArgs.FieldName = NameStr;
                 radioButtonArgs.BgColor =  Colors.Transparent;
                 radioButtonArgs.FontColor = Colors.Black;
                 radioButtonArgs.LineColor = Colors.Black;
@@ -121,47 +121,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 30 - 30
PDF Office/ViewModels/Form/SignPropertyViewModel.cs

@@ -41,8 +41,8 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitCommand()
         {
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
+            //ChangeValueHandler -= ChangeValue;
+            //ChangeValueHandler += ChangeValue;
         }
 
         #endregion
@@ -98,47 +98,47 @@ namespace PDF_Office.ViewModels.Form
         }
 
         //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    break;
+        //private void ChangeValue(object sender, FormAttributeType e)
+        //{
+        //    switch (e)
+        //    {
+        //        case FormAttributeType.Name:
+        //            break;
 
-                case FormAttributeType.ToolTip:
+        //        case FormAttributeType.ToolTip:
 
-                    break;
+        //            break;
 
-                case FormAttributeType.IsSolid:
-                    break;
+        //        case FormAttributeType.IsSolid:
+        //            break;
 
-                case FormAttributeType.IsLocked:
-                    break;
+        //        case FormAttributeType.IsLocked:
+        //            break;
 
-                case FormAttributeType.HeightSize:
-                    break;
+        //        case FormAttributeType.HeightSize:
+        //            break;
 
-                case FormAttributeType.BorderThiness:
-                    break;
+        //        case FormAttributeType.BorderThiness:
+        //            break;
 
-                case FormAttributeType.BorderColor:
-                    break;
+        //        case FormAttributeType.BorderColor:
+        //            break;
 
-                case FormAttributeType.ContentColor:
-                    break;
+        //        case FormAttributeType.ContentColor:
+        //            break;
 
-                case FormAttributeType.IsReadOnly:
-                    break;
+        //        case FormAttributeType.IsReadOnly:
+        //            break;
 
-                case FormAttributeType.WidthSize:
-                    break;
+        //        case FormAttributeType.WidthSize:
+        //            break;
 
-                case FormAttributeType.IsRequiredField:
-                    break;
+        //        case FormAttributeType.IsRequiredField:
+        //            break;
 
-            }
+        //    }
 
-        }
+        //}
         #endregion
     }
 }

+ 144 - 426
PDF Office/ViewModels/Form/TextFieldPropertyViewModel.cs

@@ -23,313 +23,159 @@ namespace PDF_Office.ViewModels.Form
 {
     public class TextFieldPropertyViewModel : FormBaseVM, INavigationAware
     {
-        #region 属性
-
-        #region 一般
-        private FormFieldType _formPos;
-        public FormFieldType FormPos
-        {
-            get { return _formPos; }
-            set { SetProperty(ref _formPos, value); ChangeFieldValue("FormPos"); }
-        }
-
-        #endregion
-
-        #region 选项
-        //默认值
-        private string _defaultValue;
-        public string DefaultValue
-        {
-            get { return _defaultValue; }
-            set { SetProperty(ref _defaultValue, value); }
-        }
-
-        //多行
-        private bool _isMultiline = false;
-        public bool IsMultiLine
-        {
-            get { return _isMultiline; }
-            set { SetProperty(ref _isMultiline, value); ChangeFieldValue("IsMultiLine"); }
-        }
-
-        //滚动显示长文本
-        private bool _isScrollText = false;
-        public bool IsScrollText
-        {
-            get { return _isScrollText; }
-            set { SetProperty(ref _isScrollText, value); ChangeFieldValue("IsScrollText"); }
-        }
-
-        #endregion
-
-        private FontFamily _fontFamily;
-        public FontFamily FontFamilyItem
-        {
-            get { return _fontFamily; }
-            set { SetProperty(ref _fontFamily, value); ChangeFieldValue("FontFamilyItem"); }
-        }
-
-        private FontStyle _fontStyle;
-        public FontStyle FontStyleItem
-        {
-            get { return _fontStyle; }
-            set { SetProperty(ref _fontStyle, value); ChangeFieldValue("FontStyleItem"); }
-        }
-
-        private FontWeight _fontWeight;
-        public FontWeight FontWeightItem
-        {
-            get { return _fontWeight; }
-            set { SetProperty(ref _fontWeight, value); ChangeFieldValue("FontWeightItem"); }
-        }
-
-        private C_TEXT_ALIGNMENT _textAlignment;
-        public C_TEXT_ALIGNMENT TextAlignmentItem
-        {
-            get { return _textAlignment; }
-            set { SetProperty(ref _textAlignment, value); ChangeFieldValue("TextAlignmentItem"); }
-        }
-
-        private string _content;
-        public string FormContent
-        {
-            get { return _content; }
-            set { SetProperty(ref _content, value); ChangeFieldValue("FormContent"); }
-        }
-
-        #endregion
 
         #region Command变量
-        public DelegateCommand<string> NameTextChangedCommand { get; set; }
+        public DelegateCommand<string> FieldNameTextChangedCommand { get; set; }
         public DelegateCommand<string> ToolTipTextChangedCommand { get; set; }
 
-        public DelegateCommand<object> IsReadOnlyCheckedCommand { get; set; }
-        public DelegateCommand<object> RequiredFieldCheckedCommand { get; set; }
-
         //外观
-        public DelegateCommand<object> ThicknessChangedCommand { get; set; }
 
         public DelegateCommand<object> ResetColorCommand { get; set; }
         public DelegateCommand<object> ResetColorCheckedBtnCommand { get; set; }
-        public DelegateCommand<object> FontFamilyChangedCommand { get; set; }
-        public DelegateCommand<object> FontStyleChangedCommand { get; set; }
-
-        public DelegateCommand<object> AlignmentChangedCommand { get; set; }
+ 
         public DelegateCommand<string> FormContentTextChangedCommand { get; set; }
 
-        public DelegateCommand<object> IsMultiLineCheckedCommand { get; set; }
-        public DelegateCommand<object> IsScrollToDisplayCheckedCommand { get; set; }
         public DelegateCommand<object> LineStyleCommand { get; set; }
         #endregion
 
         #region 变量
-        public UpdateAttributeHelper AttribEvent;
         private CPDFViewer PDFViewer;
         private WidgetTextBoxArgs textBoxArgs;
-        private bool IsCurrentWidget = false;
         private IDialogService dialogs;
-        public List<ComboDataItem> Items { get; private set; }
+        public event EventHandler<int> SelectResetColorBtnHandler;
+        public List<ComboDataItem> FontFamilyItems { get; private set; }
+        public List<ComboDataItem> FontStyleItems { get; private set; }
+        public List<ComboDataItem> AglinmentItems { get; private set; }
 
         #endregion
 
         #region 初始化
         public TextFieldPropertyViewModel(IDialogService dialogService)
         {
-            dialogs = dialogService;
+            dialogs = dialogService; 
             InitVariable();
             InitCommand();
         }
 
         private void InitVariable()
         {
-            InitResetColor();
+            InitAllResetColor();
             InitFontFamilyComboBox();
+            InitFontStyleComboBox();
+            InitAglinmentItemsComboBox();
         }
 
-        private void InitResetColor()
+        private void InitAllResetColor()
         {
-            ResetColorOne = new ResetColor()
-            {
-                BorderColor = new SolidColorBrush(Colors.Transparent),
-                FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
-                FillColor = new SolidColorBrush(Colors.Transparent)
-            };
+            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorTwo = new ResetColor()
-            {
-                BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
-                FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
-                FillColor = new SolidColorBrush(Colors.Transparent)
-            };
+            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorThree = new ResetColor()
-            {
-                BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
-                FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
-                FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xBD, 0xDF, 0xFD))
-            };
-
-            ResetColorForth = new ResetColor()
-            {
-                BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
-                FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
-                FillColor = new SolidColorBrush(Colors.Transparent)
-            };
+            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
+            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
         }
+
         private void InitFontFamilyComboBox()
         {
-            Items = new List<ComboDataItem>();
+            FontFamilyItems = new List<ComboDataItem>();
             ComboDataItem item = new ComboDataItem("Courier", "Courier New");
-            Items.Add(item);
-            item = new ComboDataItem("Arial", "Helvetica");
-            Items.Add(item);
-            item = new ComboDataItem("Times New Roman", "Times New Roman");
-            Items.Add(item);
+            FontFamilyItems.Add(item);
+            item = new ComboDataItem("Helvetica", "Helvetica");
+            FontFamilyItems.Add(item);
+            item = new ComboDataItem("Times Roman", "Times New Roman");
+            FontFamilyItems.Add(item);
+        }
+
+        private void InitFontStyleComboBox()
+        {
+            FontStyleItems = new List<ComboDataItem>();
+            ComboDataItem item = new ComboDataItem("Regular", "Regular");
+            FontStyleItems.Add(item);
+            item = new ComboDataItem("Bold", "Bold");
+            FontStyleItems.Add(item);
+            item = new ComboDataItem("Italic", "Italic");
+            FontStyleItems.Add(item);
+
+            item = new ComboDataItem("Bold Italic", "Bold Italic");
+            FontStyleItems.Add(item);
+        }
+
+        private void InitAglinmentItemsComboBox()
+        {
+            AglinmentItems = new List<ComboDataItem>();
+            ComboDataItem item = new ComboDataItem("Left", "Left");
+            AglinmentItems.Add(item);
+            item = new ComboDataItem("Center", "Center");
+            AglinmentItems.Add(item);
+            item = new ComboDataItem("Right", "Right");
+            AglinmentItems.Add(item);
         }
 
         private void InitCommand()
         {
-            NameTextChangedCommand = new DelegateCommand<string>(NameTextChanged);
+            //一般
+            FieldNameTextChangedCommand = new DelegateCommand<string>(FieldNameTextChanged);
             ToolTipTextChangedCommand = new DelegateCommand<string>(ToolTipTextChanged);
-            IsReadOnlyCheckedCommand = new DelegateCommand<object>(IsReadOnlyChecked);
-            RequiredFieldCheckedCommand = new DelegateCommand<object>(RequiredFieldChecked);
             //外观
-            ThicknessChangedCommand = new DelegateCommand<object>(ThicknessChanged);
+            ResetColorCheckedBtnCommand = new DelegateCommand<object>(ResetColorCheckedBtn);
             ResetColorCommand = new DelegateCommand<object>(ResetColorEvent);
+            LineStyleCommand = new DelegateCommand<object>(LineStyleBtnEvent);
 
-            ResetColorCheckedBtnCommand = new DelegateCommand<object>(ResetColorCheckedBtn);
-            FontFamilyChangedCommand = new DelegateCommand<object>(FontFamilyChanged);
-            FontStyleChangedCommand = new DelegateCommand<object>(FontStyleChanged);
-            AlignmentChangedCommand = new DelegateCommand<object>(AlignmentChanged);
+            //选项
             FormContentTextChangedCommand = new DelegateCommand<string>(FormContentTextChanged);
 
-            IsMultiLineCheckedCommand = new DelegateCommand<object>(IsMultiLineChecked);
-            IsScrollToDisplayCheckedCommand = new DelegateCommand<object>(IsScrollToDisplayChecked);
-            LineStyleCommand = new DelegateCommand<object>(LineStyleBtnEvent);
-            ChangeValueHandler -= ChangeValue;
-            ChangeValueHandler += ChangeValue;
         }
 
-        private void LineStyleBtnEvent(object obj)
-        {
-            if (obj != null)
-            {
-                switch ((string)obj)
-                {
-                    case "Solid":
-                        BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID;
-                        break;
-                    case "Dotted":
-                        BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_DASHDED;
-                        break;
-                }
-            }
-        }
+        #endregion
 
+        #region 事件
+  
 
-        private void IsScrollToDisplayChecked(object obj)
+        private void FieldNameTextChanged(string obj)
         {
-           if(obj != null)
+            if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
             {
-                IsScrollText = (bool)obj;
-            }
-        }
+                FieldName = obj;
 
-        private void IsMultiLineChecked(object obj)
-        {
-            if (obj != null)
-            {
-                IsMultiLine = (bool)obj;
             }
         }
 
-        private void FormContentTextChanged(string obj)
+        private void ToolTipTextChanged(string obj)
         {
-            if(obj != null)
+            if (string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
             {
-                FormContent = obj;
+                ToolTipStr = obj;
             }
         }
 
-        private void AlignmentChanged(object obj)
+
+        private void LineStyleBtnEvent(object obj)
         {
             if (obj != null)
             {
-                var combo = (ComboBoxItem)obj;
-                if (combo != null)
+                switch ((string)obj)
                 {
-                    switch (combo.Content)
-                    {
-                        case "Left":
-                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
-                            break;
-
-                        case "Center":
-                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
-                            break;
-
-                        case "Right":
-                            TextAlignmentItem = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
-                            break;
-
-                    }
+                    case "Solid":
+                        BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_SOLID;
+                        break;
+                    case "Dotted":
+                        BorderStyle = ComPDFKit.PDFAnnotation.C_BORDER_STYLE.BS_DASHDED;
+                        break;
                 }
             }
         }
 
-        private void FontStyleChanged(object obj)
-        {
-           if(obj != null)
-            {
-                var combo = (ComboBoxItem)obj;
-                if(combo != null)
-                {
-                    switch(combo.Content)
-                    {
-                        case "Regular":
-                            FontStyleItem = FontStyles.Normal;
-                            FontWeightItem = FontWeights.Normal;
-                            break;
-
-                        case "Bold":
-                            FontStyleItem = FontStyles.Normal;
-                            FontWeightItem = FontWeights.Bold;
-                            break;
-
-                        case "Italic":
-                            FontStyleItem = FontStyles.Italic;
-                            FontWeightItem = FontWeights.Normal;
-                            break;
-
-                        case "Bold Italic":
-                            FontStyleItem = FontStyles.Italic;
-                            FontWeightItem = FontWeights.Bold;
-                            break;
-                    }
-                }
-            }
-        }
 
-        private void FontFamilyChanged(object obj)
+        private void FormContentTextChanged(string obj)
         {
-            if (obj != null && string.IsNullOrEmpty((string)obj) == false)
+            if (obj != null && IsCurrentWidget == true)
             {
-                switch ((string)obj)
-                {
-                    case "Courier":
-                        FontFamilyItem = new FontFamily("Courier");
-                        break;
-                    case "Helvetica":
-                        FontFamilyItem = new FontFamily("Helvetica");
-                        break;
-                    case "Times Roman":
-                        FontFamilyItem = new FontFamily("Times Roman");
-                        break;
-                }
+                FormContent = obj;
             }
         }
 
+
         private void ResetColorCheckedBtn(object obj)
         {
             if (obj != null)
@@ -367,51 +213,8 @@ namespace PDF_Office.ViewModels.Form
             }
         }
 
-        public event EventHandler<int> SelectResetColorBtnHandler;
-        private void UpdataSelectResetColorBtn()
-        {
-            int result = 0;
-            if (UpdataSelectResetColor(ResetColorOne))
-            {
-                result = 1;
-            }
-            else if (UpdataSelectResetColor(ResetColorTwo))
-            {
-                result = 2;
-            }
-            else if (UpdataSelectResetColor(ResetColorThree))
-            {
-                result = 3;
-            }
-            else if (UpdataSelectResetColor(ResetColorForth))
-            {
-                result = 4;
-            }
-
-            SelectResetColorBtnHandler?.Invoke(null, result);
-        }
-
-        private bool UpdataSelectResetColor(ResetColor reset)
-        {
-            if (reset.FillColor.Color == FillColor &&
-                reset.FontColor.Color == ContentColor &&
-                reset.BorderColor.Color == BorderColor
-                )
-            {
-                return true;
-            }
-
-            return false;
-        }
-
         private void ResetColorEvent(object obj)
         {
-            //if(obj != null && (ResetColor)obj != null)
-            // {
-            //     var resetcolor = obj as ResetColor;
-
-            // }
-
             bool result = true;
             DialogParameters value = new DialogParameters();
             value.Add(ParameterNames.PDFViewer, PDFViewer);
@@ -424,7 +227,6 @@ namespace PDF_Office.ViewModels.Form
                 EditPresetColorsDialogViewModel DialogVM = e.Parameters.GetValue<EditPresetColorsDialogViewModel>(ParameterNames.DataModel);
                 if (DialogVM != null)
                 {
-                   // CreateSignature(DialogVM);
                 }
             });
             if (!result)
@@ -433,61 +235,48 @@ namespace PDF_Office.ViewModels.Form
             }
         }
 
-        private void ThicknessChanged(object obj)
-        {
-            if(obj != null)
-            {
-                BorderThiness = (double)obj;
-            }
-        }
-
 
         #endregion
 
+        #region 外部XAML触发事件
 
-        #region 一般处理
-        private void NameTextChanged(string obj)
+        private void UpdataSelectResetColorBtn()
         {
-            if(string.IsNullOrEmpty(obj) == false && IsCurrentWidget == true)
+            int result = 0;
+            if (UpdataSelectResetColor(ResetColorOne))
             {
-                NameStr = obj;
-
+                result = 1;
             }
-        }
-
-        private void ToolTipTextChanged(string obj)
-        {
-            if (string.IsNullOrEmpty(obj) == false)
+            else if (UpdataSelectResetColor(ResetColorTwo))
             {
-                ToolTipStr = obj;
+                result = 2;
             }
-        }
-
-        private void IsReadOnlyChecked(object obj)
-        {
-            if(obj is bool)
+            else if (UpdataSelectResetColor(ResetColorThree))
             {
-                IsReadOnly = (bool)obj;
+                result = 3;
+            }
+            else if (UpdataSelectResetColor(ResetColorForth))
+            {
+                result = 4;
             }
-        }
 
+            SelectResetColorBtnHandler?.Invoke(null, result);
+        }
 
-        private void RequiredFieldChecked(object obj)
+        private bool UpdataSelectResetColor(ResetColor reset)
         {
-            if (obj is bool)
+            if (reset.FillColor.Color == FillColor &&
+                reset.FontColor.Color == ContentColor &&
+                reset.BorderColor.Color == BorderColor
+                )
             {
-                IsRequiredField = (bool)obj;
+                return true;
             }
-        }
-        #endregion
-
-        #region 外观处理
 
+            return false;
+        }
         #endregion
 
-        #region 选项处理
-
-        #endregion
 
         #region Navegation
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -507,21 +296,18 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
             navigationContext.Parameters.TryGetValue<WidgetTextBoxArgs>("WidgetArgs", out textBoxArgs);
-           
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
-        bool isCreateWidget = false;
+        
         private void GetWidgeText()
         {
-
             //新建的form表单
             if (textBoxArgs == null)
             {
                 PDFViewer.SetMouseMode(MouseModes.FormEditTool);
                 WidgetTextBoxArgs textArgs = new WidgetTextBoxArgs();
                 textArgs.BgColor = Colors.LightGray;
-                textArgs.FieldName = "TextBox";
                 textBoxArgs = textArgs;
                 PDFViewer.SetToolParam(textBoxArgs);
                 isCreateWidget = true;
@@ -530,144 +316,76 @@ namespace PDF_Office.ViewModels.Form
             {
                 PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
                 isCreateWidget = false;
+
             }
 
-            GetProperty();
+           GetProperty();
+
             IsCurrentWidget = true;
         }
+
         private void GetProperty()
         {
             if (textBoxArgs != null)
             {
-                NameStr = textBoxArgs.FieldName;
-                IsRequiredField = textBoxArgs.IsRequired;
-                IsMultiLine = textBoxArgs.IsMultiLine;
                 IsLocked = textBoxArgs.Locked;
+                FieldName = textBoxArgs.FieldName;
                 ToolTipStr = textBoxArgs.Tooltip;
+                IsReadOnly = textBoxArgs.ReadOnly;
+                IsRequiredField = textBoxArgs.IsRequired;
+
                 FillColor = textBoxArgs.BgColor;
                 ContentColor = textBoxArgs.FontColor;
                 BorderColor = textBoxArgs.LineColor;
                 BorderThiness = textBoxArgs.LineWidth;
                 BorderStyle = textBoxArgs.BorderStyle;
+
+                string fontWeightStyleStr = "";
+                if (textBoxArgs.FontStyle == FontStyles.Normal)
+                {
+                    if (textBoxArgs.FontWeight == FontWeights.Normal)
+                        fontWeightStyleStr = "Regular";
+                    else
+                        fontWeightStyleStr = "Bold";
+                }
+                else
+                {
+                    if (textBoxArgs.FontWeight == FontWeights.Normal)
+                        fontWeightStyleStr = "Italic";
+                    else
+                        fontWeightStyleStr = "Bold Italic";
+                }
+                FontWeightStyleItem = new ComboDataItem(fontWeightStyleStr);
+
+                FontFamilyData = new ComboDataItem(textBoxArgs.FontFamily);
                 //避免BorderStyle跟上一个值相同,而没触发更改IsSolid属性
                 if (BorderStyle == C_BORDER_STYLE.BS_SOLID)
                     IsSolid = true;
                 else
                     IsSolid = false;
-            }
-        }
-        //更改基类公共属性后,触发的事件
-        private void ChangeValue(object sender, FormAttributeType e)
-        {
+                FontSizeData = new ComboDataItem(textBoxArgs.FontSize);
+                if (isCreateWidget == false)
+                {
+                    HeightSize = textBoxArgs.Height;
+                    WidthSize = textBoxArgs.Width;
+                }
 
-            switch (e)
-            {
-                case FormAttributeType.Name:
-                    textBoxArgs.FieldName = NameStr;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FieldName, NameStr);
-                    break;
-
-                case FormAttributeType.ToolTip:
-                    textBoxArgs.Tooltip = ToolTipStr;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.Tooltip, ToolTipStr);
-                    break;
-
-                case FormAttributeType.IsSolid:
-                    textBoxArgs.BorderStyle = BorderStyle;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, BorderStyle);
-                    break;
-
-                case FormAttributeType.IsLocked:
-                    textBoxArgs.Locked = IsLocked;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.Locked, IsLocked);
-                    break;
-
-                case FormAttributeType.HeightSize:
-                    textBoxArgs.Height = HeightSize;
-                    //AttribEvent?.UpdateAttrib(AnnotAttrib.w, HeightSize);
-                    break;
-
-                case FormAttributeType.BorderThiness:
-                    textBoxArgs.LineWidth = BorderThiness;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.Thickness, BorderThiness);
-                    break;
-
-                case FormAttributeType.BorderColor:
-                    textBoxArgs.BgColor = BorderColor;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.Color, BorderColor);
-                    break;
-
-                case FormAttributeType.ContentColor:
-                    textBoxArgs.FontColor = ContentColor;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FontColor, ContentColor);
-                    break;
-                case FormAttributeType.FillColor:
-                    textBoxArgs.BgColor = FillColor;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FillColor, FillColor);
-                    break;
-
-                case FormAttributeType.IsReadOnly:
-                    textBoxArgs.ReadOnly = IsReadOnly;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.ReadOnly, IsReadOnly);
-                    break;
-
-                case FormAttributeType.WidthSize:
-                    textBoxArgs.Width = WidthSize;
-
-                    break;
-
-                case FormAttributeType.IsRequiredField:
-                    textBoxArgs.IsRequired = IsRequiredField;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.IsRequired, IsRequiredField);
-                    break;
-
-                case FormAttributeType.FontFamily:
-                    textBoxArgs.FontFamily = FontFamilyItem.Source;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FontFamily, FontFamilyItem.Source);
-                    break;
+                string alignmentStr = "";
 
-            }
-            AttribEvent?.UpdateAnnot();
-        }
+                if (textBoxArgs.Alignment == C_TEXT_ALIGNMENT.ALIGNMENT_LEFT)
+                    alignmentStr = "left";
+                else if (textBoxArgs.Alignment == C_TEXT_ALIGNMENT.ALIGNMENT_CENTER)
+                    alignmentStr = "Center";
+                else
+                    alignmentStr = "Right";
 
-        private void ChangeFieldValue(string tag)
-        {
-            switch (tag)
-            {
-                case "FormPos":
-                    textBoxArgs.FormField = FormField.Visible;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FormField, FormPos);
-                    break;
-                case "FontFamilyItem":
-                    textBoxArgs.FontFamily = FontFamilyItem.Source;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FontFamily, FontFamilyItem.Source);
-                    break;
-                case "FontStyleItem":
-                    textBoxArgs.FontStyle = FontStyleItem;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyleItem);
-                    break;
-                case "FontWeightItem":
-                    textBoxArgs.FontWeight = FontWeightItem;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeightItem);
-                    break;
-                case "TextAlignmentItem":
-                    textBoxArgs.Alignment = TextAlignmentItem;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignmentItem);
-                    break;
-                case "FormContent":
-                    textBoxArgs.Content = FormContent;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.Text, FormContent);
-                    break;
-                case "IsScrollText":
-                    textBoxArgs.ScrollFlag = IsScrollText;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.ScrollFlag, IsScrollText);
-                    break;
-                case "IsMultiLine":
-                    textBoxArgs.IsMultiLine = IsMultiLine;
-                    AttribEvent?.UpdateAttrib(AnnotAttrib.IsMutilLine, IsMultiLine);
-                    break;
+                TextAlignmentData = new ComboDataItem(alignmentStr, alignmentStr);
+
+                FormContent = textBoxArgs.Text;
+                IsMultiLine = textBoxArgs.IsMultiLine;
+                IsScrollText = textBoxArgs.ScrollFlag;
+               
             }
-            AttribEvent?.UpdateAnnot();
         }
 
         #endregion

+ 35 - 109
PDF Office/Views/Form/TextFieldProperty.xaml

@@ -87,10 +87,10 @@
                         Margin="0,18,0,10"
                         Style="{StaticResource PropertyHeaderLv2}"
                         Text="Name" />
-                    <cus:TextBoxEx x:Name="TbName" Height="32" CornerRadius="4" Text="{Binding NameStr,Mode=TwoWay}" >
+                    <cus:TextBoxEx x:Name="TbName" Height="32" CornerRadius="4" Text="{Binding FieldName,Mode=TwoWay}" >
                         <i:Interaction.Triggers>
                             <i:EventTrigger EventName="TextChanged">
-                                <i:InvokeCommandAction Command="{Binding NameTextChangedCommand}" CommandParameter="{Binding ElementName=TbName,Path=Text}"/>
+                                <i:InvokeCommandAction Command="{Binding FieldNameTextChangedCommand}" CommandParameter="{Binding ElementName=TbName,Path=Text}"/>
                             </i:EventTrigger>
                         </i:Interaction.Triggers>
                     </cus:TextBoxEx>
@@ -109,9 +109,9 @@
                         Margin="0,18,0,10"
                         Style="{StaticResource PropertyHeaderLv2}"
                         Text="Form Field" />
-                    <form:FormFieldCombox x:Name="formCombox" Type="{Binding FormPos,Mode=OneWay}" Height="32" Margin="0,8,0,16" />
-                    <CheckBox x:Name="ReadOnlyCheckBox" Content="Read Only" Command="{Binding IsReadOnlyCheckedCommand}" CommandParameter="{Binding ElementName=ReadOnlyCheckBox,Path=IsChecked}"/>
-                    <CheckBox x:Name="RequiredFieldCheckBox" Margin="0,8" Content="Required field"  Command="{Binding RequiredFieldCheckedCommand}" CommandParameter="{Binding ElementName=RequiredFieldCheckBox,Path=IsChecked}"/>
+                    <form:FormFieldCombox x:Name="formCombox" Type="{Binding FormField,Mode=OneWay}" Height="32" Margin="0,8,0,16" />
+                    <CheckBox x:Name="ReadOnlyCheckBox" Content="Read Only" IsChecked="{Binding IsReadOnly,Mode=TwoWay}"/>
+                    <CheckBox x:Name="RequiredFieldCheckBox" Margin="0,8" Content="Required field" IsChecked="{Binding IsRequiredField,Mode=TwoWay}" />
                 </StackPanel>
             </TabItem>
             <TabItem>
@@ -206,16 +206,8 @@
                         Margin="0,18,0,10"
                         Style="{StaticResource PropertyHeaderLv2}"
                         Text="Line" />
-
-
-                            <CompositeControl:SlidComboControl x:Name="thickness">
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="ValueChanged">
-                                        <i:InvokeCommandAction Command="{Binding ThicknessChangedCommand}" CommandParameter="{Binding ElementName=thickness,Path=Value}"/>
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
-                            </CompositeControl:SlidComboControl>
-
+                            
+                            <CompositeControl:SlidComboControl x:Name="thickness" Value="{Binding BorderThiness,Mode=TwoWay}"/>
                             <StackPanel
                 x:Name="PnlLineStyle"
                 Margin="0,20,0,0"
@@ -291,76 +283,22 @@
                                     <RowDefinition Height="auto"></RowDefinition>
                                 </Grid.RowDefinitions>
 
-                                <CompositeControl:CustomComboControl x:Name="FontFamilyBox" ItemSource="{Binding Items}" IsValueContent="True" Grid.ColumnSpan="2"  Width="228" Height="32">
-                                    <i:Interaction.Triggers>
-                                        <i:EventTrigger EventName="ValueChanged">
-                                            <i:InvokeCommandAction Command="{Binding FontFamilyChangedCommand}" CommandParameter="{Binding ElementName=FontFamilyBox,Path=ValueStr}"/>
-                                        </i:EventTrigger>
-                                    </i:Interaction.Triggers>
+                                <CompositeControl:CustomComboControl x:Name="FontFamilyBox" 
+                                                                     ItemSource="{Binding FontFamilyItems}" SelectedItems="{Binding FontFamilyData,Mode=TwoWay}"
+                                                                     IsValueContent="True" Grid.ColumnSpan="2"  Width="228" Height="32">
                                 </CompositeControl:CustomComboControl>
-                              
-  
-                                <Border Grid.Row="1" BorderBrush="#E2E3E6"  Width="148" Height="32" Margin="12,8,4,0"  BorderThickness="0">
-                                    <Grid>
-                                        <ComboBox Name="FontStyleBox" IsReadOnly="True" BorderThickness="1" BorderBrush="#FFE2E3E6" Padding="10 10 0 0" Background="Transparent">
-                                            <ComboBox.ItemContainerStyle>
-                                                <Style TargetType="{x:Type ComboBoxItem}">
-                                                    <Setter Property="Padding" Value="10 0 0 0"/>
-                                                </Style>
-                                            </ComboBox.ItemContainerStyle>
-                                            <ComboBoxItem x:Name="RegularItem" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Regular</ComboBoxItem>
-                                            <ComboBoxItem x:Name="BoldItem" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Bold</ComboBoxItem>
-                                            <ComboBoxItem x:Name="ItalicItem" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Italic</ComboBoxItem>
-                                            <ComboBoxItem x:Name="BoldItalicItem" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Bold Italic</ComboBoxItem>
 
-                                            <i:Interaction.Triggers>
-                                                <i:EventTrigger EventName="SelectionChanged">
-                                                    <i:InvokeCommandAction Command="{Binding FontStyleChangedCommand}" CommandParameter="{Binding ElementName=FontStyleBox,Path=SelectedItem}"/>
-                                                </i:EventTrigger>
-                                            </i:Interaction.Triggers>
-                                        </ComboBox>
-                                        <TextBox Name="FontStyleText" IsReadOnly="True" FontFamily="Segoe UI" FontSize="14" Background="White" Padding="10 0 0 0" Height="20" Margin="2,0,35,0" 
-                             BorderThickness="0" VerticalAlignment="Center" TextAlignment="Left">
-                                        </TextBox>
-                                    </Grid>
-                                </Border>
+                                <CompositeControl:CustomComboControl x:Name="FontStyleBox" Grid.Row="1"
+                                                                     Width="148" Height="32" Margin="12,8,4,0"
+                                                                     ItemSource="{Binding FontStyleItems}"  SelectedItems="{Binding FontWeightStyleItem,Mode=TwoWay}"
+                                                                     IsValueContent="True" Grid.Column="0">
+                                </CompositeControl:CustomComboControl>
 
-                                <Border Grid.Row="1" Grid.Column="1" BorderBrush="#E2E3E6"  Width="80" Height="32" Margin="-1,8,0,0"  BorderThickness="0">
-                                    <Grid>
-                                        <ComboBox Name="FontSizeBox" BorderThickness="1" Background="Transparent" BorderBrush="#FFE2E3E6"
-                                  MaxDropDownHeight="200">
-                                            <ComboBox.ItemContainerStyle>
-                                                <Style TargetType="{x:Type ComboBoxItem}">
-                                                    <Setter Property="Padding" Value="10 0 0 0"/>
-                                                </Style>
-                                            </ComboBox.ItemContainerStyle>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">6</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">8</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">9</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">10</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">12</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">14</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">18</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">20</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">22</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">24</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">26</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">28</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">32</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">36</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">48</ComboBoxItem>
-                                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">72</ComboBoxItem>
-                                            <i:Interaction.Triggers>
-                                                <i:EventTrigger EventName="SelectionChanged">
-                                                    <i:InvokeCommandAction Command="{Binding FontSizeChangedCommand}" CommandParameter="{Binding ElementName=FontSizeBox,Path=SelectedItem}"/>
-                                                </i:EventTrigger>
-                                            </i:Interaction.Triggers>
-                                        </ComboBox>
-                                        <TextBox Name="FontSizeText" FontFamily="Segoe UI" FontSize="14" Background="White" Height="20" Padding="10 0 0 0" Margin="2,0,35,0" 
-                             BorderThickness="0" VerticalAlignment="Center" TextAlignment="Left" IsReadOnly="True">
-                                        </TextBox>
-                                    </Grid>
-                                </Border>
+
+                                <CompositeControl:CustomComboControl x:Name="FontSizeBox" Grid.Row="1" Grid.Column="1" SelectedItems="{Binding FontSizeData,Mode=TwoWay}"
+                                                                     Width="80" Height="32" Margin="-1,8,0,0"
+                                                                     >
+                                </CompositeControl:CustomComboControl>
 
                             </Grid>
 
@@ -374,10 +312,10 @@
                         Text="大小" />
                             <StackPanel Orientation="Horizontal">
                                 <Path Data="M12.9999 8.75012V10.8285L15.8284 8.00006L12.9999 5.17163V7.25012H2.82843V5.17175L0 8.00017L2.82843 10.8286V8.75012H12.9999Z" Fill="#616469"/>
-                                <cus:NumericUpDown Height="32" Width="90"/>
+                                <cus:NumericUpDown Height="32" Width="90" Value="{Binding WidthSize,Mode=TwoWay}"/>
 
                                 <Path Data="M10.8284 2.82843H8.74999L8.74999 12.9999H10.8285L8.00005 15.8284L5.17163 12.9999H7.24999L7.24999 2.82843H5.17151L7.99994 0L10.8284 2.82843Z" Fill="#616469"/>
-                                <cus:NumericUpDown Height="32" Width="90"/>
+                                <cus:NumericUpDown Height="32" Width="90" Value="{Binding HeightSize,Mode=TwoWay}"/>
                             </StackPanel>
                         </StackPanel>
                      
@@ -397,25 +335,14 @@
                 <Grid>
                     <StackPanel IsEnabled="{Binding ElementName=ChkLock, Path=IsChecked, Converter={StaticResource InvertBoolConvert}}">
                         <TextBlock Text="Alignment"/>
-                        <ComboBox Name="AlignmentBox" BorderThickness="1" Background="Transparent" BorderBrush="#FFE2E3E6"
-                                  MaxDropDownHeight="200">
-                            <ComboBox.ItemContainerStyle>
-                                <Style TargetType="{x:Type ComboBoxItem}">
-                                    <Setter Property="Padding" Value="10 0 0 0"/>
-                                </Style>
-                            </ComboBox.ItemContainerStyle>
-                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Left</ComboBoxItem>
-                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Center</ComboBoxItem>
-                            <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">Right</ComboBoxItem>
-                            <i:Interaction.Triggers>
-                                <i:EventTrigger EventName="SelectionChanged">
-                                    <i:InvokeCommandAction Command="{Binding AlignmentChangedCommand}" CommandParameter="{Binding ElementName=AlignmentBox,Path=SelectedItem}"/>
-                                </i:EventTrigger>
-                            </i:Interaction.Triggers>
-                        </ComboBox>
-
+                        <CompositeControl:CustomComboControl x:Name="AlignmentBox" Grid.Row="1" Grid.Column="1"
+                                                                   ItemSource="{Binding AglinmentItems}" SelectedItems="{Binding TextAlignmentData,Mode=TwoWay}"
+                                                             IsValueContent="True" Height="32" Margin="-1,8,0,0"
+                                                                     >
+                        </CompositeControl:CustomComboControl>
+                        
                         <TextBlock Text="Default Value"/>
-                        <cus:TextBoxEx x:Name="DefaultValueBox" Height="150" CornerRadius="4" Text="{Binding FormContent,Mode=TwoWay}" >
+                        <cus:TextBoxEx x:Name="DefaultValueBox" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Height="150" CornerRadius="4" Text="{Binding FormContent,Mode=TwoWay}" >
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="TextChanged">
                                     <i:InvokeCommandAction Command="{Binding FormContentTextChangedCommand}" CommandParameter="{Binding ElementName=DefaultValueBox,Path=Text}"/>
@@ -423,8 +350,9 @@
                             </i:Interaction.Triggers>
                         </cus:TextBoxEx>
 
-                        <CheckBox x:Name="MultiLineCheck" Content="Nulti-line"  Command="{Binding IsMultiLineCheckedCommand}" CommandParameter="{Binding ElementName=MultiLineCheck,Path=IsChecked}"/>
-                        <CheckBox x:Name="ScrollToDisplayLongCheck" Content="Scroll to display long text"  Command="{Binding IsScrollToDisplayCheckedCommand}" CommandParameter="{Binding ElementName=ScrollToDisplayLongCheck,Path=IsChecked}"/>
+
+                        <CheckBox x:Name="MultiLineCheck" Content="Nulti-line" IsChecked="{Binding IsMultiLine,Mode=TwoWay}"/>
+                        <CheckBox x:Name="ScrollToDisplayLongCheck" Content="Scroll to display long text" IsChecked="{Binding IsScrollText,Mode=TwoWay}"/>
                     </StackPanel>
 
                     <StackPanel Visibility="Collapsed" IsEnabled="{Binding ElementName=ChkLock, Path=IsChecked, Converter={StaticResource InvertBoolConvert}}">
@@ -481,10 +409,6 @@
                 </Grid>
 
                
-
-
-
-               
             </TabItem>
 
         </TabControl>
@@ -495,7 +419,9 @@
             <CheckBox
                 Name="ChkLock"
                 Margin="16"
-                Content="Locked" />
+                Content="Locked" IsChecked="{Binding IsLocked,Mode=TwoWay}">
+            
+            </CheckBox>
         </Border>
     </Grid>
 </UserControl>