Beispiel #1
0
 internal void BindData(string name, PropertyClonableClass value)
 {
     this._configInst      = value;
     this.Text             = name + " Editor";
     label_title.Text      = name + " Properties:";
     _originalPropertyData = _configInst.CloneProperties();
     propertyGrid_object.SelectedObject = _configInst;
 }
Beispiel #2
0
        /// <summary>
        /// Open the editor form of property
        /// </summary>
        /// <param name="propertyName">Property name</param>
        /// <param name="value">PropertyValue</param>
        /// <returns>Value after configure</returns>
        public static object EditValue(string propertyName, PropertyClonableClass value)
        {
            PropertiesEditorForm form = new PropertiesEditorForm();

            form.BindData(propertyName, value);
            form.ShowDialog();
            return(form.GetValue());
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //打开属性编辑器修改数据
            Control control            = context.Instance as Control;
            PropertyClonableClass data = context.PropertyDescriptor.GetValue(context.Instance) as PropertyClonableClass;
            // 强制变更,以将变更写入文件
            PropertyDescriptor property = TypeDescriptor.GetProperties(control)["BackColor"];

            property.SetValue(control, control.BackColor);
            return(PropertiesEditorForm.EditValue("SplitViewLayout", data));
        }
        /// <summary>
        /// Apply properties value to class instance from dictionary backup data.
        /// </summary>
        internal virtual void AppllyPropertiesData(Dictionary <string, object> propertiesData)
        {
            Type type = this.GetType();

            foreach (string propertyName in propertiesData.Keys)
            {
                PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);
                if (property.GetType().IsSubclassOf(typeof(PropertyClonableClass)))
                {
                    PropertyClonableClass value = property.GetValue(this, null) as PropertyClonableClass;
                    value.AppllyPropertiesData(propertiesData[propertyName] as Dictionary <string, object>);
                }
                else
                {
                    property.SetValue(this, propertiesData[propertyName], null);
                }
            }
        }
Beispiel #5
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //打开属性编辑器修改数据
            Control               control          = context.Instance as Control;
            PropertyDescriptor    editPropertyInfo = context.PropertyDescriptor;
            PropertyClonableClass data             = editPropertyInfo.GetValue(context.Instance) as PropertyClonableClass;

            if (null == data)
            {
                throw new InvalidCastException("Property should be the subclass of PropertyClonableClass.");
            }
            // 强制变更,以将变更写入文件
            PropertyDescriptor property = TypeDescriptor.GetProperties(control)["BackColor"];

            property.SetValue(control, control.BackColor);

            return(PropertiesEditorForm.EditValue(editPropertyInfo.Name, data));
        }