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); } } }
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; }
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); } } } }
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 { 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, 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 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, 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; }