Пример #1
0
        public override void SetParameter(MethodDef.Param param, object obj)
        {
            base.SetParameter(param, obj);

            _resetProperties = false;

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

            _agentType = (behavior != null) ? behavior.AgentType : null;
            if (!string.IsNullOrEmpty(_globalType))
            {
                _agentType = Plugin.GetInstanceAgentType(_globalType);
            }

            string      selectionName = string.Empty;
            VariableDef variable      = param.Value as VariableDef;

            if (variable != null)
            {
                selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName;
            }
            else
            {
                RightValueDef variableRV = param.Value as RightValueDef;
                if (variableRV != null)
                {
                    selectionName = variableRV.DisplayName;
                }
            }

            setComboBox(selectionName);
        }
        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);
        }
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            _resetMethods = false;

            DesignerMethodEnum enumAtt = property.Attribute as DesignerMethodEnum;

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

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

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

            _agentType = (behavior != null) ? behavior.AgentType : null;

            object    action    = property.Property.GetValue(obj, null);
            MethodDef method    = action as MethodDef;
            int       typeIndex = -1;

            if (method != null)
            {
                typeIndex = getTypeIndex(method.Owner);
            }

            if (typeIndex < 0)
            {
                typeIndex = 0;
            }

            // 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;
        }
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            _resetProperties = false;

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

            string      selectionName = string.Empty;
            VariableDef variable      = param.Value as VariableDef;

            if (variable != null)
            {
                _valueOwner   = variable.ValueClass;
                selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName;
            }
            else
            {
                RightValueDef variableRV = param.Value as RightValueDef;

                if (variableRV != null)
                {
                    _valueOwner   = variableRV.ValueClassReal;
                    selectionName = variableRV.DisplayName;
                }
            }

            _agentType = (behavior != null) ? behavior.AgentType : null;
            if (_valueOwner != VariableDef.kSelf)
            {
                _agentType = Plugin.GetInstanceAgentType(_valueOwner);
            }

            setComboBox(selectionName);
        }
Пример #5
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            _resetProperties = false;

            Type enumtype = null;
            DesignerPropertyEnum enumAtt = property.Attribute as DesignerPropertyEnum;

            if (enumAtt != null)
            {
                enumtype = property.Property.PropertyType;
            }

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

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

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

            _agentType = null;
            if (behavior != null)
            {
                _agentType = behavior.AgentType;
                if (_agentType == null)
                {
                    return;
                }
            }

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

            if (variable != null && variable.ValueClass != VariableDef.kSelf)
            {
                _agentType = Plugin.GetInstanceAgentType(variable.ValueClass);
            }

            if (variableRV != null && variableRV.ValueClassReal != VariableDef.kSelf)
            {
                string gloablClass = variableRV.ValueClassReal;

                _agentType = Plugin.GetInstanceAgentType(gloablClass);
            }

            string selectionName = string.Empty;

            if (variable != null && variable.Property != null)
            {
                selectionName = variable.Property.DisplayName;
            }
            else if (variableRV != null && variableRV.Var != null && variableRV.Var.Property != null)
            {
                selectionName = variableRV.Var.Property.DisplayName;
            }

            this.FilterType = null;
            if (enumAtt != null)
            {
                if (enumAtt.DependedProperty != "")
                {
                    Type         objType    = _object.GetType();
                    PropertyInfo pi         = objType.GetProperty(enumAtt.DependedProperty);
                    object       propMember = pi.GetValue(obj, null);
                    VariableDef  var        = propMember as VariableDef;
                    if (var != null)
                    {
                        this.FilterType = var.GetValueType();
                    }
                    else
                    {
                        MethodDef method = propMember as MethodDef;
                        if (method != null)
                        {
                            this.FilterType = method.ReturnType;
                        }
                        else
                        {
                            RightValueDef varRV = propMember as RightValueDef;
                            if (varRV != null)
                            {
                                this.FilterType = varRV.ValueType;
                            }
                        }
                    }
                }
                else
                {
                    this.FilterType = enumAtt.FilterType;
                }
            }

            setComboBox(selectionName);

            //after the left is changed, the right might need to be invalidated
            if (this.comboBox.Text != selectionName)
            {
                property.Property.SetValue(_object, null, null);
            }
        }