protected override void ConfigureEditor(object configureData) { base.ConfigureEditor(configureData); var hintOverride = configureData as IEnumerable <EditorHintAttribute>; foreach (NumericEditorTemplate t in this.editor) { t.ResetProperties(); this.ApplyDefaultSubEditorConfig(t); } if (this.EditedMember != null) { var range = EditorHintAttribute.Get <EditorHintRangeAttribute>(this.EditedMember, hintOverride); var increment = EditorHintAttribute.Get <EditorHintIncrementAttribute>(this.EditedMember, hintOverride); var places = EditorHintAttribute.Get <EditorHintDecimalPlacesAttribute>(this.EditedMember, hintOverride); foreach (NumericEditorTemplate t in this.editor) { if (places != null) { t.DecimalPlaces = places.Places; } if (increment != null) { t.Increment = increment.Increment; } if (range != null) { t.ValueBarMaximum = range.ReasonableMaximum; t.ValueBarMinimum = range.ReasonableMinimum; t.Minimum = range.LimitMinimum; t.Maximum = range.LimitMaximum; } } } }
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 = EditorHintAttribute.GetAll <EditorHintAttribute>(editor.ParentEditor.EditedMember, 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 = EditorHintAttribute.Get <EditorHintFlagsAttribute>(editor.EditedMember, 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 = EditorHintAttribute.Get <EditorHintRangeAttribute>(editor.EditedMember, hintOverride); var incAttrib = EditorHintAttribute.Get <EditorHintIncrementAttribute>(editor.EditedMember, hintOverride); var placesAttrib = EditorHintAttribute.Get <EditorHintDecimalPlacesAttribute>(editor.EditedMember, hintOverride); NumericPropertyEditor numEditor = editor as NumericPropertyEditor; if (rangeAttrib != null) { numEditor.ValueBarMaximum = rangeAttrib.ReasonableMaximum; numEditor.ValueBarMinimum = rangeAttrib.ReasonableMinimum; numEditor.Maximum = rangeAttrib.LimitMaximum; numEditor.Minimum = rangeAttrib.LimitMinimum; } if (incAttrib != null) { numEditor.Increment = incAttrib.Increment; } if (placesAttrib != null) { numEditor.DecimalPlaces = placesAttrib.Places; } } }