public override void Update(object sender, DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyEditor oplEditor = GetEditor(_obj, "Opl"); Debug.Check(oplEditor != null); if (oplEditor == sender) { VariableDef opl = (VariableDef)GetProperty(_obj, "Opl"); if (opl != null) { RightValueDef opr = (RightValueDef)GetProperty(_obj, "Opr"); if (opr != null && opl.ValueType != opr.ValueType) { DesignerPropertyEditor oprEditor = GetEditor(_obj, "Opr"); Debug.Check(oprEditor != null); oprEditor.Clear(); } } } } }
public override bool ShouldUpdatePropertyGrids(DesignerPropertyInfo property) { DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl"); DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator"); return(property.Property == oplProp.Property || property.Property == operatorProp.Property); }
public override void Update(object sender, DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyEditor statusPhaseEditor = GetEditor(_obj, "TransitionPhase"); Debug.Check(statusPhaseEditor != null); PluginBehaviac.Events.AlwaysTransition at = this._obj as PluginBehaviac.Events.AlwaysTransition; if (at.Node is PluginBehaviac.Nodes.FSMReferencedBehavior) { // } else { if (statusPhaseEditor != null) { statusPhaseEditor.Enabled = false; } //ResultOption is set to be SUCCESS by default SetProperty(_obj, "TransitionPhase", PluginBehaviac.Events.ETransitionPhase.ETP_Always); } } }
public override void OnPropertyValueChanged(DesignerPropertyInfo property) { if (property.Property.Name == "Prototype") { List <ParInfo> pars = ((Behavior)(this.Behavior)).LocalVars; bool bLoop = true; //remove old added local variables while (bLoop) { int index = pars.FindIndex((p) => p.Name.IndexOf(LOCAL_TASK_PARAM_PRE) != -1); if (index != -1) { pars.RemoveAt(index); } else { bLoop = false; } } CollectTaskPars(ref pars); this.Behavior.AgentType.ResetPars(pars); if (Plugin.UpdateMetaStoreHandler != null) { Plugin.UpdateMetaStoreHandler(null); } } }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { if (string.IsNullOrEmpty(_agentFullname)) { return; } int index = getRowIndex(sender as DesignerPropertyEditor); if (index > -1) { RowControl row = _rowControls[index]; VariableDef var = row.ValueEditor.GetVariable(); if (var != null && var.Value != null) { string value = var.Value.ToString(); if (!string.IsNullOrEmpty(value)) { string valueType = row.TypeLabel.Text; string valueName = row.NameLabel.Text; if (AgentDataPool.CurrentFrame > -1) { AgentDataPool.AddValue(_agentFullname, valueName, AgentDataPool.CurrentFrame, value); } NetworkManager.Instance.SendProperty(_agentFullname, valueType, valueName, value); } } } }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { Debug.Check(_parTemp != null); DesignerPropertyEditor editor = sender as DesignerPropertyEditor; _parTemp.Variable = editor.GetVariable(); }
/// <summary> /// Initialises a property on a given node. /// </summary> /// <param name="xml">The XML element containing the attribute we want to get.</param> /// <param name="node">The node whose property we want to set.</param> /// <param name="property">The property on the node we want to set.</param> protected void InitProperty(XmlNode xml, Node node, DesignerPropertyInfo property) { string value; if (GetAttribute(xml, property.Property.Name, out value)) { property.SetValueFromString(node, value); } }
/// <summary> /// Initialises a property on a given attachment. /// </summary> /// <param name="xml">The XML element containing the attribute we want to get.</param> /// <param name="node">The attachment whose property we want to set.</param> /// <param name="property">The property on the attachment we want to set.</param> protected void InitProperty(XmlNode xml, Attachments.Attachment attach, DesignerPropertyInfo property) { string value; if (GetAttribute(xml, property.Property.Name, out value)) { property.SetValueFromString(attach, value); } }
protected object GetProperty(object obj, string propertyName) { if (obj != null) { DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName); return(propInfo.GetValue(obj)); } return(null); }
public override void Update(object sender, DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyEditor statusEditor = GetEditor(_obj, "EndStatus"); if (statusEditor != null) { statusEditor.FilterType = typeof(XMLPluginBehaviac.behaviac_EBTStatus); } } }
public override void Update(object sender, DesignerPropertyInfo property) { if (_obj != null) { BaseNode p = _obj as BaseNode; if (p != null) { bool bHTN = false; while (p != null) { if (p.Parent != null && p.Parent.ToString() == "Branch") { bHTN = true; break; } p = p.Parent; } //hide policy configs if for HTN { DesignerPropertyEditor FailurePolicyEditor = GetEditor(_obj, "FailurePolicy"); Debug.Check(FailurePolicyEditor != null); if (FailurePolicyEditor != null) { FailurePolicyEditor.Visible = !bHTN; } DesignerPropertyEditor SuccessPolicyEditor = GetEditor(_obj, "SuccessPolicy"); Debug.Check(SuccessPolicyEditor != null); if (SuccessPolicyEditor != null) { SuccessPolicyEditor.Visible = !bHTN; } DesignerPropertyEditor ExitPolicyEditor = GetEditor(_obj, "ExitPolicy"); Debug.Check(ExitPolicyEditor != null); if (ExitPolicyEditor != null) { ExitPolicyEditor.Visible = !bHTN; } DesignerPropertyEditor ChildFinishPolicyEditor = GetEditor(_obj, "ChildFinishPolicy"); Debug.Check(ChildFinishPolicyEditor != null); if (ChildFinishPolicyEditor != null) { ChildFinishPolicyEditor.Visible = !bHTN; } } } } }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { if (_initialized) { DesignerPropertyEditor editor = sender as DesignerPropertyEditor; _property.Variable = editor.GetVariable(); this.IsModified = true; } }
/// <summary> /// WriteProperty /// </summary> /// <param name="file"></param> /// <param name="p"></param> /// <param name="o"></param> static private void WriteProperty(JArray file, DesignerPropertyInfo p, object o) { //WritePropertyValue(file, property, o); string name = p.Property.Name; string str = p.GetExportValue(o); file.Add(new JObject { { name, str } }); }
public override IList <DesignerPropertyInfo> GetDesignerProperties(bool bCustom = false) { IList <DesignerPropertyInfo> result = base.GetDesignerProperties(bCustom); if (bCustom) { PropertyInfo pi = this.GetType().GetProperty("Phase"); DesignerPropertyInfo propertyInfo = new DesignerPropertyInfo(pi); result.Add(propertyInfo); } return(result); }
void editor_ValueWasChanged(DesignerPropertyInfo property) { string text = _selectedObject == null ? "Properties" : "Properties of " + _selectedObject.ToString(); //Text= text; //TabText= text; // if we change a DesignerNodeProperty other properties of that object might be affected if (property.Attribute is DesignerNodeProperty) { UpdatePropertyGrids(); } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerFlexibleFloat flexFloatAtt = property.Attribute as DesignerFlexibleFloat; if (flexFloatAtt != null) { unitLabel.Text = flexFloatAtt.Units; } DesignerFlexibleInteger flexIntegerAtt = property.Attribute as DesignerFlexibleInteger; if (flexIntegerAtt != null) { unitLabel.Text = flexIntegerAtt.Units; } CanUseDefinition canUseDefinition = (CanUseDefinition)property.Property.GetValue(obj, null); if (AIType.Current != null) { Type type = canUseDefinition.PropertyType; foreach (Definition definition in AIType.Current.Definitions) { PropertyInfo[] properties = definition.Object.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo prop in properties) { if (!prop.CanRead || prop.PropertyType != type) { continue; } comboBox.Items.Add(definition.Name + '.' + prop.Name); } } } if (canUseDefinition.DefinitionName != string.Empty && canUseDefinition.DefinitionMember != string.Empty) { string str = canUseDefinition.DefinitionName + '.' + canUseDefinition.DefinitionMember; if (!comboBox.Items.Contains(str)) { comboBox.Items.Insert(0, str); } comboBox.Text = str; } }
public override bool ShouldAddProperty(DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl"); DesignerPropertyInfo opr1Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1"); DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator"); DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2"); if (oplProp.Property != null) { RightValueDef rv = oplProp.GetValue(_obj) as RightValueDef; if (rv != null && rv.IsMethod && rv.Method != null) { return(property.Property != opr1Prop.Property && property.Property != operatorProp.Property && property.Property != opr2Prop.Property); } } OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator"); // action if (this.isAction()) { return(property.Property != opr1Prop.Property && property.Property != operatorProp.Property && property.Property != opr2Prop.Property); } // assign else if (operatorType == OperatorTypes.Assign) { return(property.Property != opr1Prop.Property); } // compute else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div) { } // compare else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual) { return(property.Property != opr1Prop.Property); } } return(base.ShouldAddProperty(property)); }
protected bool SetProperty(object obj, string propertyName, object value) { if (obj != null) { DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName); if (propInfo.Property != null) { propInfo.Property.SetValue(obj, value, null); return(true); } } return(false); }
public override void OnPropertyValueChanged(DesignerPropertyInfo property) { if (property.Property.Name == "Prototype") { List <ParInfo> pars = ((Behavior)(this.Behavior)).LocalVars; bool bLoop = true; //remove old added local variables while (bLoop) { int index = pars.FindIndex((p) => p.Name.IndexOf(LOCAL_TASK_PARAM_PRE) != -1); if (index != -1) { pars.RemoveAt(index); } else { bLoop = false; } } for (int i = 0; i < this._task.Params.Count; ++i) { var param = this._task.Params[i]; string par_name = string.Format("{0}{1}", LOCAL_TASK_PARAM_PRE, i); ParInfo par = new ParInfo(this, this.Behavior != null ? this.Behavior.AgentType : null); par.IsAddedAutomatically = true; par.Name = par_name; par.DisplayName = param.DisplayName; par.TypeName = param.Type.FullName; par.Variable = new VariableDef(param.Value); par.Description = param.Description; par.Display = false; pars.Add(par); } this.Behavior.AgentType.ClearPars(); this.Behavior.AgentType.AddPars(pars); if (Plugin.UpdateMetaStoreHandler != null) { Plugin.UpdateMetaStoreHandler(null); } } }
void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { string text = _selectedObject == null ? Resources.Properties : string.Format(Resources.PropertiesOf, _selectedObject.ToString()); Text = text; TabText = text; UndoManager.PreSave(); if (_selectedObject != null) { Nodes.Node node = null; if (_selectedObject is Nodes.Node) { node = (Nodes.Node)_selectedObject; } else if (_selectedObject is Attachments.Attachment) { node = ((Attachments.Attachment)_selectedObject).Node; } if (node != null) { if ((property.Attribute == null || !property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NotPrefabRelated)) && !string.IsNullOrEmpty(node.PrefabName)) { node.HasOwnPrefabData = true; } UndoManager.Save(this._rootBehavior); } } UndoManager.PostSave(); // if we change a DesignerNodeProperty other properties of that object might be affected if (property.Attribute is DesignerNodeProperty || uiPolicy != null && uiPolicy.ShouldUpdatePropertyGrids(property)) { PropertiesDock.UpdatePropertyGrids(); } if (BehaviorTreeViewDock.LastFocused != null && BehaviorTreeViewDock.LastFocused.BehaviorTreeView != null) { BehaviorTreeViewDock.LastFocused.BehaviorTreeView.Redraw(); } }
public Param(DesignerPropertyInfo property, object obj) { _paramInfo = null; _property = property; _object = obj; _value = property.GetValue(obj); _nativeType = (_value != null) ? Plugin.GetNativeTypeName(_value.GetType()) : string.Empty; DesignerProperty pattr = property.Attribute; _displayName = pattr.DisplayName; _description = pattr.Description; _attribute = pattr; _bParamFromStruct = true; }
public override string GetLabel(DesignerPropertyInfo property) { OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator"); // compare if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual) { DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2"); if (property.Property == opr2Prop.Property) { return(Resources.Right); } } return(base.GetLabel(property)); }
public override bool ShouldAddProperty(DesignerPropertyInfo property) { if (_obj != null) { if (Plugin.IsQueryFiltered) { DesignerPropertyInfo domainsProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Domains"); DesignerPropertyInfo descriptorRefsProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "DescriptorRefs"); return(property.Property != domainsProp.Property && property.Property != descriptorRefsProp.Property); } } return(true); }
public override void Update(object sender, DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyEditor resultOptionEditor = GetEditor(_obj, "ResultOption"); DesignerPropertyEditor resultFunctorEditor = GetEditor(_obj, "ResultFunctor"); Debug.Check(resultOptionEditor != null && resultFunctorEditor != null); if (resultOptionEditor != null && resultFunctorEditor != null) { MethodDef method = GetProperty(_obj, "Method") as MethodDef; MethodDef checkMethod = GetProperty(_obj, "ResultFunctor") as MethodDef; if (method == null || method.NativeReturnType == "behaviac::EBTStatus") { resultOptionEditor.Enabled = false; resultFunctorEditor.Enabled = false; //ResultOption is set to be SUCCESS by default SetProperty(_obj, "ResultOption", EBTStatus.BT_INVALID); } else { bool enableMethod = true; object prop = GetProperty(_obj, "ResultOption"); if (prop is EBTStatus) { EBTStatus checkStatusdProp = (EBTStatus)prop; if (EBTStatus.BT_INVALID != checkStatusdProp) { enableMethod = false; } } resultOptionEditor.Enabled = true; resultFunctorEditor.Enabled = enableMethod; } if (!resultFunctorEditor.Enabled) { SetProperty(_obj, "ResultFunctor", null); resultFunctorEditor.Clear(); } } } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerFlexibleFloat flexFloatAtt = property.Attribute as DesignerFlexibleFloat; if (flexFloatAtt != null) { minNumericUpDown.DecimalPlaces = flexFloatAtt.Precision; minNumericUpDown.Minimum = (decimal)flexFloatAtt.Min; minNumericUpDown.Maximum = (decimal)flexFloatAtt.Max; minNumericUpDown.Increment = (decimal)flexFloatAtt.Steps; maxNumericUpDown.DecimalPlaces = flexFloatAtt.Precision; maxNumericUpDown.Minimum = (decimal)flexFloatAtt.Min; maxNumericUpDown.Maximum = (decimal)flexFloatAtt.Max; maxNumericUpDown.Increment = (decimal)flexFloatAtt.Steps; FlexiblePropertyFloat flexProp = (FlexiblePropertyFloat)property.Property.GetValue(obj, null); minNumericUpDown.Value = (decimal)flexProp.Min; maxNumericUpDown.Value = (decimal)flexProp.Max; unitLabel.Text = flexFloatAtt.Units; } DesignerFlexibleInteger flexIntegerAtt = property.Attribute as DesignerFlexibleInteger; if (flexIntegerAtt != null) { minNumericUpDown.DecimalPlaces = 0; minNumericUpDown.Minimum = (decimal)flexIntegerAtt.Min; minNumericUpDown.Maximum = (decimal)flexIntegerAtt.Max; minNumericUpDown.Increment = (decimal)flexIntegerAtt.Steps; maxNumericUpDown.DecimalPlaces = 0; maxNumericUpDown.Minimum = (decimal)flexIntegerAtt.Min; maxNumericUpDown.Maximum = (decimal)flexIntegerAtt.Max; maxNumericUpDown.Increment = (decimal)flexIntegerAtt.Steps; FlexiblePropertyInteger flexProp = (FlexiblePropertyInteger)property.Property.GetValue(obj, null); minNumericUpDown.Value = (decimal)flexProp.Min; maxNumericUpDown.Value = (decimal)flexProp.Max; unitLabel.Text = flexIntegerAtt.Units; } }
public Param GetParam(string paramName, Type strutType, object obj, DesignerPropertyInfo param) { int indexInArray = -1; if (!_structParams.ContainsKey(paramName)) { StructParam_t ps0 = new StructParam_t(); _structParams[paramName] = ps0; ps0.type = obj.GetType(); IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(strutType, DesignerProperty.SortByDisplayOrder); foreach (DesignerPropertyInfo property in properties) { object member = property.GetValue(obj); Param v = new Param(property, obj); _structParams[paramName].AddParam(-1, v); } } StructParam_t ps1 = _structParams[paramName] as StructParam_t; Debug.Check(ps1 != null); if (ps1.type == obj.GetType()) { List <Param> ps = _structParams[paramName].GetParams(indexInArray); if (ps != null) { foreach (Param p in ps) { if (p.Name == param.Property.Name && p.Type == param.Property.PropertyType) { return(p); } } } else { Debug.Check(true); } } return(null); }
public override bool ShouldAddProperty(DesignerPropertyInfo property) { if (_obj != null) { DesignerPropertyInfo binaryOperator = DesignerProperty.GetDesignerProperty(_obj.GetType(), "BinaryOperator"); if (property.Property == binaryOperator.Property) { Attachments.Attachment attach = _obj as Attachments.Attachment; if (attach != null && attach.Node != null && attach.Node.Attachments != null && attach.Node.Attachments.Count > 0 && attach.Node.Attachments[0] == attach) { return(false); } } } return(base.ShouldAddProperty(property)); }
public override string GetLabel(DesignerPropertyInfo property) { OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator"); // action if (this.isAction()) { DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl"); if (property.Property == oplProp.Property) { return(Resources.Method); } } // assign else if (operatorType == OperatorTypes.Assign) { DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2"); if (property.Property == opr2Prop.Property) { return(Resources.Right); } } // compute else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div) { } // compare else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual) { DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2"); if (property.Property == opr2Prop.Property) { return(Resources.Right); } } return(base.GetLabel(property)); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="properties"></param> /// <param name="value"></param> private static void CreateCoordinateDesignerPropertyInfo(String keyName, MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties, int value) { DesignerPropertyInfo DesignerPropertyInfo = new DesignerPropertyInfo(); DesignerPropertyInfo.Value = value; if (control.Type != MgControlType.CTRL_TYPE_LINE) { DesignerPropertyInfo.VisibleInPropertyGrid = (control.Type == MgControlType.CTRL_TYPE_LINE ? false : true); } if (control.isComboBox() && !control.isOwnerDrawComboBox() && (keyName == "Height")) { DesignerPropertyInfo.VisibleInPropertyGrid = false; } properties.Add(keyName, DesignerPropertyInfo); }
protected DesignerPropertyEditor GetEditor(object obj, string propertyName) { if (obj != null) { DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName); if (propInfo.Property != null) { foreach (DesignerPropertyEditor editor in _allPropertyEditors) { DesignerPropertyInfo prop = editor.GetProperty(); if (prop.Property == propInfo.Property) { return(editor); } } } } return(null); }