private Type getDependedPropertyType(DesignerPropertyInfo prop, object obj) { Debug.Check(obj != null); PropertyInfo pi = getDependedProperty(prop, obj); if (pi != null) { object propertyMember = pi.GetValue(obj, null); VariableDef variable = propertyMember as VariableDef; if (variable != null) { return(variable.ValueType); } RightValueDef varRV = propertyMember as RightValueDef; if (varRV != null) { return(varRV.ValueType); } MethodDef method = propertyMember as MethodDef; if (method != null) { return(method.ReturnType); } } return(null); }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { if (!_initialized) { return; } if (_node != null) { _node.OnPropertyValueChanged(true); UndoManager.Save(_node.Behavior); } //comment it as it disposed control and System.ObjectDisposedException might be raised //buildPropertyGrid(); if (property.Attribute is DesignerNodeProperty || uiPolicy != null && uiPolicy.ShouldUpdatePropertyGrids(property)) { buildPropertyGrid(); } _isModified = true; }
protected void OnValueChanged(DesignerPropertyInfo property) { if (!_valueWasAssigned) { return; } Nodes.Node node = _object as Nodes.Node; if (node != null) { node.OnPropertyValueChanged(true); } else { Attachments.Attachment attach = _object as Attachments.Attachment; if (attach != null) { attach.OnPropertyValueChanged(true); } } if (ValueWasChanged != null) { ValueWasChanged(this, property); } }
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(); } } } } }
private Type getPropertyType(DesignerPropertyInfo prop, object obj, string valueClass) { if (prop.Property != null && obj != null) { object propertyMember = prop.Property.GetValue(obj, null); if (propertyMember != null) { VariableDef variable = propertyMember as VariableDef; if (variable != null) { variable.ValueClass = valueClass; return(variable.GetValueType()); } RightValueDef varRV = propertyMember as RightValueDef; if (varRV != null) { return(varRV.ValueType); } } } if (prop.Attribute != null) { DesignerPropertyEnum enumAtt = prop.Attribute as DesignerPropertyEnum; if (enumAtt != null) { return(enumAtt.FilterType); } } return(null); }
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)); } Nodes.Behavior behavior = GetBehavior(); _agentType = (behavior != null) ? behavior.AgentType : null; SetTypes(); 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; }
private Type GetEditorType(DesignerPropertyInfo prop, object obj, bool isConst, bool isFunction) { if (isConst) { Type type = getDependedPropertyType(prop, obj); if (type == null) { type = getPropertyType(prop, obj, VariableDef.kConst); } if (type != null) { return(Plugin.InvokeEditorType(type)); } } else if (isFunction) { return(typeof(DesignerMethodEnumEditor)); } else { return(typeof(DesignerPropertyEnumEditor)); } return(null); }
protected void RereshProperty(bool byForce, DesignerPropertyInfo property) { if (!byForce) { DesignerPropertyEnum enumAtt = property.Attribute as DesignerPropertyEnum; if (enumAtt != null && enumAtt.DependingProperty != "") { byForce = true; } if (this._param != null && this._param.Type.FullName == "XMLPluginBehaviac.IList") { byForce = true; } } if (byForce && DesignerPropertyEditor.PropertyChanged != null) { try { //DesignerPropertyEditor.PropertyChanged(); this.BeginInvoke(new MethodInvoker(DesignerPropertyEditor.PropertyChanged)); } catch { } } }
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); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); string enumName = string.Empty; Type enumtype = null; DesignerTypeEnum enumAtt = property.Attribute as DesignerTypeEnum; if (enumAtt != null) { object agentType = property.Property.GetValue(obj, null); AgentType t = agentType as AgentType; if (t != null) { enumName = t.DisplayName; } enumtype = property.Property.PropertyType; } if (enumtype == null) { throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name)); } _agentTypes = getAgentTypes(); comboBox.Items.Clear(); foreach(AgentType t in _agentTypes) { if (t.DisplayName == enumName) { _agentTypes.Clear(); _agentTypes.Add(t); comboBox.Items.Add(t.DisplayName); break; } } comboBox.Text = enumName; }
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 bool ShouldAddProperty(DesignerPropertyInfo property) { if (_obj != null) { OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator"); 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"); // 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 true; }
private DesignerPropertyEditor CreateEditor(string valueType, DesignerPropertyInfo prop, object obj, bool isConst, bool isFunction) { if (flowLayoutPanel.Controls.Count > 1) { flowLayoutPanel.Controls.RemoveAt(1); } Type editorType = GetEditorType(prop, obj, isConst, isFunction); if (editorType == null) { return(null); } DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]); editor.Location = new System.Drawing.Point(74, 1); editor.Margin = new System.Windows.Forms.Padding(0); editor.Size = new System.Drawing.Size(flowLayoutPanel.Width - typeComboBox.Width - 5, 20); editor.TabIndex = 1; editor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged); setEditor(valueType, editor, prop, obj, isConst, isFunction); flowLayoutPanel.Controls.Add(editor); return(editor); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerBoolean boolAtt = property.Attribute as DesignerBoolean; if (boolAtt != null) { checkBox.Checked = (bool)property.Property.GetValue(obj, null); } }
/// <summary> /// This method is used to sort properties by their display order. /// </summary> public static int SortByDisplayOrder(DesignerPropertyInfo a, DesignerPropertyInfo b) { if (a.Attribute.DisplayOrder == b.Attribute.DisplayOrder) { return(0); } return(a.Attribute.DisplayOrder < b.Attribute.DisplayOrder ? -1 : 1); }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { // Set the owner for the method. if (_property.Property != null) { object propertyMember = _property.Property.GetValue(_object, null); RightValueDef varRV = propertyMember as RightValueDef; if (varRV != null && varRV.IsMethod) { int methodIndex = -1; int offset = 0; for (int i = 0; i < typeComboBox.Items.Count; ++i) { string item = typeComboBox.Items[i].ToString(); int pos = item.IndexOf(VariableDef.kMethod); if (pos != -1) { methodIndex = i; if (item == VariableDef.kSelfMethod) { offset = 1; } break; } } if (methodIndex != -1) { Debug.Check(varRV.Method != null); if (typeComboBox.SelectedIndex - methodIndex - offset >= 0) { string owner = _currentNames[typeComboBox.SelectedIndex - methodIndex - offset]; int pos = owner.IndexOf(VariableDef.kMethod); if (pos >= 0) { owner = owner.Substring(0, pos); } varRV.Method.Owner = owner; } else { varRV.Method.Owner = VariableDef.kSelf; } } } } OnValueChanged(_property); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); object value = property.GetValue(obj); if (value != null) { setProperty(value, property.Attribute.DisplayName, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly), obj); } else { update(); } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerBoolean boolAtt = property.Attribute as DesignerBoolean; if (boolAtt != null) { checkBox.Checked = (bool)property.Property.GetValue(obj, null); } }
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); }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { if (_node != null) { _node.OnPropertyValueChanged(true); UndoManager.Save(_node.Behavior); } //comment it as it disposed control and System.ObjectDisposedException might be raised //buildPropertyGrid(); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); object v = property.Property.GetValue(obj, null); if (Plugin.IsCharType(v.GetType())) { textBox.MaxLength = 1; } textBox.Text = trimQuotes(v.ToString()); }
private PropertyInfo getDependedProperty(DesignerPropertyInfo prop, object obj) { Debug.Check(obj != null); DesignerPropertyEnum propertyAttr = prop.Attribute as DesignerPropertyEnum; if (propertyAttr != null && !string.IsNullOrEmpty(propertyAttr.DependedProperty)) { return(obj.GetType().GetProperty(propertyAttr.DependedProperty)); } return(null); }
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 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 void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { if (this.propertyEditor != null) { UndoManager.PreSave(); // Don't save Undo data here. _par.Variable = this.propertyEditor.GetVariable(); UndoManager.PostSave(); // Just save Undo data here. OnValueChanged(_property); } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); object value = property.GetValue(obj); if (value != null) { setProperty(value, property.Attribute.DisplayName, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly), obj); } else { update(); } }
protected void RereshProperty(bool byForce, DesignerPropertyInfo property) { if (!byForce) { DesignerPropertyEnum enumAtt = property.Attribute as DesignerPropertyEnum; if (enumAtt != null && enumAtt.DependingProperty != "") { byForce = true; } } if (byForce && DesignerPropertyEditor.PropertyChanged != null) { this.BeginInvoke(new MethodInvoker(DesignerPropertyEditor.PropertyChanged)); } }
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 SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); object v = property.Property.GetValue(obj, null); if (v != null) { if (Plugin.IsCharType(v.GetType())) { textBox.MaxLength = 1; } textBox.Text = trimQuotes(v.ToString()); } else { Debug.Check(false); } }
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; }
private static bool getPropertyInfo(Type type, string propertyName, out DesignerPropertyInfo p) { IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type); foreach (DesignerPropertyInfo property in properties) { if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave) && property.Property.Name == propertyName) { p = property; return(true); } } p = new DesignerPropertyInfo(); //throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); return(false); }
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 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.GetValueType(); } 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; } setComboBox(); }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); string enumName = string.Empty; Type enumtype = null; DesignerTypeEnum enumAtt = property.Attribute as DesignerTypeEnum; if (enumAtt != null) { object agentType = property.Property.GetValue(obj, null); AgentType t = agentType as AgentType; if (t != null) { enumName = t.DisplayName; } enumtype = property.Property.PropertyType; } if (enumtype == null) { throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name)); } _agentTypes = getAgentTypes(); comboBox.Items.Clear(); foreach (AgentType t in _agentTypes) { if (t.DisplayName == enumName) { _agentTypes.Clear(); _agentTypes.Add(t); comboBox.Items.Add(t.DisplayName); break; } } comboBox.Text = enumName; }
public override bool ShouldAddProperty(DesignerPropertyInfo property) { if (_obj != null) { OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator"); DesignerPropertyInfo opr1Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1"); DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl"); DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator"); DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2"); // compare if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual) { return property.Property != opr1Prop.Property; } } return true; }
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 { statusPhaseEditor.Enabled = false; //ResultOption is set to be SUCCESS by default SetProperty(_obj, "TransitionPhase", PluginBehaviac.Events.ETransitionPhase.ETP_Always); } } }
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); FailurePolicyEditor.Visible = !bHTN; DesignerPropertyEditor SuccessPolicyEditor = GetEditor(_obj, "SuccessPolicy"); Debug.Check(SuccessPolicyEditor != null); SuccessPolicyEditor.Visible = !bHTN; DesignerPropertyEditor ExitPolicyEditor = GetEditor(_obj, "ExitPolicy"); Debug.Check(ExitPolicyEditor != null); ExitPolicyEditor.Visible = !bHTN; DesignerPropertyEditor ChildFinishPolicyEditor = GetEditor(_obj, "ChildFinishPolicy"); Debug.Check(ChildFinishPolicyEditor != null); ChildFinishPolicyEditor.Visible = !bHTN; } } } }
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 { // } } } } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); object v = property.Property.GetValue(obj, null); if (v != null) { m_IsChar = false; if (Plugin.IsCharType(v.GetType())) { m_IsChar = true; textBox.MaxLength = 2; } textBox.Text = trimQuotes(m_IsChar, v.ToString()); } else { Debug.Check(false); } }
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); 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 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; } } } return base.ShouldAddProperty(property); }
/// <summary> /// Returns the property this one is linked to. /// </summary> /// <param name="linkBroken">Is true if a link was found but it does not work.</param> /// <returns>The info of the property this is linked to.</returns> public DesignerPropertyInfo GetLinkedProperty(object obj, out bool linkBroken) { linkBroken = false; if (string.IsNullOrEmpty(_linkedToProperty)) { return(new DesignerPropertyInfo()); } DesignerPropertyInfo dpi = DesignerProperty.GetDesignerProperty(obj.GetType(), _linkedToProperty); // if we are linked to a DesignerNodeProperty we get the information of its assigned property DesignerNodeProperty dnp = dpi.Attribute as DesignerNodeProperty; if (dnp == null) { return(dpi); } Attachments.Attachment attach = (Attachments.Attachment)obj; // check if a valid property is associated object objvalue = dpi.Property.GetValue(obj, null); string value = dnp.GetDisplayValue(objvalue); if (string.IsNullOrEmpty(value) || value == Resources.DesignerNodePropertyNone) { linkBroken = true; return(new DesignerPropertyInfo()); } // return the property we are pointing at return(DesignerProperty.GetDesignerProperty(attach.Node.GetType(), value)); }
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(); filterEnums(enumAtt, enumName, enumtype); }
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); } } }
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 Param GetParam(string paramName, DesignerPropertyInfo param, int indexInArray = -1) { if (_structParams.ContainsKey(paramName)) { 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 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; }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { OnValueChanged(_property); }
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.Name; 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) { _parameter.Variable = propertyEditor.GetVariable(); }
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, node.Behavior); } } UndoManager.PostSave(); // if we change a DesignerNodeProperty other properties of that object might be affected if (property.Attribute is DesignerNodeProperty) { PropertiesDock.UpdatePropertyGrids(); } if (BehaviorTreeViewDock.LastFocused != null) { BehaviorTreeViewDock.LastFocused.Refresh(); } }
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; }
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; }
public virtual string GetLabel(DesignerPropertyInfo property) { return property.Attribute.DisplayName; }
public void DoSubItemAdded(DesignerPropertyInfo property) { if (SubItemAdded != null) { SubItemAdded(this, property); } }
public virtual void OnPropertyValueChanged(DesignerPropertyInfo property) { }
private void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { Update(); }
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); } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); // check if there is an override for this paroperty Nodes.Node node = _object as Nodes.Node; if (node != null && node.HasOverrride(property.Property.Name)) { numericUpDown.Enabled = false; return; } DesignerPropertyInfo restrictions = property; bool linkBroken; DesignerPropertyInfo linkedProperty = property.Attribute.GetLinkedProperty(obj, out linkBroken); // control cannot be used with a broken link if (linkBroken) { numericUpDown.Enabled = false; return; } // if we have a linked property this property will define the restrictions if (linkedProperty.Property != null) { restrictions = linkedProperty; } // extract resrictions for float property DesignerFloat restFloatAtt = restrictions.Attribute as DesignerFloat; if (restFloatAtt != null) { SetRange(restFloatAtt.Precision, (decimal)restFloatAtt.Min, (decimal)restFloatAtt.Max, (decimal)restFloatAtt.Steps, restFloatAtt.Units); } // extract restrictions for int property DesignerInteger restIntAtt = restrictions.Attribute as DesignerInteger; if (restIntAtt != null) { SetRange(0, (decimal)restIntAtt.Min, (decimal)restIntAtt.Max, (decimal)restIntAtt.Steps, restIntAtt.Units); } // extract the value decimal value = 0; DesignerFloat floatAtt = property.Attribute as DesignerFloat; if (floatAtt != null) { float val = (float)property.Property.GetValue(obj, null); value = (decimal)val; } DesignerInteger intAtt = property.Attribute as DesignerInteger; if (intAtt != null) { int val = (int)property.Property.GetValue(obj, null); value = (decimal)val; } // assign value within limits numericUpDown.Value = Math.Max(numericUpDown.Minimum, Math.Min(numericUpDown.Maximum, value)); }
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(); }