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); } }
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(); } }
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(); } }