public override void CheckForErrors(BehaviorNode rootBehavior, List <ErrorCheck> result) { if (this.Method == null #if USE_NOOP || this.Method == MethodDef.Noop #endif//#if USE_NOOP ) { bool bAllowNullMethod = false; System.Reflection.PropertyInfo fi = this.GetType().GetProperty("Method"); Attribute[] attributes = (Attribute[])fi.GetCustomAttributes(typeof(DesignerMethodEnum), false); if (attributes.Length > 0) { DesignerMethodEnum designerProperty = ((DesignerMethodEnum)attributes[0]); if ((designerProperty.MethodType & MethodType.AllowNullMethod) == MethodType.AllowNullMethod) { bAllowNullMethod = true; } } if (!bAllowNullMethod) { result.Add(new Node.ErrorCheck(this, ErrorCheckLevel.Error, Resources.NoMethod)); } } else { bool isParamCompleted = true; foreach (MethodDef.Param param in this.Method.Params) { if (param.Value == null) { isParamCompleted = false; break; } } if (!isParamCompleted) { result.Add(new Node.ErrorCheck(this, ErrorCheckLevel.Error, Resources.NoParam)); } if (this.Method.NativeReturnType != "behaviac::EBTStatus") { if (EBTStatus.BT_INVALID == this.ResultOption) { if (this.ResultFunctor == null) { ErrorCheckLevel checkLevel = ms_NoResultTreatAsError ? ErrorCheckLevel.Error : ErrorCheckLevel.Warning; result.Add(new Node.ErrorCheck(this, checkLevel, Resources.NoResultFunctor)); } else if (!Plugin.IsMatchedStatusMethod(this.Method, this.ResultFunctor)) { result.Add(new Node.ErrorCheck(this, ErrorCheckLevel.Error, Resources.WrongResultFunctor)); } } } } base.CheckForErrors(rootBehavior, result); }
//private void UpdateProperties(IList<DesignerPropertyInfo> properties, List<MethodDef.Param> parameters, string parametersCategory) private void UpdateProperties(IList <DesignerPropertyInfo> properties) { //Console.WriteLine("UpdateProperties"); //this.SuspendLayout(); List <string> categories = new List <string>(); foreach (DesignerPropertyInfo property in properties) { if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) && (property.Attribute.CategoryResourceString != "CategoryVersion" || Settings.Default.ShowVersionInfo) && !categories.Contains(property.Attribute.CategoryResourceString)) { categories.Add(property.Attribute.CategoryResourceString); } } categories.Sort(); Nodes.Node node = SelectedObject as Nodes.Node; List <ParInfo> pars = new List <ParInfo>(); bool referrencedPar = false; NodeUIPolicy uiPolicy = null; if (node != null) { node.GetAllPars(ref pars); uiPolicy = NodeUIPolicy.CreateUIPolicy(node); uiPolicy.Initialize(SelectedObject); } else { Attachments.Attach attachment = SelectedObject as Behaviac.Design.Attachments.Attach; if (attachment != null) { node = attachment.Node; referrencedPar = true; attachment.GetAllPars(ref pars); uiPolicy = NodeUIPolicy.CreateUIPolicy(attachment); uiPolicy.Initialize(SelectedObject); } } if (pars.Count > 0 && !categories.Contains("CategoryPar")) { categories.Add("CategoryPar"); } foreach (string category in categories) { propertyGrid.AddCategory(Plugin.GetResourceString(category), true); foreach (DesignerPropertyInfo property in properties) { if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) && property.Attribute.CategoryResourceString == category) { Type type = property.Attribute.GetEditorType(property.Property.GetValue(_selectedObject, null)); Label label = propertyGrid.AddProperty(property.Attribute.DisplayName, type, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly)); // register description showing label.MouseEnter += new EventHandler(label_MouseEnter); // when we found an editor we connect it to the object if (type != null) { DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag; editor.SetRootNode((Nodes.Node) this._rootBehavior); editor.SetProperty(property, _selectedObject); editor.ValueWasAssigned(); editor.MouseEnter += editor_MouseEnter; editor.DescriptionWasChanged += editor_DescriptionWasChanged; editor.ValueWasChanged += editor_ValueWasChanged; if (uiPolicy != null) { uiPolicy.AddEditor(editor); } } MethodDef method = null; bool methodEditorEnable = true; DesignerMethodEnum propertyMethod = property.Attribute as DesignerMethodEnum; if (propertyMethod != null) { if (propertyMethod.MethodType != MethodType.Status) { method = property.Property.GetValue(_selectedObject, null) as MethodDef; methodEditorEnable = (propertyMethod.MethodType != MethodType.Event); } } else { DesignerRightValueEnum propertyRV = property.Attribute as DesignerRightValueEnum; if (propertyRV != null) { RightValueDef rv = property.Property.GetValue(_selectedObject, null) as RightValueDef; if (rv != null && rv.IsMethod) { method = rv.Method; } } } if (method != null) { createParamEditor(method, methodEditorEnable); } } } if (pars.Count > 0 && "CategoryPar" == category) { createParEditor(pars, referrencedPar ? typeof(DesignerParComboEnumEditor) : typeof(DesignerParEditor)); } } if (uiPolicy != null) { uiPolicy.Update(); } //this.ResumeLayout(false); }
//private void UpdateProperties(IList<DesignerPropertyInfo> properties, List<MethodDef.Param> parameters, string parametersCategory) private void UpdateProperties(IList <DesignerPropertyInfo> properties) { DefaultObject obj = SelectedObject as DefaultObject; if (obj != null) { uiPolicy = obj.CreateUIPolicy(); uiPolicy.Initialize(obj); } List <string> categories = new List <string>(); foreach (DesignerPropertyInfo property in properties) { if (uiPolicy.ShouldAddProperty(property) && !property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) && (property.Attribute.CategoryResourceString != "CategoryVersion" || Settings.Default.ShowVersionInfo) && !categories.Contains(property.Attribute.CategoryResourceString)) { categories.Add(property.Attribute.CategoryResourceString); } } categories.Sort(new CategorySorter()); foreach (string category in categories) { propertyGrid.AddCategory(Plugin.GetResourceString(category), true); foreach (DesignerPropertyInfo property in properties) { if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) && property.Attribute.CategoryResourceString == category) { if (uiPolicy != null && !uiPolicy.ShouldAddProperty(property)) { continue; } object value_ = property.Property.GetValue(_selectedObject, null); Type type = property.Attribute.GetEditorType(value_); 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)); // register description showing label.MouseEnter += new EventHandler(label_MouseEnter); // when we found an editor we connect it to the object if (type != null) { DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag; editor.SetRootNode((Nodes.Node) this._rootBehavior); editor.SetProperty(property, _selectedObject); editor.ValueWasAssigned(); editor.MouseEnter += editor_MouseEnter; editor.DescriptionWasChanged += editor_DescriptionWasChanged; editor.ValueWasChanged += editor_ValueWasChanged; if (uiPolicy != null) { uiPolicy.AddEditor(editor); } } MethodDef method = null; bool methodEditorEnable = true; if (propertyMethod != null) { if (propertyMethod.MethodType != MethodType.Status) { method = value_ as MethodDef; //methodEditorEnable = (propertyMethod.MethodType != MethodType.Event); } } else { DesignerRightValueEnum propertyRV = property.Attribute as DesignerRightValueEnum; if (propertyRV != null) { RightValueDef rv = value_ 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(method, methodEditorEnable, bReadonly); } } else { MethodDef.Param arrayIndexElement = null; if (value_ is VariableDef) { VariableDef var = value_ as VariableDef; arrayIndexElement = var.ArrayIndexElement; } else if (value_ is RightValueDef) { RightValueDef varRV = value_ as RightValueDef; if (varRV.Var != null) { arrayIndexElement = varRV.Var.ArrayIndexElement; } } if (arrayIndexElement != null) { createArrayIndexEditor(" ", arrayIndexElement); } } } } } } if (uiPolicy != null) { uiPolicy.Update(null, new DesignerPropertyInfo()); } }