public void SetupCastSettings(object obj) { if (obj != null && obj is Behaviac.Design.Nodes.Node) { Behaviac.Design.Nodes.Node assignNode = obj as Behaviac.Design.Nodes.Node; if (assignNode != null) { bool bCasting = assignNode.IsCasting; if (bCasting) { DesignerPropertyInfo leftPropInfo = DesignerProperty.GetDesignerProperty(assignNode.GetType(), "Opl"); VariableDef opl = (VariableDef)leftPropInfo.GetValue(assignNode); Type leftType = opl.ValueType; // if number if (Plugin.IsIntergerNumberType(leftType) || Plugin.IsFloatType(leftType)) { this.ValueType = ValueTypes.Int | ValueTypes.Float; this.FilterType = null; } else if (Plugin.IsRefType(leftType)) { //ref type/pointer type this.ValueType = ValueTypes.RefType; this.FilterType = leftType; } else { // } } } } }
private string getValueType(MethodDef.Param param, string propertyName) { if (param.IsLocalVar) { Behaviac.Design.Nodes.Node node = _object as Behaviac.Design.Nodes.Node; if (node == null) { Attachments.Attachment attach = (_object as Attachments.Attachment); if (attach != null) { node = attach.Node; } } Behaviac.Design.Nodes.Behavior behavior = (node != null) ? node.Behavior as Behaviac.Design.Nodes.Behavior : null; // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { IList <PropertyDef> properties = behavior.AgentType.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kSelf); } } } // Try to find the global property with the name. string className = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(className)) { AgentType agent = Plugin.GetInstanceAgentType(className); if (agent != null) { IList <PropertyDef> properties = agent.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(className); } } } } } return(VariableDef.kConst); }
private string getValueType(string propertyName) { Behaviac.Design.Nodes.Node node = _object as Behaviac.Design.Nodes.Node; Behaviac.Design.Nodes.Behavior behavior = (node != null) ? node.Behavior as Behaviac.Design.Nodes.Behavior : null; if (behavior != null) { // Try to find the Par parameter with the name. List <ParInfo> allPars = new List <ParInfo>(); ((Nodes.Node)behavior).GetAllPars(ref allPars); if (allPars.Count > 0) { foreach (ParInfo p in allPars) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kPar); } } } } // Try to find the Agent property with the name. if (behavior != null && behavior.AgentType != null) { IList <PropertyDef> properties = behavior.AgentType.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(VariableDef.kSelf); } } } // Try to find the World property with the name. string className = Plugin.GetClassName(propertyName); if (!string.IsNullOrEmpty(className)) { AgentType agent = Plugin.GetInstanceAgentType(className); if (agent != null) { IList <PropertyDef> properties = agent.GetProperties(); foreach (PropertyDef p in properties) { if (p.Name == propertyName #if BEHAVIAC_NAMESPACE_FIX || p.Name.EndsWith(propertyName) #endif ) { return(className); } } } } return(VariableDef.kConst); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); string enumName = string.Empty; Type enumtype = null; DesignerEnum enumAtt = property.Attribute as DesignerEnum; if (enumAtt != null) { enumName = DesignerEnum.GetDisplayName(property.Property.GetValue(obj, null)); enumtype = property.Property.PropertyType; } if (enumtype == null) { throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name)); } clear(); Behaviac.Design.Nodes.Node node = obj as Behaviac.Design.Nodes.Node; Behaviac.Design.Attachments.Attach evt = obj as Behaviac.Design.Attachments.Attach; object[] excludedElements = null; if (node != null) { excludedElements = node.GetExcludedEnums(enumAtt); } else if (evt != null) { excludedElements = evt.GetExcludedEnums(enumAtt); } Array list = Enum.GetValues(enumtype); foreach (object enumVal in list) { bool excluded = false; if (excludedElements != null) { for (int i = 0; i < excludedElements.Length; ++i) { if (excludedElements[i].Equals(enumVal)) { excluded = true; break; } } } if (!excluded) { _allValues.Add(enumVal); if (DesignerEnum.GetDisplayName(enumVal) == enumName) { _values.Add(enumVal); comboBox.Items.Add(enumName); } } } comboBox.Text = enumName; }