protected override bool IsChildValueModified(PropertyEditor childEditor) { if (childEditor is SoundEmitterSourcePropertyEditor) return this.IsMemberInPrefabLinkChanges(ReflectionInfo.Property_SoundEmitter_Sources); else return base.IsChildValueModified(childEditor); }
public override MemberInfo MapEditorToMember(PropertyEditor editor) { if (editor is SoundEmitterSourcePropertyEditor) return ReflectionInfo.Property_SoundEmitter_Sources; else return base.MapEditorToMember(editor); }
public void ApplyTo(PropertyEditor mainEditor, bool dontCollapse = true) { if (mainEditor == null) return; foreach (GroupedPropertyEditor child in mainEditor.ChildrenDeep.OfType<GroupedPropertyEditor>()) { if (child.Expanded && dontCollapse) continue; child.Expanded = this.IsEditorExpanded(child); } }
protected override bool IsChildValueModified(PropertyEditor childEditor) { if (this.jointEditors.Contains(childEditor)) { Component[] values = this.GetValue().Cast<Component>().NotNull().ToArray(); return values.Any(c => { Duality.Resources.PrefabLink l = c.GameObj.AffectedByPrefabLink; return l != null && l.HasChange(c, ReflectionInfo.Property_RigidBody_Joints); }); } else return base.IsChildValueModified(childEditor); }
protected override PropertyEditor AutoCreateMemberEditor(MemberInfo info) { if (ReflectionHelper.MemberInfoEquals(info, typeof(PrimitiveNode).GetProperty("PrimitiveValue"))) { PrimitiveNode primitiveNode = this.GetValue().NotNull().FirstOrDefault() as PrimitiveNode; Type actualType = primitiveNode.NodeType.ToActualType(); if (actualType == null) actualType = (info as PropertyInfo).PropertyType; this.editorPrimitiveValue = this.ParentGrid.CreateEditor(actualType, this); return this.editorPrimitiveValue; } else return base.AutoCreateMemberEditor(info); }
public override MemberInfo MapEditorToMember(PropertyEditor editor) { if (editor == this.editorPos) return ReflectionInfo.Property_Transform_RelativePos; else if (editor == this.editorVel) return ReflectionInfo.Property_Transform_RelativeVel; else if (editor == this.editorScale) return ReflectionInfo.Property_Transform_RelativeScale; else if (editor == this.editorAngle) return ReflectionInfo.Property_Transform_RelativeAngle; else if (editor == this.editorAngleVel) return ReflectionInfo.Property_Transform_RelativeAngleVel; else return base.MapEditorToMember(editor); }
public void UpdatePrefabModifiedState(PropertyEditor specificEditor = null) { if (specificEditor == null) { foreach (PropertyEditor editor in this.Children) { MemberInfo member = this.MapEditorToMember(editor); editor.ValueModified = this.IsMemberInPrefabLinkChanges(member); } } else { MemberInfo member = this.MapEditorToMember(specificEditor); specificEditor.ValueModified = this.IsMemberInPrefabLinkChanges(member); } }
protected override PropertyEditor AutoCreateMemberEditor(MemberInfo info) { if (ReflectionHelper.MemberInfoEquals(info, typeof(ArrayNode).GetProperty("PrimitiveData"))) { ArrayNode arrayNode = this.GetValue().NotNull().FirstOrDefault() as ArrayNode; Type actualType = ReflectionHelper.ResolveType(arrayNode.TypeString); if (actualType == null || !actualType.IsArray || actualType.GetElementType() == null) actualType = (info as PropertyInfo).PropertyType; bool primitiveDataEditable = actualType != null && actualType.IsArray && (actualType.GetElementType().IsPrimitive || actualType.GetElementType() == typeof(string)); this.editorPrimitiveData = this.ParentGrid.CreateEditor(actualType, this); if (!primitiveDataEditable) this.editorPrimitiveData.Setter = null; return this.editorPrimitiveData; } else return base.AutoCreateMemberEditor(info); }
public PropertyEditor GetFocusReciever(PropertyEditor primary, bool secondaryNext = true) { if (primary == null) return null; while (!primary.CanGetFocus) { if (secondaryNext) { if (primary.ChildrenDeep.Any(e => e.CanGetFocus)) primary = primary.ChildrenDeep.FirstOrDefault(e => e.CanGetFocus); else if (primary.NextEditor != null) primary = primary.NextEditor; else if (primary.ParentEditor != null) primary = this.GetFocusReciever(primary.ParentEditor.NextEditor, secondaryNext); else return null; } else { if (primary.PrevEditor != null) primary = primary.PrevEditor; else primary = this.GetFocusReciever(primary.ParentEditor, secondaryNext); } if (primary == null) break; } return primary; }
public void Focus(PropertyEditor editor) { if (this.focusEditor == editor) return; editor = this.GetFocusReciever(editor); if (this.focusEditor != null && this.Focused) this.focusEditor.OnLostFocus(EventArgs.Empty); this.focusEditor = editor; this.ScrollToEditor(this.focusEditor); if (this.focusEditor != null) { if (!this.Focused) this.Focus(); else this.focusEditor.OnGotFocus(EventArgs.Empty); } //this.Invalidate(); }
public virtual void ConfigureEditor(PropertyEditor editor, object configureData = null) { editor.ConfigureEditor(configureData); }
protected override void OnEditorRemoving(PropertyEditor editor) { base.OnEditorRemoving(editor); this.UpdatePrefabModifiedState(); }
private static string GetEditorId(PropertyEditor editor) { if (editor == null) return ""; return editor.PropertyName + editor.EditedType; }
protected override bool IsChildNonPublic(PropertyEditor childEditor) { if (base.IsChildNonPublic(childEditor)) return true; if (childEditor.EditedMember is FieldInfo) return true; // Discourage use of fields in Components return false; }
public virtual Point GetChildLocation(PropertyEditor child) { return(Point.Empty); }
public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason) : base(editor, value) { this.reason = reason; }
protected override void BeforeAutoCreateEditors() { base.BeforeAutoCreateEditors(); JointInfo joint = this.GetValue().Cast<JointInfo>().FirstOrDefault(); if (joint != null && joint.DualJoint) { if (this.otherColEditor == null) { this.otherColEditor = this.ParentGrid.CreateEditor(typeof(RigidBody), this); this.otherColEditor.Getter = this.CreateOtherColValueGetter(); this.otherColEditor.Setter = this.CreateOtherColValueSetter(); this.otherColEditor.PropertyName = PluginRes.EditorBaseRes.PropertyName_OtherCollider; this.otherColEditor.PropertyDesc = PluginRes.EditorBaseRes.PropertyDesc_OtherCollider; this.ParentGrid.ConfigureEditor(this.otherColEditor); this.AddPropertyEditor(this.otherColEditor); } } else if (this.otherColEditor != null) { this.RemovePropertyEditor(this.otherColEditor); this.otherColEditor = null; } }
public override void ClearContent() { base.ClearContent(); this.otherColEditor = null; }
public virtual MemberInfo MapEditorToMember(PropertyEditor editor) { return editor != null ? editor.EditedMember : null; }
public Point GetEditorLocation(PropertyEditor editor, bool scrolled = false) { if (this.mainEditor == null) return Point.Empty; Point result = this.mainEditor.GetChildLocation(editor); result.X += this.ClientRectangle.X; result.Y += this.ClientRectangle.Y; if (scrolled) { result.X += this.AutoScrollPosition.X; result.Y += this.AutoScrollPosition.Y; } return result; }
public void UpdateFrom(PropertyEditor mainEditor) { if (mainEditor == null) return; foreach (GroupedPropertyEditor child in mainEditor.ChildrenDeep.OfType<GroupedPropertyEditor>()) this.SetEditorExpanded(child, child.Expanded); }
public void ScrollToEditor(PropertyEditor editor) { Point editorLoc = this.GetEditorLocation(editor); Rectangle editorRect = new Rectangle(editorLoc, editor.Size); Point scrollPos = this.AutoScrollPosition; if (editorRect.Bottom > this.ClientRectangle.Y - scrollPos.Y + this.ClientRectangle.Height) scrollPos.Y = -editorRect.Bottom + this.ClientRectangle.Y + this.ClientRectangle.Height; if (editorRect.Y < this.ClientRectangle.Y - scrollPos.Y) scrollPos.Y = this.ClientRectangle.Y - editorRect.Y; this.AutoScrollPosition = new Point(-scrollPos.X, -scrollPos.Y); }
protected override void BeforeAutoCreateEditors() { base.BeforeAutoCreateEditors(); this.editorPos = this.ParentGrid.CreateEditor((typeof(Vector3)), this); if (this.editorPos != null) { this.editorPos.BeginUpdate(); this.editorPos.Getter = this.PosGetter; this.editorPos.Setter = this.PosSetter; this.editorPos.PropertyName = "Pos"; this.ParentGrid.ConfigureEditor(this.editorPos, new EditorHintAttribute[] { new EditorHintDecimalPlacesAttribute(0), new EditorHintIncrementAttribute(1) }); this.AddPropertyEditor(this.editorPos); this.editorPos.EndUpdate(); } this.editorVel = this.ParentGrid.CreateEditor(typeof(Vector3), this); if (this.editorVel != null) { this.editorVel.BeginUpdate(); this.editorVel.Getter = this.VelGetter; this.editorVel.PropertyName = "Vel"; this.ParentGrid.ConfigureEditor(this.editorVel); this.AddPropertyEditor(this.editorVel); this.editorVel.EndUpdate(); } this.editorScale = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorScale != null) { this.editorScale.BeginUpdate(); this.editorScale.Getter = this.ScaleGetter; this.editorScale.Setter = this.ScaleSetter; this.editorScale.PropertyName = "Scale"; this.ParentGrid.ConfigureEditor(this.editorScale); this.AddPropertyEditor(this.editorScale); this.editorScale.EndUpdate(); } this.editorAngle = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorAngle != null) { this.editorAngle.BeginUpdate(); this.editorAngle.Getter = this.AngleGetter; this.editorAngle.Setter = this.AngleSetter; this.editorAngle.PropertyName = "Angle"; this.ParentGrid.ConfigureEditor(this.editorAngle, new EditorHintAttribute[] { new EditorHintDecimalPlacesAttribute(1), new EditorHintIncrementAttribute(1), new EditorHintRangeAttribute(float.MinValue, float.MaxValue, 0.0f, 359.999f) }); this.AddPropertyEditor(this.editorAngle); this.editorAngle.EndUpdate(); } this.editorAngleVel = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorAngleVel != null) { this.editorAngleVel.BeginUpdate(); this.editorAngleVel.Getter = this.AngleVelGetter; this.editorAngleVel.PropertyName = "AngleVel"; this.ParentGrid.ConfigureEditor(this.editorAngleVel, new[] { new EditorHintIncrementAttribute(0.1f) }); this.AddPropertyEditor(this.editorAngleVel); this.editorAngleVel.EndUpdate(); } this.AddEditorForMember(ReflectionInfo.Property_Transform_DeriveAngle); this.AddEditorForMember(ReflectionInfo.Property_Transform_IgnoreParent); this.editorShowRelative = this.ParentGrid.CreateEditor(typeof(bool), this); if (editorShowRelative != null) { this.editorShowRelative.BeginUpdate(); this.editorShowRelative.Getter = this.ShowRelativeGetter; this.editorShowRelative.Setter = this.ShowRelativeSetter; this.editorShowRelative.PropertyName = "[ Relative values ]"; this.ParentGrid.ConfigureEditor(this.editorShowRelative); this.AddPropertyEditor(this.editorShowRelative); this.editorShowRelative.EndUpdate(); } }
protected override bool IsChildValueModified(PropertyEditor childEditor) { return this.IsMemberInPrefabLinkChanges(childEditor.EditedMember); }
public PropertyEditorValueEventArgs(PropertyEditor editor, object value) { this.editor = editor; this.value = value; }
public override void ConfigureEditor(PropertyEditor editor, object configureData = null) { IEnumerable<EditorHintAttribute> hintOverride = configureData as IEnumerable<EditorHintAttribute>; IEnumerable<EditorHintAttribute> parentHint = null; if (editor.ParentEditor != null) { IEnumerable<EditorHintAttribute> parentHintOverride = editor.ParentEditor.ConfigureData as IEnumerable<EditorHintAttribute>; if (editor.ParentEditor.EditedMember != null) parentHint = editor.ParentEditor.EditedMember.GetEditorHints<EditorHintAttribute>(parentHintOverride); else parentHint = parentHintOverride; } if (hintOverride == null && parentHint != null) { // No configuration data available? Allow to derive certain types from parent list or dictionary. if (editor.ParentEditor is IListPropertyEditor || editor.ParentEditor is IDictionaryPropertyEditor) { hintOverride = parentHint.Where(a => a is EditorHintDecimalPlacesAttribute || a is EditorHintIncrementAttribute || a is EditorHintRangeAttribute); } // That way we can specify the decimal places of an array of Vector2-structs and actually change those Vector2 editors. } // Invoke the PropertyEditor's configure method base.ConfigureEditor(editor, hintOverride); // Do some final configuration for editors that do not behave as intended by default. if (editor is MemberwisePropertyEditor) { MemberwisePropertyEditor memberEditor = editor as MemberwisePropertyEditor; memberEditor.MemberPredicate = this.EditorMemberPredicate; memberEditor.MemberAffectsOthers = this.EditorMemberAffectsOthers; memberEditor.MemberPropertySetter = this.EditorMemberPropertySetter; memberEditor.MemberFieldSetter = this.EditorMemberFieldSetter; } if (editor is IListPropertyEditor) { IListPropertyEditor listEditor = editor as IListPropertyEditor; listEditor.ListIndexSetter = this.EditorListIndexSetter; } if (editor is IDictionaryPropertyEditor) { IDictionaryPropertyEditor dictEditor = editor as IDictionaryPropertyEditor; dictEditor.DictionaryKeySetter = this.EditorDictionaryKeySetter; } var flagsAttrib = editor.EditedMember.GetEditorHint<EditorHintFlagsAttribute>(hintOverride); if (flagsAttrib != null) { editor.ForceWriteBack = (flagsAttrib.Flags & MemberFlags.ForceWriteback) == MemberFlags.ForceWriteback; if ((flagsAttrib.Flags & MemberFlags.ReadOnly) == MemberFlags.ReadOnly) editor.Setter = null; } if (editor is NumericPropertyEditor) { var rangeAttrib = editor.EditedMember.GetEditorHint<EditorHintRangeAttribute>(hintOverride); var incAttrib = editor.EditedMember.GetEditorHint<EditorHintIncrementAttribute>(hintOverride); var placesAttrib = editor.EditedMember.GetEditorHint<EditorHintDecimalPlacesAttribute>(hintOverride); NumericPropertyEditor numEditor = editor as NumericPropertyEditor; if (rangeAttrib != null) { numEditor.Maximum = rangeAttrib.Max; numEditor.Minimum = rangeAttrib.Min; } if (incAttrib != null) numEditor.Increment = incAttrib.Increment; if (placesAttrib != null) numEditor.DecimalPlaces = placesAttrib.Places; } }
public PropertyEditor CreateEditor(Type editedType, PropertyEditor parentEditor) { if (parentEditor == null) throw new ArgumentNullException("parentEditor"); if (parentEditor.ParentGrid != this) throw new ArgumentException("The specified editor is not a child of this PropertyGrid", "parentEditor"); PropertyEditor e = this.editorProvider.CreateEditor(editedType, new ProviderContext(this, parentEditor)); e.EditedType = editedType; e.ParentGrid = this; return e; }
public ProviderContext(PropertyGrid grid, PropertyEditor editor = null) { this.parentEditor = editor; this.parentGrid = editor != null ? editor.ParentGrid : grid; }
protected override void OnEditorAdded(PropertyEditor editor) { base.OnEditorAdded(editor); this.UpdatePrefabModifiedState(editor); }
private static string GetEditorFullId(PropertyEditor editor) { if (editor == null) return ""; string fullId = ""; while (editor != null) { fullId = GetEditorId(editor) + "/" + fullId; editor = editor.ParentEditor; } return fullId; }
protected void InitPropertyEditor(Type type) { if (this.mainEditor != null) this.DisposePropertyEditor(); this.focusEditor = null; this.mainEditor = this.editorProvider.CreateEditor(type, new ProviderContext(this)); this.mainEditor.SizeChanged += this.mainEditor_SizeChanged; this.mainEditor.ValueChanged += this.mainEditor_ValueChanged; this.mainEditor.EditingFinished += this.mainEditor_EditingFinished; this.UpdatePropertyEditor(); this.ConfigureEditor(this.mainEditor); if (this.mainEditor is GroupedPropertyEditor) { GroupedPropertyEditor mainGroupEditor = this.mainEditor as GroupedPropertyEditor; mainGroupEditor.Expanded = true; } this.Invalidate(); }
protected void DisposePropertyEditor() { if (this.mainEditor == null) return; this.mainEditor.SizeChanged -= this.mainEditor_SizeChanged; this.mainEditor.Dispose(); this.mainEditor = null; this.focusEditor = null; this.Invalidate(); }
public PropertyEditorEventArgs(PropertyEditor e) { this.editor = e; }