private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_valueWasAssigned || comboBox.SelectedIndex < 0 || comboBox.SelectedIndex >= _methods.Count)
            {
                return;
            }

            DesignerRightValueEnum propertRV = _property.Attribute as DesignerRightValueEnum;
            MethodDef m_ = _methods[comboBox.SelectedIndex] as MethodDef;
            MethodDef m  = new MethodDef(m_);

            m.Owner = VariableDef.kSelf;

            if (propertRV == null)
            {
                _property.Property.SetValue(_object, m, null);
            }
            else
            {
                object propertyMember = _property.Property.GetValue(_object, null);

                if (propertyMember != null)
                {
                    RightValueDef oldvarRV = propertyMember as RightValueDef;
                    RightValueDef varRV    = new RightValueDef(m, oldvarRV.ValueClass);
                    _property.Property.SetValue(_object, varRV, null);
                }
            }

            this.RereshProperty(true, _property);

            OnValueChanged(_property);
        }
        private List <MethodDef> getMethods()
        {
            List <MethodDef> methods = new List <MethodDef>();

            Behaviac.Design.Attachments.Attach evt      = _object as Behaviac.Design.Attachments.Attach;
            Behaviac.Design.Nodes.BaseNode     baseNode = (evt != null) ? evt.Node : _object as Behaviac.Design.Nodes.BaseNode;

            if (baseNode == null)
            {
                baseNode = this._root;
            }

            Behaviac.Design.Nodes.Behavior behavior = null;

            if (baseNode != null)
            {
                behavior = baseNode.Behavior as Behaviac.Design.Nodes.Behavior;
            }

            AgentType agentType = null;

            if (behavior != null && behavior.AgentType != null)
            {
                agentType = behavior.AgentType;
            }

            object        action = _property.Property.GetValue(_object, null);
            RightValueDef varRV  = action as RightValueDef;

            if (varRV != null && Plugin.IsInstanceName(varRV.ValueClassReal))
            {
                agentType = Plugin.GetInstanceAgentType(varRV.ValueClassReal);
            }

            if (agentType != null)
            {
                DesignerRightValueEnum enumAttRV  = _property.Attribute as DesignerRightValueEnum;
                DesignerMethodEnum     attrMethod = _property.Attribute as DesignerMethodEnum;
                MethodType             methodType = attrMethod != null ? attrMethod.MethodType : MethodType.Getter;

                if (enumAttRV != null)
                {
                    methodType = enumAttRV.MethodType;
                }

                IList <MethodDef> actions = agentType.GetMethods(methodType);
                foreach (MethodDef actionType in actions)
                {
                    if (Plugin.IsCompatibleType(this.FilterType, actionType.ReturnType, false))
                    {
                        methods.Add(actionType);
                    }
                }
            }

            return(methods);
        }
        private List <MethodDef> getMethods()
        {
            List <MethodDef> methods = new List <MethodDef>();

            if (typeComboBox.SelectedIndex > -1)
            {
                Nodes.Behavior behavior  = GetBehavior();
                AgentType      agentType = Plugin.GetInstanceAgentType(_currentNames[typeComboBox.SelectedIndex], behavior, _agentType);

                if (agentType != null)
                {
                    // get the linked method to filter
                    MethodDef            linkedMethod = null;
                    bool                 linkBroken;
                    DesignerPropertyInfo linkedProp = _property.Attribute.GetLinkedProperty(_object, out linkBroken);
                    object               prop       = linkedProp.GetValue(_object);

                    if (prop != null && prop is MethodDef)
                    {
                        linkedMethod = prop as MethodDef;
                    }

                    DesignerMethodEnum attrMethod = _property.Attribute as DesignerMethodEnum;
#if USE_NOOP
                    IList <MethodDef> methods = new List <MethodDef>();
                    methods.Add(MethodDef.Noop);

                    IList <MethodDef> agentMethods = agentType.GetMethods(attrMethod.MethodType, ValueTypes.All, linkedMethod);

                    foreach (MethodDef m in agentMethods)
                    {
                        methods.Add(m);
                    }
#else
                    if (attrMethod != null)
                    {
                        methods.AddRange(agentType.GetMethods(attrMethod.MethodType, attrMethod.MethodReturnType, linkedMethod));
                    }
                    else
                    {
                        DesignerRightValueEnum attrMethodRV = _property.Attribute as DesignerRightValueEnum;

                        if (attrMethodRV != null)
                        {
                            methods.AddRange(agentType.GetMethods(attrMethodRV.MethodType, ValueTypes.All, linkedMethod));
                        }
                    }
#endif//#if USE_NOOP
                }
            }

            return(methods);
        }
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            _resetMethods = false;

            DesignerRightValueEnum enumAttRV = _property.Attribute as DesignerRightValueEnum;

            this.FilterType = null;

            if (enumAttRV != null && enumAttRV.DependedProperty != "")
            {
                Type         objType    = _object.GetType();
                PropertyInfo pi         = objType.GetProperty(enumAttRV.DependedProperty);
                object       propMember = pi.GetValue(_object, null);
                VariableDef  var        = propMember as VariableDef;

                if (var != null)
                {
                    this.FilterType = var.ValueType;
                }
                else
                {
                    MethodDef method = propMember as MethodDef;

                    if (method != null)
                    {
                        this.FilterType = method.ReturnType;
                    }
                    else
                    {
                        RightValueDef varRVp = propMember as RightValueDef;

                        if (varRVp != null)
                        {
                            this.FilterType = varRVp.ValueType;
                        }
                    }
                }
            }
            else
            {
                this.FilterType = _property.Attribute.FilterType;
            }

            SetupCastSettings(obj);

            setComboBox();
        }
        private List <MethodDef> getMethods()
        {
            List <MethodDef> methods = new List <MethodDef>();

            Nodes.Behavior behavior  = GetBehavior();
            AgentType      agentType = (behavior != null) ? behavior.AgentType : null;

            object      action = _property.Property.GetValue(_object, null);
            VariableDef var    = action as VariableDef;

            Debug.Check(var == null);

            RightValueDef varRV = action as RightValueDef;

            if (varRV != null && Plugin.IsInstanceName(varRV.ValueClassReal, behavior))
            {
                agentType = Plugin.GetInstanceAgentType(varRV.ValueClassReal, behavior, agentType);
            }

            if (agentType != null)
            {
                DesignerRightValueEnum enumAttRV  = _property.Attribute as DesignerRightValueEnum;
                DesignerMethodEnum     attrMethod = _property.Attribute as DesignerMethodEnum;
                MethodType             methodType = attrMethod != null ? attrMethod.MethodType : MethodType.Getter;

                if (enumAttRV != null)
                {
                    methodType = enumAttRV.MethodType;
                }

                IList <MethodDef> actions = agentType.GetMethods(true, methodType);

                foreach (MethodDef actionType in actions)
                {
                    if (Plugin.IsCompatibleType(this.ValueType, this.FilterType, actionType.ReturnType, false))
                    {
                        methods.Add(actionType);
                    }
                }
            }

            return(methods);
        }
Example #6
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            _isReady = false;

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

            _methodOnly = true;

            _names.Clear();
            _types.Clear();

            int defaultSelect = 0;

            if (enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.Const))
            {
                _methodOnly = false;
                _allowConst = true;

                _names.Add(VariableDef.kConst);
                _types.Add(VariableDef.kConst);
            }
            else
            {
                _allowConst = false;
            }

            if (enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.Self))
            {
                _methodOnly = false;

                _names.Add(VariableDef.kSelf);
                _types.Add(VariableDef.kSelf);
                defaultSelect = _types.Count - 1;
            }

            List <Plugin.InstanceName_t> instanceNames = this.InstanceNames;

            if (enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.Instance))
            {
                _methodOnly = false;

                foreach (Plugin.InstanceName_t instanceName in instanceNames)
                {
                    _names.Add(instanceName.name_);
                    _types.Add(instanceName.displayName_);
                }
            }

            if (enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.SelfMethod))
            {
                _names.Add(VariableDef.kSelfMethod);
                _types.Add(VariableDef.kSelfMethod);

                if (enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.Instance))
                {
                    foreach (Plugin.InstanceName_t instanceName in instanceNames)
                    {
                        _names.Add(instanceName.name_ + VariableDef.kMethod);
                        _types.Add(instanceName.displayName_ + VariableDef.kMethod);
                    }
                }
            }

            typeComboBox.Enabled = (_types.Count > 1);

            if (property.Property.PropertyType == null)
            {
                throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name));
            }

            object        propertyMember = property.Property.GetValue(obj, null);
            VariableDef   variable       = propertyMember as VariableDef;
            RightValueDef variableRV     = propertyMember as RightValueDef;

            //right value's default should be const
            if (enumAtt != null && enumAtt.DependedProperty != null && enumAtt.HasStyles(DesignerPropertyEnum.AllowStyles.Const))
            {
                defaultSelect = 0;
            }

            int typeIndex = -1;

            if (variableRV == null)
            {
                if (variable != null)
                {
                    typeIndex = getComboIndex(variable.ValueClass);
                }
                else
                {
                    typeIndex = defaultSelect;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(variableRV.ValueClass))
                {
                    typeIndex = getComboIndex(variableRV.ValueClass);
                }
                else
                {
                    typeIndex = 0;
                }
            }

            if (_types.Count > 0 && typeIndex > -1)
            {
                // Keep only one type for efficiency.
                _currentNames.Clear();
                _currentNames.Add(_names[typeIndex]);

                this.typeComboBox.Items.Clear();
                this.typeComboBox.Items.Add(_types[typeIndex]);
                this.typeComboBox.SelectedIndex = 0;
            }

            _isReady = true;

            string selectedText = ((string)typeComboBox.SelectedItem);

            setPropertyEditor(CreateEditor(selectedText, _property, _object,
                                           _allowConst && selectedText == VariableDef.kConst,
                                           variableRV != null ? variableRV.IsMethod : false));

            this.ValueWasAssigned();
        }
Example #7
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);
            }
        }
Example #8
0
        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 setValueComboBox()
        {
            if (_methods.Count == 0)
            {
                return;
            }

            if (string.IsNullOrEmpty(valueComboBox.Text))
            {
                foreach (MethodDef md in _methods)
                {
                    if (!valueComboBox.Items.Contains(md.DisplayName))
                    {
                        valueComboBox.Items.Add(md.DisplayName);
                    }
                }
            }
            else
            {
                int index = -1;

                for (int i = 0; i < _methods.Count; ++i)
                {
                    if (valueComboBox.Text == _methods[i].DisplayName)
                    {
                        index = i;
                        break;
                    }
                }

                if (index > -1)
                {
                    for (int i = index - 1; i >= 0; --i)
                    {
                        if (!valueComboBox.Items.Contains(_methods[i].DisplayName))
                        {
                            valueComboBox.Items.Insert(0, _methods[i].DisplayName);
                        }
                    }

                    for (int i = index + 1; i < _methods.Count; ++i)
                    {
                        if (!valueComboBox.Items.Contains(_methods[i].DisplayName))
                        {
                            valueComboBox.Items.Add(_methods[i].DisplayName);
                        }
                    }
                }
            }

            object             action     = _property.Property.GetValue(_object, null);
            DesignerMethodEnum attrMethod = _property.Attribute as DesignerMethodEnum;

            if (attrMethod != null)
            {
                MethodDef method = action as MethodDef;

                if (method != null && this.valueComboBox.Text != method.DisplayName)
                {
                    this.valueComboBox.Text = method.DisplayName;
                }
            }
            else
            {
                DesignerRightValueEnum attrMethodRV = _property.Attribute as DesignerRightValueEnum;

                if (attrMethodRV != null)
                {
                    RightValueDef method = action as RightValueDef;

                    if (method != null && this.valueComboBox.Text != method.Method.DisplayName)
                    {
                        Debug.Check(method.IsMethod);
                        this.valueComboBox.Text = method.Method.DisplayName;
                    }
                }
            }
        }
Example #10
0
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_valueWasAssigned || comboBox.SelectedIndex < 0 || comboBox.SelectedIndex >= _properties.Count)
            {
                return;
            }

            PropertyDef selectedProperty = _properties[comboBox.SelectedIndex];

            selectedProperty       = selectedProperty.Clone();
            selectedProperty.Owner = _valueOwner;

            bool isArrayElement = selectedProperty.IsArrayElement;
            bool bForceFresh    = false;

            if (_property.Property != null)
            {
                object                 propertyMember = _property.Property.GetValue(_object, null);
                VariableDef            var            = propertyMember as VariableDef;
                DesignerRightValueEnum rvPropertyEnum = _property.Attribute as DesignerRightValueEnum;

                if (rvPropertyEnum == null)
                {
                    if (var == null)
                    {
                        var = new VariableDef(selectedProperty, VariableDef.kSelf);
                    }

                    else
                    {
                        var.SetProperty(selectedProperty, var.ValueClass);
                    }

                    if (isArrayElement && var.ArrayIndexElement == null)
                    {
                        var.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                        var.ArrayIndexElement.IsArrayIndex = true;
                        bForceFresh = true;
                    }
                    else if (!isArrayElement && var.ArrayIndexElement != null)
                    {
                        var.ArrayIndexElement = null;
                        bForceFresh           = true;
                    }

                    _property.Property.SetValue(_object, var, null);
                }
                else if (propertyMember != null)
                {
                    RightValueDef varRV = propertyMember as RightValueDef;

                    if (varRV == null)
                    {
                        Debug.Check(false);
                        //varRV = new RightValueDef(selectedProperty, VariableDef.kSelf);
                    }
                    else
                    {
                        if (varRV.IsMethod)
                        {
                            Debug.Check(false);
                        }
                        else
                        {
                            if (varRV.Var != null)
                            {
                                varRV.Var.SetProperty(selectedProperty, varRV.ValueClassReal);
                            }
                            else
                            {
                                var   = new VariableDef(selectedProperty, varRV.ValueClassReal);
                                varRV = new RightValueDef(var);
                            }
                        }
                    }

                    if (varRV != null && varRV.Var != null)
                    {
                        if (isArrayElement && varRV.Var.ArrayIndexElement == null)
                        {
                            varRV.Var.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                            varRV.Var.ArrayIndexElement.IsArrayIndex = true;

                            bForceFresh = true;
                        }
                        else if (!isArrayElement && varRV.Var.ArrayIndexElement != null)
                        {
                            varRV.Var.ArrayIndexElement = null;
                            bForceFresh = true;
                        }
                    }

                    _property.Property.SetValue(_object, varRV, null);
                }
            }
            else if (_param != null)
            {
                string valueType       = _valueOwner;
                bool   bOldArrayElment = false;

                if (_param.Value != null && _param.Value is VariableDef)
                {
                    VariableDef paramV = _param.Value as VariableDef;

                    if (paramV.ArrayIndexElement != null)
                    {
                        bOldArrayElment = true;
                    }
                }

                VariableDef paramValue = new VariableDef(selectedProperty, valueType);
                _param.Value = paramValue;

                if (isArrayElement && paramValue.ArrayIndexElement == null)
                {
                    paramValue.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                    paramValue.ArrayIndexElement.IsArrayIndex = true;

                    bForceFresh = true;
                }
                else if (!isArrayElement && bOldArrayElment)
                {
                    paramValue.ArrayIndexElement = null;
                    bForceFresh = true;
                }
            }

            this.RereshProperty(bForceFresh, _property);

            OnValueChanged(_property);
        }
Example #11
0
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_valueWasAssigned || comboBox.SelectedIndex < 0 || comboBox.SelectedIndex >= _properties.Count)
            {
                return;
            }

            PropertyDef selectedProperty = _properties[comboBox.SelectedIndex];

            selectedProperty       = new PropertyDef(selectedProperty);
            selectedProperty.Owner = !string.IsNullOrEmpty(_globalType) ? _globalType : VariableDef.kSelf;

            if (_property.Property != null)
            {
                object                 propertyMember = _property.Property.GetValue(_object, null);
                VariableDef            var            = propertyMember as VariableDef;
                DesignerRightValueEnum rvPropertyEnum = _property.Attribute as DesignerRightValueEnum;
                if (rvPropertyEnum == null)
                {
                    if (var == null)
                    {
                        var = new VariableDef(selectedProperty, VariableDef.kSelf);
                    }
                    else
                    {
                        var.SetProperty(selectedProperty, var.ValueClass);
                    }

                    _property.Property.SetValue(_object, var, null);
                }
                else if (propertyMember != null)
                {
                    RightValueDef varRV = propertyMember as RightValueDef;

                    if (varRV == null)
                    {
                        Debug.Check(false);
                        //varRV = new RightValueDef(selectedProperty, VariableDef.kSelf);
                    }
                    else
                    {
                        if (varRV.IsMethod)
                        {
                            Debug.Check(false);
                        }
                        else
                        {
                            if (varRV.Var != null)
                            {
                                varRV.Var.SetProperty(selectedProperty, varRV.ValueClassReal);
                            }
                            else
                            {
                                var   = new VariableDef(selectedProperty, varRV.ValueClassReal);
                                varRV = new RightValueDef(var);
                            }
                        }
                    }

                    _property.Property.SetValue(_object, varRV, null);
                }
            }
            else if (_param != null)
            {
                string valueType = !string.IsNullOrEmpty(_globalType) ? _globalType : VariableDef.kSelf;
                _param.Value = new VariableDef(selectedProperty, valueType);
            }

            OnValueChanged(_property);

            this.RereshProperty(false, _property);
        }
        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();
            }
        }