private void createArrayPropertyEditor(int itemIndex, Type editorType, bool isSelected)
        {
            Debug.Check(_arrayProperty != null);

            string propertyName = string.Format("{0}", itemIndex);
            Label  label        = propertyGrid.AddProperty(propertyName, editorType, _arrayProperty.ReadOnly);

            label.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
            label.MouseClick += new MouseEventHandler(label_MouseClick);

            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

            if (Plugin.IsCustomClassType(_arrayProperty.ItemType))
            {
                editor.SetStructProperty(new DesignerStructPropertyInfo(
                                             _arrayProperty.ItemType.Name, _arrayProperty.ItemType, _arrayProperty.ItemList[itemIndex], itemIndex),
                                         _object);
            }
            else
            {
                DesignerArrayPropertyInfo arrayProperty = new DesignerArrayPropertyInfo(_arrayProperty);
                arrayProperty.ItemIndex = itemIndex;

                editor.SetArrayProperty(arrayProperty, _object);
            }

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;

            if (isSelected)
            {
                selectLabel(label);
            }
        }
Exemple #2
0
        private DesignerPropertyEditor CreateEditor(Type type)
        {
            this.Controls.Clear();

            if (type == null)
            {
                return(null);
            }

            Type editorType = Plugin.InvokeEditorType(type);

            Debug.Check(editorType != null);

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.AutoSize = true;
            editor.Dock     = System.Windows.Forms.DockStyle.Fill;
            editor.Location = new System.Drawing.Point(0, 0);
            editor.Margin   = new System.Windows.Forms.Padding(0);
            editor.TabIndex = 1;

            this.Controls.Add(editor);

            return(editor);
        }
Exemple #3
0
        private DesignerPropertyEditor CreateEditor(string valueType, DesignerPropertyInfo prop, object obj, bool isConst, bool isFunction)
        {
            if (flowLayoutPanel.Controls.Count > 1)
            {
                flowLayoutPanel.Controls.RemoveAt(1);
            }

            Type editorType = GetEditorType(prop, obj, isConst, isFunction);

            if (editorType == null)
            {
                return(null);
            }

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.Location         = new System.Drawing.Point(74, 1);
            editor.Margin           = new System.Windows.Forms.Padding(0);
            editor.Size             = new System.Drawing.Size(flowLayoutPanel.Width - typeComboBox.Width - 5, 20);
            editor.TabIndex         = 1;
            editor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged);

            setEditor(valueType, editor, prop, obj, isConst, isFunction);

            flowLayoutPanel.Controls.Add(editor);
            return(editor);
        }
        private void createEditor(string valueType)
        {
            Type editorType = getEditorType(valueType);

            if (editorType == null)
            {
                return;
            }

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.AutoSize = true;
            editor.Dock     = System.Windows.Forms.DockStyle.Fill;
            editor.Location = new System.Drawing.Point(74, 1);
            editor.Margin   = new System.Windows.Forms.Padding(0);
            editor.Size     = new System.Drawing.Size(flowLayoutPanel.Width - this.typeComboBox.Width - 5, 20);
            editor.TabIndex = 1;

            setEditor(editor, valueType);

            if (flowLayoutPanel.Controls.Count > 1)
            {
                flowLayoutPanel.Controls.RemoveAt(1);
            }
            flowLayoutPanel.Controls.Add(editor);

            this.propertyEditor = editor;
            if (this.propertyEditor != null)
            {
                this.propertyEditor.MouseEnter            += typeComboBox_MouseEnter;
                this.propertyEditor.DescriptionWasChanged += propertyEditor_DescriptionWasChanged;
            }
        }
        private DesignerPropertyEditor createEditor(string valueType)
        {
            if (flowLayoutPanel.Controls.Count > 1)
            {
                flowLayoutPanel.Controls.RemoveAt(1);
            }

            Type editorType = getEditorType(valueType);

            if (editorType == null)
            {
                return(null);
            }

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.Location = new System.Drawing.Point(74, 1);
            editor.Margin   = new System.Windows.Forms.Padding(0);
            editor.Size     = new System.Drawing.Size(flowLayoutPanel.Width - this.typeComboBox.Width - 5, 20);
            editor.TabIndex = 1;

            setEditor(editor, valueType);

            flowLayoutPanel.Controls.Add(editor);
            return(editor);
        }
        private void label_MouseEnter(object sender, EventArgs e)
        {
            Label label = (Label)sender;
            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

            propertyGrid.ShowDescription(editor.DisplayName, editor.Description);
        }
        void createParamEditor(object owner, MethodDef method, bool enable, bool bReadonlyParent)
        {
            List <MethodDef.Param> parameters = method.Params;

            foreach (MethodDef.Param p in parameters)
            {
                Type   editorType    = typeof(DesignerParameterComboEnumEditor);
                string arugmentsName = "    " + p.DisplayName;
                bool   bReadonly     = bReadonlyParent | p.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly);
                Label  label         = propertyGrid.AddProperty(arugmentsName, editorType, bReadonly);

                label.MouseEnter += new EventHandler(label_MouseEnter);

                DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

                if (p.Type.Name == "IList")
                {
                    lastListParam = p;
                }

                if (p.Type.Name == "System_Object" && lastListParam != null)
                {
                    p.ListParam = lastListParam;
                }

                editor.Enabled = enable;
                editor.SetParameter(p, owner, bReadonly);

                editor.ValueWasAssigned();
                editor.MouseEnter      += editor_MouseEnter;
                editor.ValueWasChanged += editor_ValueWasChanged;
                //editor.ValueType = p.Attribute.ValueType;

                MethodDef.Param arrayIndexElement = null;

                if (p.Value is VariableDef)
                {
                    VariableDef var = p.Value as VariableDef;
                    arrayIndexElement = var.ArrayIndexElement;
                }
                else if (p.Value is RightValueDef)
                {
                    RightValueDef varRV = p.Value as RightValueDef;

                    if (varRV.Var != null)
                    {
                        arrayIndexElement = varRV.Var.ArrayIndexElement;
                    }
                }

                if (arrayIndexElement != null)
                {
                    createArrayIndexEditor(owner, "        ", arrayIndexElement);
                }
            }
        }
        private void setPropertyEditor(DesignerPropertyEditor editor)
        {
            this.propertyEditor = editor;

            if (this.propertyEditor != null)
            {
                this.propertyEditor.MouseEnter            += typeComboBox_MouseEnter;
                this.propertyEditor.DescriptionWasChanged += propertyEditor_DescriptionWasChanged;
            }
        }
        private void updateStructProperties(object owner)
        {
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(_structProperty.Type, DesignerProperty.SortByDisplayOrder);

            List <string> categories = new List <string>();

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!categories.Contains(property.Attribute.CategoryResourceString))
                {
                    categories.Add(property.Attribute.CategoryResourceString);
                }
            }
            categories.Sort();

            foreach (string category in categories)
            {
                if (categories.Count > 1)
                {
                    propertyGrid.AddCategory(Plugin.GetResourceString(category), true);
                }

                foreach (DesignerPropertyInfo property in properties)
                {
                    if (property.Attribute.CategoryResourceString == category)
                    {
                        object member = property.GetValue(owner);

                        Type type = property.Attribute.GetEditorType(member);

                        Label label = propertyGrid.AddProperty(property.Attribute.DisplayName, type, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly));
                        label.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
                        label.MouseEnter += new EventHandler(label_MouseEnter);

                        if (type != null)
                        {
                            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;
                            editor.SetRootNode(this._node);
                            editor.SetProperty(property, owner);
                            editor.ValueWasAssigned();
                            editor.MouseEnter      += editor_MouseEnter;
                            editor.ValueWasChanged += editor_ValueWasChanged;
                        }
                    }
                }
            }

            if (properties.Count > 0)
            {
                propertyGrid.UpdateSizes();
                propertyGrid.PropertiesVisible(true, true);
            }
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
            {
                return;
            }

            if (valueType == VariableDef.kConst)
            {
                _par.EventParam = null;
            }

            editor.SetPar(_par, _object);
            editor.ValueWasAssigned();
        }
 private void SetFilterType(DesignerPropertyEditor propertyEnumEditor, Type valueType)
 {
     if (_param.ListParam != null && _param.ListParam.Value != null)
     {
         Type itemType = MethodDef.Param.GetListParamItemType(_param);
         Debug.Check(itemType != null);
         propertyEnumEditor.FilterType = itemType;
     }
     else if (valueType != null)
     {
         propertyEnumEditor.FilterType = valueType;
     }
     else
     {
         propertyEnumEditor.FilterType = _param.Type;
     }
 }
        void createParamEditor(DesignerStructPropertyInfo structParam, Nodes.Action action)
        {
            MethodDef method = action.Method;

            if (method != null)
            {
                List <MethodDef.Param> parameters = method.GetParams(structParam);

                if (parameters != null && parameters.Count > 0)
                {
                    foreach (MethodDef.Param p in parameters)
                    {
                        Type editorType = null;

                        if (structParam.ElmentIndexInArray != -1)
                        {
                            object member = p.Value;
                            editorType = p.Attribute.GetEditorType(member);
                        }
                        else
                        {
                            editorType = typeof(DesignerParameterComboEnumEditor);
                        }

                        string arugmentsName = "    " + p.DisplayName;
                        Label  label         = propertyGrid.AddProperty(arugmentsName, editorType,
                                                                        p.Attribute != null ? p.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly) : false);
                        label.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
                        label.MouseEnter += label_MouseEnter;

                        DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;
                        editor.Enabled = true;
                        //editor.SetRootNode(this._node);
                        editor.SetParameter(p, action, false);
                        editor.MouseEnter += new EventHandler(editor_MouseEnter);
                        editor.ValueWasAssigned();
                        editor.ValueWasChanged += editor_ValueWasChanged;
                    }

                    {
                        propertyGrid.UpdateSizes();
                        propertyGrid.PropertiesVisible(true, true);
                    }
                }
            }
        }
        void createArrayIndexEditor(object owner, string preBlank, MethodDef.Param arrayIndex)
        {
            Type   editorType    = typeof(DesignerParameterComboEnumEditor);
            string arugmentsName = preBlank + "Index";
            bool   bReadonly     = false;
            Label  label         = propertyGrid.AddProperty(arugmentsName, editorType, bReadonly);

            label.MouseEnter += new EventHandler(label_MouseEnter);

            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

            editor.Enabled = true;
            editor.SetParameter(arrayIndex, owner, bReadonly);
            editor.ValueWasAssigned();
            editor.MouseEnter      += editor_MouseEnter;
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
        private DesignerPropertyEditor CreateEditor()
        {
            if (flowLayoutPanel.Controls.Count > 1)
            {
                flowLayoutPanel.Controls.RemoveAt(1);
            }

            string currentType = typeComboBox.SelectedItem.ToString();
            Type   type        = null;

            foreach (Type key in Plugin.TypeHandlers.Keys)
            {
                if (Plugin.GetNativeTypeName(key.Name) == currentType)
                {
                    type = key;
                    break;
                }
            }

            Debug.Check(type != null);
            if (type != null)
            {
                Type editorType = Plugin.InvokeEditorType(type);
                Debug.Check(editorType != null);

                if (editorType != null)
                {
                    DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);
                    editor.Location         = new System.Drawing.Point(74, 1);
                    editor.Margin           = new System.Windows.Forms.Padding(0);
                    editor.Size             = new System.Drawing.Size(flowLayoutPanel.Width - typeComboBox.Width - 5, 20);
                    editor.TabIndex         = 1;
                    editor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged);

                    flowLayoutPanel.Controls.Add(editor);

                    return(editor);
                }
            }

            return(null);
        }
        private DesignerPropertyEditor createEditor(string valueType)
        {
            if (flowLayoutPanel.Controls.Count > 1)
            {
                flowLayoutPanel.Controls.RemoveAt(1);
            }

            Type editorType = getEditorType(valueType);

            if (editorType == null)
            {
                return(null);
            }

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.Location  = new System.Drawing.Point(74, 1);
            editor.Margin    = new System.Windows.Forms.Padding(0);
            editor.Size      = new System.Drawing.Size(flowLayoutPanel.Width - this.typeComboBox.Width - 5, 20);
            editor.TabIndex  = 1;
            editor.ValueType = (this._param != null ? this._param.Attribute.ValueType : ValueTypes.All);

            if (this._param != null && this._param.IsArrayIndex)
            {
                editor.ValueType = ValueTypes.Int;
            }

            setEditor(editor, valueType);

            if (this._bIsReadonly)
            {
                editor.ReadOnly();
            }

            flowLayoutPanel.Controls.Add(editor);
            return(editor);
        }
Exemple #16
0
        private void setEditor(string valueType, DesignerPropertyEditor editor, DesignerPropertyInfo prop, object obj, bool isConst, bool isFunction)
        {
            if (editor != null)
            {
                editor.SetRootNode(this._root);

                object        propertyMember = prop.Property.GetValue(obj, null);
                VariableDef   var            = propertyMember as VariableDef;
                RightValueDef varRV          = propertyMember as RightValueDef;

                DesignerPropertyEnum   enumAtt   = prop.Attribute as DesignerPropertyEnum;
                DesignerRightValueEnum enumAttRV = prop.Attribute as DesignerRightValueEnum;

                if (isConst)
                {
                    bool bHasDepend    = false;
                    Type dependVarType = getDependedPropertyType(prop, obj);

                    if (dependVarType == null)
                    {
                        dependVarType = getPropertyType(prop, obj, VariableDef.kConst);
                    }
                    else
                    {
                        bHasDepend = true;
                    }

                    Debug.Check(dependVarType != null);

                    object defaultValue = Plugin.DefaultValue(dependVarType);
                    Debug.Check(defaultValue != null);

                    //for a const bool, to use true as the default when it is the right operand
                    if (bHasDepend && (defaultValue is bool))
                    {
                        defaultValue = true;
                    }

                    if (var == null)
                    {
                        var = new VariableDef(defaultValue);
                    }

                    if (var.Value == null || var.Value.GetType() != defaultValue.GetType())
                    {
                        var.Value = defaultValue;
                    }

                    var.ValueClass = VariableDef.kConst;

                    if (enumAttRV == null)
                    {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);

                        if (enumAtt != null)
                        {
                            editor.SetRange(enumAtt.MinValue, enumAtt.MaxValue);
                        }
                    }
                    else
                    {
                        if (varRV == null || varRV.Var == null || varRV.ValueClass != var.ValueClass || varRV.ValueType != var.ValueType)
                        {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }
                }
                else
                {
                    // VariableDef
                    if (enumAttRV == null)
                    {
                        if (var == null)
                        {
                            var = new VariableDef(null);
                            prop.Property.SetValue(obj, var, null);
                        }

                        var.ValueClass = valueType;
                    }

                    // RightValueDef
                    else
                    {
                        if (varRV == null)
                        {
                            varRV = new RightValueDef(var);
                            prop.Property.SetValue(obj, varRV, null);
                        }

                        varRV.ValueClass = valueType;
                    }

                    editor.ValueType = prop.Attribute.ValueType;
                    editor.SetProperty(prop, obj);
                }

                editor.ValueWasAssigned();
                OnValueChanged(_property);
            }
        }
Exemple #17
0
        public void AddEditor(DesignerPropertyEditor editor)
        {
            editor.ValueWasChanged += editor_ValueWasChanged;

            _allPropertyEditors.Add(editor);
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
            {
                return;
            }

            if (valueType == VariableDef.kConst)
            {
                if (_param.Value != null && (_param.Value is VariableDef || _param.Value is PropertyDef || _param.Value is ParInfo))
                {
                    if (!(_param.IsFromStruct))
                    {
                        _param.Value = Plugin.DefaultValue(_param.Type);
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;
                            _param.Value = Plugin.DefaultValue(v.GetValueType());
                        }
                        else if (_param.Value is ParInfo)
                        {
                            ParInfo v = _param.Value as ParInfo;
                            _param.Value = Plugin.DefaultValue(v.Variable.GetValueType());
                        }
                    }
                }
            }
            else
            {
                DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;

                if (_param.Value is VariableDef)
                {
                    VariableDef v = _param.Value as VariableDef;

                    if (v.ValueClass != valueType)
                    {
                        Type t1 = v.GetValueType() != null?v.GetValueType() : _param.Type;

                        object dv = Plugin.DefaultValue(t1);
                        _param.Value = new VariableDef(dv, valueType);
                    }

                    propertyEnumEditor.FilterType = (v.GetValueType() != null ? v.GetValueType() : _param.Type);
                }
                else if (_param.Value is ParInfo)
                {
                    ParInfo v = _param.Value as ParInfo;

                    if (v.Variable.ValueClass != valueType)
                    {
                        object dv = Plugin.DefaultValue(v.Variable.GetValueType());
                        _param.Value = new VariableDef(dv, valueType);
                    }

                    propertyEnumEditor.FilterType = v.Variable.GetValueType();
                }
                else
                {
                    _param.Value = new VariableDef(_param.Value, valueType);
                    propertyEnumEditor.FilterType = _param.Type;
                }
            }

            editor.SetParameter(_param, _object, false);

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
Exemple #19
0
        private void createValueEditor(Type type)
        {
            Type editorType = Plugin.InvokeEditorType(type);
            Debug.Check(editorType != null);

            ParInfo par = this._property as ParInfo;

            if (_property.Variable == null || _property.Variable.ValueType != type)
            {
                _property.Variable = new VariableDef(Plugin.DefaultValue(type));
            }

            _valueEditor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
            _valueEditor.Margin = new System.Windows.Forms.Padding(0);
            _valueEditor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            _valueEditor.Width = this.dispTextBox.Width;
            _valueEditor.Location = this.dispTextBox.Location;
            _valueEditor.Location = new Point(_valueEditor.Location.X, _valueEditor.Location.Y - _valueEditor.Height - 6);
            _valueEditor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged);

            if (par != null)
            {
                _valueEditor.SetPar(par, null);
            }
            else
            {
                _valueEditor.SetVariable(this._property.Variable, null);
            }

            _valueEditor.ValueWasAssigned();

            this.Controls.Add(_valueEditor);
            _valueEditor.BringToFront();
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
            {
                return;
            }

            Type filterTypeCandidate = null;

            if (valueType == VariableDef.kConst)
            {
                if (_param.Value != null && (_param.Value is VariableDef || _param.Value is PropertyDef || _param.Value is ParInfo))
                {
                    if (!(_param.IsFromStruct))
                    {
                        _param.Value = Plugin.DefaultValue(_param.Type);
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;
                            _param.Value = Plugin.DefaultValue(v.ValueType);
                        }
                        else if (_param.Value is ParInfo)
                        {
                            ParInfo v = _param.Value as ParInfo;
                            _param.Value = Plugin.DefaultValue(v.Variable.ValueType);
                        }
                    }
                }
            }
            else
            {
                if (_param.Value is VariableDef)
                {
                    VariableDef v = _param.Value as VariableDef;

                    filterTypeCandidate = v.ValueType;

                    if (v.ValueClass != valueType)
                    {
                        Type   t1 = v.ValueType != null ? v.ValueType : _param.Type;
                        object dv = Plugin.DefaultValue(t1);
                        _param.Value = new VariableDef(dv, valueType);
                    }
                }
                else if (_param.Value is ParInfo)
                {
                    ParInfo v = _param.Value as ParInfo;

                    filterTypeCandidate = v.Variable.ValueType;

                    if (v.Variable.ValueClass != valueType)
                    {
                        object dv = Plugin.DefaultValue(v.Variable.ValueType);
                        _param.Value = new VariableDef(dv, valueType);
                    }
                }
                else
                {
                    _param.Value        = new VariableDef(_param.Value, valueType);
                    filterTypeCandidate = _param.Type;
                }
            }

            this.SetFilterType(editor, filterTypeCandidate);
            SetupCastSettings(_object);
            editor.SetParameter(_param, _object, false);

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
                return;

            if (valueType == VariableDef.kConst)
            {
                if (_param.Value != null && (_param.Value is VariableDef || _param.Value is PropertyDef || _param.Value is ParInfo))
                {
                    if (!(_param.IsFromStruct))
                    {
                        _param.Value = Plugin.DefaultValue(_param.Type);
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;

                            _param.Value = Plugin.DefaultValue(v.GetValueType());
                        }
                        else if (_param.Value is ParInfo)
                        {
                            ParInfo v = _param.Value as ParInfo;

                            _param.Value = Plugin.DefaultValue(v.Variable.GetValueType());
                        }
                    }
                }
            }
            else if (valueType == VariableDef.kPar)
            {
                if (_param.IsFromStruct)
                {
                    if (!(_param.Value is ParInfo) && !(_param.Value is VariableDef))
                    {
                        ParInfo par = new ParInfo(this._root);

                        par.Name = _param.Attribute.DisplayName;
                        par.TypeName = _param.Type.FullName;

                        par.Variable = new VariableDef(_param.Value, VariableDef.kPar);

                        _param.Value = par;
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;
                            if (v.ValueClass != valueType)
                            {
                                Type t1 = v.GetValueType() != null ? v.GetValueType() : _param.Type;
                                object dv = Plugin.DefaultValue(t1);
                                _param.Value = new VariableDef(dv, valueType);
                            }
                        }
                    }
                }
            }
            else
            {
                if (!_param.IsFromStruct)
                {
                    if (valueType == VariableDef.kSelf)
                    {
                        DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;
                        propertyEnumEditor.GlobalType = null;
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                    else
                    {
                        DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;
                        propertyEnumEditor.GlobalType = valueType;
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                }
                else
                {
                    DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;

                    if (valueType == VariableDef.kSelf)
                    {
                        propertyEnumEditor.GlobalType = null;
                    }
                    else
                    {
                        propertyEnumEditor.GlobalType = valueType;
                    }

                    if (_param.Value is VariableDef)
                    {
                        VariableDef v = _param.Value as VariableDef;
                        if (v.ValueClass != valueType)
                        {
                            Type t1 = v.GetValueType() != null ? v.GetValueType() : _param.Type;
                            object dv = Plugin.DefaultValue(t1);
                            _param.Value = new VariableDef(dv, valueType);
                        }

                        propertyEnumEditor.FilterType = (v.GetValueType() != null ? v.GetValueType() : _param.Type);
                    }
                    else if (_param.Value is ParInfo)
                    {
                        ParInfo v = _param.Value as ParInfo;
                        if (v.Variable.ValueClass != valueType)
                        {
                            object dv = Plugin.DefaultValue(v.Variable.GetValueType());
                            _param.Value = new VariableDef(dv, valueType);
                        }

                        propertyEnumEditor.FilterType = v.Variable.GetValueType();
                    }
                    else
                    {
                        _param.Value = new VariableDef(_param.Value, valueType);
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                }
            }

            editor.SetParameter(_param, _object);

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
        private void editor_MouseEnter(object sender, EventArgs e)
        {
            DesignerPropertyEditor editor = (DesignerPropertyEditor)sender;

            propertyGrid.ShowDescription(editor.DisplayName, editor.Description);
        }
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            SetTypes();

            int typeIndex = -1;
            DesignerPropertyEditor editor = null;

            if (param.IsFromStruct)
            {
                string instance = string.Empty;
                string vt       = VariableDef.kConst;

                if (_param.Value is VariableDef)
                {
                    VariableDef v = _param.Value as VariableDef;
                    vt = v.ValueClass;

                    instance = vt;

                    if (instance != VariableDef.kSelf)
                    {
                        instance = Plugin.GetInstanceNameFromClassName(instance);
                    }
                }

                typeIndex = getComboIndex(vt, instance, "");

                editor = createEditor(vt);
            }
            else
            {
                string valueType    = "Self";
                string instance     = "Self";
                string propertyName = "";

                if (param.Value != null)
                {
                    bool bSet = ClearValueIfChanged(param);

                    if (bSet)
                    {
                        string[] tokens = param.Value.ToString().Split(' ');
                        propertyName = tokens[tokens.Length - 1];
                        instance     = Plugin.GetInstanceName(propertyName);
                        valueType    = string.Empty;

                        if (!string.IsNullOrEmpty(instance))
                        {
                            propertyName = propertyName.Substring(instance.Length + 1, propertyName.Length - instance.Length - 1);
                            valueType    = getValueType(param, instance, propertyName);
                        }
                        else
                        {
                            valueType = getValueType(param, propertyName);
                        }
                    }
                }

                typeIndex = getComboIndex(valueType, instance, propertyName);

                editor = createEditor(valueType);
            }

            if (editor != null)
            {
                setPropertyEditor(editor);
            }

            if (typeIndex > -1)
            {
                // Keep only one type for efficiency.
                this.typeComboBox.Items.Clear();
                this.typeComboBox.Items.Add(_types[typeIndex]);
                this.typeComboBox.SelectedIndex = 0;
            }
        }
        private void setEditor(string valueType, DesignerPropertyEditor editor, DesignerPropertyInfo prop, object obj, bool isConst, bool isFunction)
        {
            if (editor != null) {
                editor.SetRootNode(this._root);

                object propertyMember = prop.Property.GetValue(obj, null);
                VariableDef var = propertyMember as VariableDef;
                RightValueDef varRV = propertyMember as RightValueDef;

                DesignerPropertyEnum enumAtt = prop.Attribute as DesignerPropertyEnum;
                DesignerRightValueEnum enumAttRV = prop.Attribute as DesignerRightValueEnum;

                if (isConst) {
                    bool bHasDepend = false;
                    Type dependVarType = getDependedPropertyType(prop, obj);

                    if (dependVarType == null) {
                        dependVarType = getPropertyType(prop, obj, VariableDef.kConst);

                    } else {
                        bHasDepend = true;
                    }

                    Debug.Check(dependVarType != null);

                    object defaultValue = Plugin.DefaultValue(dependVarType);
                    Debug.Check(defaultValue != null);

                    //for a const bool, to use true as the default when it is the right operand
                    if (bHasDepend && (defaultValue is bool)) {
                        defaultValue = true;
                    }

                    if (var == null) {
                        var = new VariableDef(defaultValue);
                    }

                    if (var.Value == null || var.Value.GetType() != defaultValue.GetType())
                    { var.Value = defaultValue; }

                    var.ValueClass = VariableDef.kConst;

                    if (enumAttRV == null) {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);

                        if (enumAtt != null)
                        { editor.SetRange(enumAtt.MinValue, enumAtt.MaxValue); }

                    } else {
                        if (varRV == null || varRV.Var == null || varRV.ValueClass != var.ValueClass || varRV.ValueType != var.GetValueType()) {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }

                } else {
                    // VariableDef
                    if (enumAttRV == null) {
                        if (var == null) {
                            var = new VariableDef(null);
                            prop.Property.SetValue(obj, var, null);
                        }

                        var.ValueClass = valueType;
                    }

                    // RightValueDef
                    else {
                        if (varRV == null) {
                            varRV = new RightValueDef(var);
                            prop.Property.SetValue(obj, varRV, null);
                        }

                        varRV.ValueClass = valueType;
                    }

                    editor.ValueType = prop.Attribute.ValueType;
                    editor.SetProperty(prop, obj);
                }

                editor.ValueWasAssigned();
                OnValueChanged(_property);
                this.ValueWasAssigned();
            }
        }
Exemple #25
0
        private void resetType(Type type, bool reset)
        {
            Debug.Check(_property != null);

            if (type == null)
            {
                if (this.typeComboBox.SelectedItem != null)
                {
                    type = Plugin.GetMemberValueType(this.typeComboBox.SelectedItem.ToString());
                    Debug.Check(type != null);

                    if (_isArray)
                    {
                        type = typeof(List<>).MakeGenericType(type);
                    }
                }
            }
            else
            {
                if (_isArray)
                {
                    type = typeof(List<>).MakeGenericType(type);
                }
            }

            if (type != null)
            {
                if (reset)
                {
                    _property.Type = type;
                    _property.NativeType = Plugin.GetMemberValueTypeName(type);
                }

                if (_valueEditor != null)
                {
                    this.Controls.Remove(_valueEditor);
                    _valueEditor = null;
                }

                if ((_agent != null) && ((_property.IsPar && _property is ParInfo) || _property.IsCustomized))
                {
                    createValueEditor(type);

                    this.valueLabel.Visible = true;
                }
                else
                {
                    this.valueLabel.Visible = false;
                }
            }
        }
Exemple #26
0
        private int getRowIndex(DesignerPropertyEditor valueEditor) {
            for (int i = 0; i < _rowControls.Count; ++i) {
                if (_rowControls[i].ValueEditor == valueEditor) {
                    return i;
                }
            }

            return -1;
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
                return;

            if (valueType == VariableDef.kConst)
                _par.EventParam = null;

            editor.SetPar(_par, _object);
            editor.ValueWasAssigned();
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
                return;

            if (valueType == VariableDef.kConst)
            {
                if (_param.Value != null && (_param.Value is VariableDef || _param.Value is PropertyDef || _param.Value is ParInfo))
                {
                    if (!(_param.IsFromStruct))
                    {
                        _param.Value = Plugin.DefaultValue(_param.Type);
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;
                            _param.Value = Plugin.DefaultValue(v.GetValueType());
                        }
                        else if (_param.Value is ParInfo)
                        {
                            ParInfo v = _param.Value as ParInfo;
                            _param.Value = Plugin.DefaultValue(v.Variable.GetValueType());
                        }
                    }
                }

            }
            else
            {
                DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;

                if (_param.Value is VariableDef)
                {
                    VariableDef v = _param.Value as VariableDef;

                    if (v.ValueClass != valueType)
                    {
                        Type t1 = v.GetValueType() != null ? v.GetValueType() : _param.Type;
                        object dv = Plugin.DefaultValue(t1);
                        _param.Value = new VariableDef(dv, valueType);
                    }

                    propertyEnumEditor.FilterType = (v.GetValueType() != null ? v.GetValueType() : _param.Type);
                }
                else if (_param.Value is ParInfo)
                {
                    ParInfo v = _param.Value as ParInfo;

                    if (v.Variable.ValueClass != valueType)
                    {
                        object dv = Plugin.DefaultValue(v.Variable.GetValueType());
                        _param.Value = new VariableDef(dv, valueType);
                    }

                    propertyEnumEditor.FilterType = v.Variable.GetValueType();
                }
                else
                {
                    _param.Value = new VariableDef(_param.Value, valueType);
                    propertyEnumEditor.FilterType = _param.Type;
                }
            }

            editor.SetParameter(_param, _object, false);

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
        private void setEditor(DesignerPropertyEditor editor, DesignerPropertyInfo prop, object obj, bool isConst, bool isPar, bool isFunction)
        {
            if (editor != null)
            {
                editor.SetRootNode(this._root);

                object propertyMember = prop.Property.GetValue(obj, null);
                VariableDef var = propertyMember as VariableDef;
                RightValueDef varRV = propertyMember as RightValueDef;

                DesignerPropertyEnum enumAtt = prop.Attribute as DesignerPropertyEnum;
                DesignerRightValueEnum enumAttRV = prop.Attribute as DesignerRightValueEnum;

                if (isConst)
                {
                    Type dependVarType = getDependedPropertyType(prop, obj);
                    if (dependVarType == null)
                    {
                        dependVarType = getPropertyType(prop, obj, VariableDef.kConst);
                    }
                    Debug.Check(dependVarType != null);

                    object defaultValue = Plugin.DefaultValue(dependVarType);
                    Debug.Check(defaultValue != null);

                    if (var == null)
                    {
                        var = new VariableDef(defaultValue);
                    }

                    if (var.Value == null || var.Value.GetType() != defaultValue.GetType())
                        var.Value = defaultValue;

                    var.ValueClass = VariableDef.kConst;

                    if (enumAttRV == null)
                    {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);
                        if (enumAtt != null)
                            editor.SetRange(enumAtt.MinValue, enumAtt.MaxValue);
                    }
                    else
                    {
                        if (varRV == null || varRV.Var == null || varRV.ValueClass != var.ValueClass || varRV.ValueType != var.GetValueType())
                        {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }
                }
                else if (isPar)
                {
                    Type dependVarType = getDependedPropertyType(prop, obj);
                    //if (dependVarType == null)
                    //    dependVarType = getPropertyType(prop, obj, VariableDef.kPar);
                    if (dependVarType == null)
                        dependVarType = prop.Attribute.FilterType;

                    object defaultValue = Plugin.DefaultValue((var != null) ? var.GetValueType() : dependVarType);

                    if (varRV == null || varRV.ValueClass != VariableDef.kPar)
                    {
                        if (var == null)
                        {
                            ParInfo par = new ParInfo(obj as Nodes.Node);
                            par.Variable = new VariableDef(defaultValue);

                            var = new VariableDef(par);
                        }

                        if (var.Value == null)
                        {
                            ParInfo par = new ParInfo(obj as Nodes.Node);
                            par.Variable = new VariableDef(defaultValue);

                            var.Value = par;
                        }

                        var.ValueClass = VariableDef.kPar;
                    }

                    editor.FilterType = dependVarType;

                    if (enumAttRV == null)
                    {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);
                    }
                    else
                    {
                        if (var != null &&
                            (varRV == null || varRV.Var == null ||
                                (varRV.ValueClass != var.ValueClass || (var.GetValueType() != null && varRV.ValueType != var.GetValueType())
                                )
                            )
                           )
                        {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }
                }
                else
                {
                    // VariableDef
                    if (enumAttRV == null)
                    {
                        if (var == null)
                        {
                            var = new VariableDef(null);
                            prop.Property.SetValue(obj, var, null);
                        }

                        if (var != null && typeComboBox.SelectedIndex > -1)
                            var.ValueClass = _currentNames[typeComboBox.SelectedIndex];
                    }
                    // RightValueDef
                    else
                    {
                        if (varRV == null)
                        {
                            varRV = new RightValueDef(var);
                            prop.Property.SetValue(obj, varRV, null);
                        }

                        if (typeComboBox.SelectedIndex > -1)
                            varRV.ValueClass = _currentNames[typeComboBox.SelectedIndex];
                    }

                    editor.ValueType = prop.Attribute.ValueType;
                    editor.SetProperty(prop, obj);
                }

                editor.ValueWasAssigned();
            }
        }
        private void setEditor(DesignerPropertyEditor editor, DesignerPropertyInfo prop, object obj, bool isConst, bool isPar, bool isFunction)
        {
            if (editor != null)
            {
                editor.SetRootNode(this._root);

                object        propertyMember = prop.Property.GetValue(obj, null);
                VariableDef   var            = propertyMember as VariableDef;
                RightValueDef varRV          = propertyMember as RightValueDef;

                DesignerPropertyEnum   enumAtt   = prop.Attribute as DesignerPropertyEnum;
                DesignerRightValueEnum enumAttRV = prop.Attribute as DesignerRightValueEnum;

                if (isConst)
                {
                    Type dependVarType = getDependedPropertyType(prop, obj);
                    if (dependVarType == null)
                    {
                        dependVarType = getPropertyType(prop, obj, VariableDef.kConst);
                    }
                    Debug.Check(dependVarType != null);

                    object defaultValue = Plugin.DefaultValue(dependVarType);
                    Debug.Check(defaultValue != null);

                    if (var == null)
                    {
                        var = new VariableDef(defaultValue);
                    }

                    if (var.Value == null || var.Value.GetType() != defaultValue.GetType())
                    {
                        var.Value = defaultValue;
                    }

                    var.ValueClass = VariableDef.kConst;

                    if (enumAttRV == null)
                    {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);
                        if (enumAtt != null)
                        {
                            editor.SetRange(enumAtt.MinValue, enumAtt.MaxValue);
                        }
                    }
                    else
                    {
                        if (varRV == null || varRV.Var == null || varRV.ValueClass != var.ValueClass || varRV.ValueType != var.GetValueType())
                        {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }
                }
                else if (isPar)
                {
                    Type dependVarType = getDependedPropertyType(prop, obj);
                    //if (dependVarType == null)
                    //    dependVarType = getPropertyType(prop, obj, VariableDef.kPar);
                    if (dependVarType == null)
                    {
                        dependVarType = prop.Attribute.FilterType;
                    }

                    object defaultValue = Plugin.DefaultValue((var != null) ? var.GetValueType() : dependVarType);

                    if (varRV == null || varRV.ValueClass != VariableDef.kPar)
                    {
                        if (var == null)
                        {
                            ParInfo par = new ParInfo(obj as Nodes.Node);
                            par.Variable = new VariableDef(defaultValue);

                            var = new VariableDef(par);
                        }

                        if (var.Value == null)
                        {
                            ParInfo par = new ParInfo(obj as Nodes.Node);
                            par.Variable = new VariableDef(defaultValue);

                            var.Value = par;
                        }

                        var.ValueClass = VariableDef.kPar;
                    }

                    editor.FilterType = dependVarType;

                    if (enumAttRV == null)
                    {
                        prop.Property.SetValue(obj, var, null);
                        editor.SetVariable(var, obj);
                    }
                    else
                    {
                        if (var != null &&
                            (varRV == null || varRV.Var == null ||
                             (varRV.ValueClass != var.ValueClass || (var.GetValueType() != null && varRV.ValueType != var.GetValueType())
                             )
                            )
                            )
                        {
                            varRV = new RightValueDef(var);
                        }

                        prop.Property.SetValue(obj, varRV, null);
                        editor.SetVariable(varRV.Var, obj);
                    }
                }
                else
                {
                    // VariableDef
                    if (enumAttRV == null)
                    {
                        if (var == null)
                        {
                            var = new VariableDef(null);
                            prop.Property.SetValue(obj, var, null);
                        }

                        if (var != null && typeComboBox.SelectedIndex > -1)
                        {
                            var.ValueClass = _currentNames[typeComboBox.SelectedIndex];
                        }
                    }
                    // RightValueDef
                    else
                    {
                        if (varRV == null)
                        {
                            varRV = new RightValueDef(var);
                            prop.Property.SetValue(obj, varRV, null);
                        }

                        if (typeComboBox.SelectedIndex > -1)
                        {
                            varRV.ValueClass = _currentNames[typeComboBox.SelectedIndex];
                        }
                    }

                    editor.ValueType = prop.Attribute.ValueType;
                    editor.SetProperty(prop, obj);
                }

                editor.ValueWasAssigned();
            }
        }
 private void SetFilterType(DesignerPropertyEditor propertyEnumEditor, Type valueType)
 {
     if (_param.ListParam != null && _param.ListParam.Value != null)
     {
         Type itemType = GetListParamItemType(_param);
         Debug.Check(itemType != null);
         propertyEnumEditor.FilterType = itemType;
     }
     else if (valueType != null)
     {
         propertyEnumEditor.FilterType = valueType;
     }
     else
     {
         propertyEnumEditor.FilterType = _param.Type;
     }
 }
        private void updateStructProperties(object owner)
        {
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(_structProperty.Type, DesignerProperty.SortByDisplayOrder);

            List <string> categories = new List <string>();

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!categories.Contains(property.Attribute.CategoryResourceString))
                {
                    categories.Add(property.Attribute.CategoryResourceString);
                }
            }
            categories.Sort();

            UIObject uiObj = owner as UIObject;

            if (uiObj != null)
            {
                uiPolicy = uiObj.CreateUIPolicy();
                uiPolicy.Initialize(uiObj);
            }

            foreach (string category in categories)
            {
                if (categories.Count > 1)
                {
                    propertyGrid.AddCategory(Plugin.GetResourceString(category), true);
                }

                foreach (DesignerPropertyInfo property in properties)
                {
                    if (property.Attribute.CategoryResourceString == category)
                    {
                        if (uiPolicy != null && !uiPolicy.ShouldAddProperty(property))
                        {
                            continue;
                        }

                        object             member         = property.GetValue(owner);
                        Type               type           = property.Attribute.GetEditorType(member);
                        DesignerMethodEnum propertyMethod = property.Attribute as DesignerMethodEnum;

                        if (propertyMethod != null)
                        {
                            if ((propertyMethod.MethodType & MethodType.Task) == MethodType.Task)
                            {
                                type = typeof(DesignerMethodEnumEditor);
                            }
                        }

                        string displayName = property.Attribute.DisplayName;

                        if (uiPolicy != null)
                        {
                            displayName = uiPolicy.GetLabel(property);
                        }

                        Label label = propertyGrid.AddProperty(displayName, type, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly));
                        label.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
                        label.MouseEnter += new EventHandler(label_MouseEnter);

                        if (type != null)
                        {
                            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;
                            editor.SetRootNode(this._node);
                            editor.SetProperty(property, owner);
                            editor.ValueWasAssigned();
                            editor.MouseEnter      += editor_MouseEnter;
                            editor.ValueWasChanged += editor_ValueWasChanged;

                            if (uiPolicy != null)
                            {
                                uiPolicy.AddEditor(editor);
                            }
                        }

                        MethodDef method = null;

                        if (propertyMethod != null)
                        {
                            if (propertyMethod.MethodType != MethodType.Status)
                            {
                                method = member as MethodDef;
                            }
                        }
                        else
                        {
                            DesignerRightValueEnum propertyRV = property.Attribute as DesignerRightValueEnum;

                            if (propertyRV != null)
                            {
                                RightValueDef rv = member as RightValueDef;

                                if (rv != null && rv.IsMethod)
                                {
                                    method = rv.Method;
                                }
                            }
                        }

                        if (property.Attribute != null)
                        {
                            if (method != null)
                            {
                                if (property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplayOnProperty))
                                {
                                    //don't dipslay on the property panel
                                }
                                else
                                {
                                    bool bReadonly = property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnlyParams);

                                    createParamEditor(owner, method, true, bReadonly);
                                }
                            }
                            else
                            {
                                MethodDef.Param arrayIndexElement = null;

                                if (member is VariableDef)
                                {
                                    VariableDef var = member as VariableDef;
                                    arrayIndexElement = var.ArrayIndexElement;
                                }
                                else if (member is RightValueDef)
                                {
                                    RightValueDef varRV = member as RightValueDef;

                                    if (varRV.Var != null)
                                    {
                                        arrayIndexElement = varRV.Var.ArrayIndexElement;
                                    }
                                }

                                if (arrayIndexElement != null)
                                {
                                    createArrayIndexEditor(owner, "    ", arrayIndexElement);
                                }
                            }
                        }
                    }
                }
            }

            if (uiPolicy != null)
            {
                uiPolicy.Update(null, new DesignerPropertyInfo());
            }

            if (properties.Count > 0)
            {
                propertyGrid.UpdateSizes();
                propertyGrid.PropertiesVisible(true, true);
            }
        }
        private void setPropertyEditor(DesignerPropertyEditor editor)
        {
            this.propertyEditor = editor;

            if (this.propertyEditor != null)
            {
                this.propertyEditor.MouseEnter += typeComboBox_MouseEnter;
                this.propertyEditor.DescriptionWasChanged += propertyEditor_DescriptionWasChanged;
            }
        }
        private void setEditor(DesignerPropertyEditor editor, string valueType)
        {
            if (editor == null)
            {
                return;
            }

            if (valueType == VariableDef.kConst)
            {
                if (_param.Value != null && (_param.Value is VariableDef || _param.Value is PropertyDef || _param.Value is ParInfo))
                {
                    if (!(_param.IsFromStruct))
                    {
                        _param.Value = Plugin.DefaultValue(_param.Type);
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;

                            _param.Value = Plugin.DefaultValue(v.GetValueType());
                        }
                        else if (_param.Value is ParInfo)
                        {
                            ParInfo v = _param.Value as ParInfo;

                            _param.Value = Plugin.DefaultValue(v.Variable.GetValueType());
                        }
                    }
                }
            }
            else if (valueType == VariableDef.kPar)
            {
                if (_param.IsFromStruct)
                {
                    if (!(_param.Value is ParInfo) && !(_param.Value is VariableDef))
                    {
                        ParInfo par = new ParInfo(this._root);

                        par.Name     = _param.Attribute.DisplayName;
                        par.TypeName = _param.Type.FullName;

                        par.Variable = new VariableDef(_param.Value, VariableDef.kPar);

                        _param.Value = par;
                    }
                    else
                    {
                        if (_param.Value is VariableDef)
                        {
                            VariableDef v = _param.Value as VariableDef;
                            if (v.ValueClass != valueType)
                            {
                                Type t1 = v.GetValueType() != null?v.GetValueType() : _param.Type;

                                object dv = Plugin.DefaultValue(t1);
                                _param.Value = new VariableDef(dv, valueType);
                            }
                        }
                    }
                }
            }
            else
            {
                if (!_param.IsFromStruct)
                {
                    if (valueType == VariableDef.kSelf)
                    {
                        DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;
                        propertyEnumEditor.GlobalType = null;
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                    else
                    {
                        DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;
                        propertyEnumEditor.GlobalType = valueType;
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                }
                else
                {
                    DesignerPropertyEnumEditor propertyEnumEditor = editor as DesignerPropertyEnumEditor;

                    if (valueType == VariableDef.kSelf)
                    {
                        propertyEnumEditor.GlobalType = null;
                    }
                    else
                    {
                        propertyEnumEditor.GlobalType = valueType;
                    }

                    if (_param.Value is VariableDef)
                    {
                        VariableDef v = _param.Value as VariableDef;
                        if (v.ValueClass != valueType)
                        {
                            Type t1 = v.GetValueType() != null?v.GetValueType() : _param.Type;

                            object dv = Plugin.DefaultValue(t1);
                            _param.Value = new VariableDef(dv, valueType);
                        }

                        propertyEnumEditor.FilterType = (v.GetValueType() != null ? v.GetValueType() : _param.Type);
                    }
                    else if (_param.Value is ParInfo)
                    {
                        ParInfo v = _param.Value as ParInfo;
                        if (v.Variable.ValueClass != valueType)
                        {
                            object dv = Plugin.DefaultValue(v.Variable.GetValueType());
                            _param.Value = new VariableDef(dv, valueType);
                        }

                        propertyEnumEditor.FilterType = v.Variable.GetValueType();
                    }
                    else
                    {
                        _param.Value = new VariableDef(_param.Value, valueType);
                        propertyEnumEditor.FilterType = _param.Type;
                    }
                }
            }

            editor.SetParameter(_param, _object);

            editor.ValueWasAssigned();
            editor.ValueWasChanged += editor_ValueWasChanged;
        }