public override MemberInfo MapEditorToMember(PropertyEditor editor)
		{
			if (this.jointEditors.Contains(editor))
				return ReflectionInfo.Property_RigidBody_Joints;
			else
				return base.MapEditorToMember(editor);
		}
		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);
     }
 }
		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.ChildEditors)
				{
					MemberInfo member = this.MapEditorToMember(editor);
					editor.ValueModified = this.IsMemberInPrefabLinkChanges(member);
				}
			}
			else
			{
				MemberInfo member = this.MapEditorToMember(specificEditor);
				specificEditor.ValueModified = this.IsMemberInPrefabLinkChanges(member);
			}
		}
Exemple #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (this.focusEditor != null)
            {
                PropertyEditor current = this.focusEditor;
                while (current != null)
                {
                    current.OnKeyDown(e);
                    if (e.Handled)
                    {
                        break;
                    }
                    current = current.ParentEditor;
                }
            }

            if (!e.Handled)
            {
                if (this.focusEditor != null)
                {
                    if (e.KeyCode == Keys.Down)
                    {
                        PropertyEditor current = this.focusEditor;
                        PropertyEditor next    = this.GetNextFocusEditor(current);
                        if (next == null)
                        {
                            next = current.VisibleChildEditors.FirstOrDefault();
                        }
                        if (next == null && current.ParentEditor != null)
                        {
                            next = this.GetNextFocusEditor(current.ParentEditor);
                        }

                        next = this.GetFocusReciever(next, true);
                        if (next != null)
                        {
                            next.Focus();
                        }
                        e.Handled = true;
                    }
                    else if (e.KeyCode == Keys.Up)
                    {
                        PropertyEditor current = this.focusEditor;
                        PropertyEditor prev    = this.GetPrevFocusEditor(current);
                        if (prev == null)
                        {
                            prev = current.ParentEditor;
                        }

                        prev = this.GetFocusReciever(prev, false);
                        if (prev != null)
                        {
                            prev.Focus();
                        }
                        e.Handled = true;
                    }
                    else if (e.KeyCode == Keys.Left)
                    {
                        PropertyEditor current = this.focusEditor;
                        while (current != null)
                        {
                            current = current.ParentEditor;
                            while (current != null && !current.CanGetFocus)
                            {
                                current = current.ParentEditor;
                            }
                            if (current != null)
                            {
                                current.Focus();
                                break;
                            }
                        }
                        e.Handled = true;
                    }
                    else if (e.KeyCode == Keys.Right)
                    {
                        if (this.focusEditor != null)
                        {
                            if (this.focusEditor is GroupedPropertyEditor)
                            {
                                (this.focusEditor as GroupedPropertyEditor).Expanded = true;
                            }
                            PropertyEditor current = null;
                            current = this.focusEditor.VisibleChildEditors.FirstOrDefault(editor => editor.CanGetFocus);
                            if (current == null)
                            {
                                current = this.focusEditor.GetChildEditorsDeep(true).FirstOrDefault(editor => editor.CanGetFocus);
                            }
                            if (current != null)
                            {
                                current.Focus();
                            }
                        }
                        e.Handled = true;
                    }
                    else if (e.KeyCode == Keys.PageUp || e.KeyCode == Keys.Home)
                    {
                        if (this.focusEditor.ParentEditor != null)
                        {
                            PropertyEditor current = this.focusEditor.ParentEditor;
                            current = current.VisibleChildEditors.FirstOrDefault(editor => editor.CanGetFocus);
                            if (current != null)
                            {
                                current.Focus();
                            }
                        }
                        e.Handled = true;
                    }
                    else if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.End)
                    {
                        if (this.focusEditor.ParentEditor != null)
                        {
                            PropertyEditor current = this.focusEditor.ParentEditor;
                            current = current.VisibleChildEditors.LastOrDefault(editor => editor.CanGetFocus);
                            if (current != null)
                            {
                                current.Focus();
                            }
                        }
                        e.Handled = true;
                    }
                }
            }
        }
 private static string GetEditorId(PropertyEditor editor)
 {
     if (editor == null) return "";
     return editor.PropertyName + editor.EditedType;
 }
Exemple #8
0
 public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason) : base(editor, value)
 {
     this.reason = reason;
 }
		public override void ClearContent()
		{
			base.ClearContent();
			this.otherColEditor = null;
		}
 private void DisposeResourceEditor()
 {
     if (this.resourceEditor == null) return;
     this.RemovePropertyEditor(this.resourceEditor);
     this.resourceEditor.Dispose();
     this.resourceEditor = null;
     this.resourceType = null;
 }
 protected internal override void OnDragLeave(EventArgs e)
 {
     base.OnDragLeave(e);
     if (this.hoverEditor != null)
     {
         this.hoverEditor.OnDragLeave(e);
         this.hoverEditor = null;
     }
 }
        protected void UpdateHoverEditor(MouseEventArgs e)
        {
            PropertyEditor lastHoverEditor = this.hoverEditor;
            this.hoverEditor = this.PickEditorAt(e.X, e.Y, true);
            if (this.hoverEditor == this) this.hoverEditor = null;

            if (lastHoverEditor != this.hoverEditor && lastHoverEditor != null)
                lastHoverEditor.OnMouseLeave(EventArgs.Empty);
            if (lastHoverEditor != this.hoverEditor && this.hoverEditor != null)
            {
                // Indent expand button
                if (this.UseIndentChildExpand)
                {
                    foreach (PropertyEditor child in this.propertyEditors)
                    {
                        this.IndentChildExpandOnMouseLeave(EventArgs.Empty, child as GroupedPropertyEditor);
                    }
                }

                this.hoverEditor.OnMouseEnter(EventArgs.Empty);
            }
        }
 protected internal override void OnDragEnter(DragEventArgs e)
 {
     base.OnDragEnter(e);
     if (this.hoverEditorLock)
     {
         this.hoverEditorLock = false;
         this.hoverEditor = null;
     }
     e.Effect = e.AllowedEffect; // Accept anything to pass it on to children
 }
Exemple #14
0
 public virtual void ConfigureEditor(PropertyEditor editor, object configureData = null)
 {
     editor.ConfigureEditor(configureData);
 }
Exemple #15
0
 public ProviderContext(PropertyGrid grid, PropertyEditor editor = null)
 {
     this.parentEditor = editor;
     this.parentGrid   = editor != null ? editor.ParentGrid : grid;
 }
Exemple #16
0
            public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
            {
                PropertyEditor e = null;

                // Basic numeric data types
                if (baseType == typeof(sbyte) || baseType == typeof(byte) ||
                    baseType == typeof(short) || baseType == typeof(ushort) ||
                    baseType == typeof(int) || baseType == typeof(uint) ||
                    baseType == typeof(long) || baseType == typeof(ulong) ||
                    baseType == typeof(float) || baseType == typeof(double) || baseType == typeof(decimal))
                {
                    e = new NumericPropertyEditor();
                }
                // Basic data type: Boolean
                else if (baseType == typeof(bool))
                {
                    e = new BoolPropertyEditor();
                }
                // Basic data type: Flagged Enum
                else if (baseType.IsEnum && baseType.GetCustomAttributes(typeof(FlagsAttribute), true).Any())
                {
                    e = new FlaggedEnumPropertyEditor();
                }
                // Basic data type: Other Enums
                else if (baseType.IsEnum)
                {
                    e = new EnumPropertyEditor();
                }
                // Basic data type: String
                else if (baseType == typeof(string))
                {
                    e = new StringPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IList).IsAssignableFrom(baseType))
                {
                    e = new IListPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IDictionary).IsAssignableFrom(baseType))
                {
                    e = new IDictionaryPropertyEditor();
                }
                // Unknown data type
                else
                {
                    // Ask around if any sub-editor can handle it and choose the most specialized
                    var availSubProviders =
                        from p in this.subProviders
                        where p.IsResponsibleFor(baseType, context) != EditorPriority_None
                        orderby p.IsResponsibleFor(baseType, context) descending
                        select p;

                    IPropertyEditorProvider subProvider = availSubProviders.FirstOrDefault();
                    if (subProvider != null)
                    {
                        e            = subProvider.CreateEditor(baseType, context);
                        e.EditedType = baseType;
                        return(e);
                    }

                    // If not, default to reflection-driven MemberwisePropertyEditor.
                    // Except for MemberInfo types, since we can't edit them in any
                    // meaningful anyway, and they clutter up the grid.
                    if (typeof(MemberInfo).IsAssignableFrom(baseType))
                    {
                        e = new LabelPropertyEditor();
                    }
                    else
                    {
                        e = new MemberwisePropertyEditor();
                    }
                }

                e.EditedType = baseType;
                return(e);
            }
 public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason)
     : base(editor, value)
 {
     this.reason = reason;
 }
        protected internal override void OnDragOver(DragEventArgs e)
        {
            base.OnDragOver(e);
            PropertyEditor lastHoverEditor = this.hoverEditor;

            this.hoverEditor = this.PickEditorAt(e.X, e.Y, true);
            if (this.hoverEditor == this) this.hoverEditor = null;

            if (lastHoverEditor != this.hoverEditor && lastHoverEditor != null)
                lastHoverEditor.OnDragLeave(EventArgs.Empty);
            if (lastHoverEditor != this.hoverEditor && this.hoverEditor != null)
            {
                e.Effect = DragDropEffects.None;
                this.hoverEditor.OnDragEnter(e);
            }

            if (this.hoverEditor != null)
            {
                this.hoverEditor.OnDragOver(e);
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemple #19
0
 public PropertyEditorValueEventArgs(PropertyEditor editor, object value)
 {
     this.editor = editor;
     this.value  = value;
 }
        protected internal override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            if (this.hoverEditor != null)
            {
                PropertyEditor lastHoverEditor = this.hoverEditor;
                this.hoverEditor = null;

                if (lastHoverEditor != this.hoverEditor && lastHoverEditor != null)
                    lastHoverEditor.OnMouseLeave(EventArgs.Empty);
            }

            if (this.expandCheckHovered) this.Invalidate();
            if (this.activeCheckHovered) this.Invalidate();
            this.expandCheckHovered = false;
            this.expandCheckPressed = false;
            this.activeCheckHovered = false;
            this.activeCheckPressed = false;

            // Indent expand button
            if (this.UseIndentChildExpand)
            {
                foreach (PropertyEditor child in this.propertyEditors)
                {
                    this.IndentChildExpandOnMouseLeave(e, child as GroupedPropertyEditor);
                }
            }
        }
		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 void AddPropertyEditor(PropertyEditor editor, PropertyEditor before)
 {
     int atIndex = -1;
     if (before != null && before.ParentEditor == this)
     {
         int index = 0;
         foreach (PropertyEditor child in this.ChildEditors)
         {
             if (child == before)
             {
                 atIndex = index;
                 break;
             }
             ++index;
         }
     }
     this.AddPropertyEditor(editor, atIndex);
 }
        private void SetupChildEditors()
        {
            this.BeginUpdate();

            // Remove the old Resource editor if it doesn't match
            if (this.resourceEditor != null && this.resourceType != this.EditedType)
                this.DisposeResourceEditor();

            // Add a new Resource editor if we don't have one yet
            if (this.resourceEditor == null)
            {
                this.resourceType = this.EditedType;
                this.resourceEditor = this.ParentGrid.CreateEditor(this.EditedType, this);
                this.resourceEditor.Getter = this.GetValue;
                this.resourceEditor.Setter = v => {};
                this.ParentGrid.ConfigureEditor(this.resourceEditor);
                this.AddPropertyEditor(this.resourceEditor);

                // If the child editor is a grouped one, expand it immediately after adding
                // and hide the expand / collapse checkbox. We don't want to expose our wrapper
                // structure after all.
                GroupedPropertyEditor group = this.resourceEditor as GroupedPropertyEditor;
                if (group != null)
                {
                    group.Expanded = true;
                    group.Hints &= ~HintFlags.HasExpandCheck;
                }
            }

            // Set up a shared Asset editor that will be added or removed on demand
            if (this.assetEditor == null)
            {
                this.assetEditor = new ResourceAssetPropertyEditor();
                this.assetEditor.EditedType = this.EditedType; // Needs to match so the forwarded getter's safety check passes
                this.assetEditor.Getter = this.GetValue;
                this.assetEditor.Setter = v => {};
                this.ParentGrid.ConfigureEditor(this.assetEditor);
            }

            this.EndUpdate();
        }
        protected void AddPropertyEditor(PropertyEditor editor, int atIndex = -1)
        {
            if (this.propertyEditors.Contains(editor)) this.propertyEditors.Remove(editor);

            editor.ParentEditor = this;

            if (atIndex == -1)
                this.propertyEditors.Add(editor);
            else
                this.propertyEditors.Insert(atIndex, editor);

            GroupedPropertyEditor groupedEditor = editor as GroupedPropertyEditor;
            if (groupedEditor != null && groupedEditor.Expanded && !groupedEditor.ContentInitialized)
                groupedEditor.InitContent();

            this.OnEditorAdded(editor);
            this.UpdateChildGeometry();

            editor.ValueChanged += this.OnValueChanged;
            editor.EditingFinished += this.OnEditingFinished;
            editor.SizeChanged += this.child_SizeChanged;
        }
		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 = Properties.EditorBaseRes.PropertyName_OtherCollider;
					this.otherColEditor.PropertyDesc = Properties.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 void UpdateFrom(PropertyEditor mainEditor)
 {
     if (mainEditor == null) return;
     foreach (GroupedPropertyEditor child in mainEditor.ChildrenDeep.OfType<GroupedPropertyEditor>())
         this.SetEditorExpanded(child, child.Expanded);
 }
        public PropertyEditor AddEditorForMember(MemberInfo member, IEnumerable<object> values = null, PropertyEditor replaceOld = null)
        {
            if (!(member is FieldInfo) && !(member is PropertyInfo))
            {
                throw new ArgumentException("Only PropertyInfo and FieldInfo members are supported");
            }

            PropertyEditor e;
            Type editType = ReflectTypeForMember(member, values ?? this.GetValue());
            e = this.AutoCreateMemberEditor(member);
            if (e == null) e = this.ParentGrid.CreateEditor(editType, this);
            if (e == null) return null;

            e.BeginUpdate();
            {
                if (member is PropertyInfo)
                {
                    PropertyInfo property = member as PropertyInfo;
                    e.Getter = this.CreatePropertyValueGetter(property);
                    e.Setter = property.CanWrite ? this.CreatePropertyValueSetter(property) : null;
                    e.PropertyName = property.Name;
                    e.EditedMember = property;
                    e.NonPublic = !this.memberPredicate(property, false);
                }
                else if (member is FieldInfo)
                {
                    FieldInfo field = member as FieldInfo;
                    e.Getter = this.CreateFieldValueGetter(field);
                    e.Setter = this.CreateFieldValueSetter(field);
                    e.PropertyName = field.Name;
                    e.EditedMember = field;
                    e.NonPublic = !this.memberPredicate(field, false);
                }

                if (replaceOld != null)
                {
                    this.AddPropertyEditor(e, replaceOld);
                    this.RemovePropertyEditor(replaceOld);
                    replaceOld.Dispose();
                }
                else
                {
                    this.AddPropertyEditor(e);
                }
                this.ParentGrid.ConfigureEditor(e);
            }
            e.EndUpdate();

            return e;
        }
		protected override void OnEditorAdded(PropertyEditor editor)
		{
			base.OnEditorAdded(editor);
			this.UpdatePrefabModifiedState(editor);
		}
 protected bool HasPropertyEditor(PropertyEditor editor)
 {
     return this.propertyEditors.Contains(editor);
 }
        public PropertyEditor AddEditorForMember(MemberInfo member, IEnumerable <object> values = null, PropertyEditor replaceOld = null)
        {
            if (!(member is FieldInfo) && !(member is PropertyInfo))
            {
                throw new ArgumentException("Only PropertyInfo and FieldInfo members are supported");
            }

            PropertyEditor e;
            Type           editType = ReflectTypeForMember(member, values ?? this.GetValue());

            e = this.AutoCreateMemberEditor(member);
            if (e == null)
            {
                e = this.ParentGrid.CreateEditor(editType, this);
            }
            if (e == null)
            {
                return(null);
            }

            e.BeginUpdate();
            {
                if (member is PropertyInfo)
                {
                    PropertyInfo property = member as PropertyInfo;
                    e.Getter       = this.CreatePropertyValueGetter(property);
                    e.Setter       = property.CanWrite ? this.CreatePropertyValueSetter(property) : null;
                    e.PropertyName = property.Name;
                    e.EditedMember = property;
                    e.NonPublic    = !this.memberPredicate(property, false);
                }
                else if (member is FieldInfo)
                {
                    FieldInfo field = member as FieldInfo;
                    e.Getter       = this.CreateFieldValueGetter(field);
                    e.Setter       = this.CreateFieldValueSetter(field);
                    e.PropertyName = field.Name;
                    e.EditedMember = field;
                    e.NonPublic    = !this.memberPredicate(field, false);
                }

                if (replaceOld != null)
                {
                    this.AddPropertyEditor(e, replaceOld);
                    this.RemovePropertyEditor(replaceOld);
                    replaceOld.Dispose();
                }
                else
                {
                    this.AddPropertyEditor(e);
                }
                this.ParentGrid.ConfigureEditor(e);
            }
            e.EndUpdate();

            return(e);
        }
 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 virtual void OnEditorAdded(PropertyEditor e)
 {
     if (this.EditorAdded != null)
         this.EditorAdded(this, new PropertyEditorEventArgs(e));
 }
		protected override void OnEditorRemoving(PropertyEditor editor)
		{
			base.OnEditorRemoving(editor);
			this.UpdatePrefabModifiedState();
		}
 protected virtual void OnEditorRemoving(PropertyEditor e)
 {
     if (this.EditorRemoving != null)
         this.EditorRemoving(this, new PropertyEditorEventArgs(e));
 }
		public virtual MemberInfo MapEditorToMember(PropertyEditor editor)
		{
			return editor != null ? editor.EditedMember : null;
		}
        protected void RemovePropertyEditor(PropertyEditor editor)
        {
            editor.ParentEditor = null;
            editor.ValueChanged -= this.OnValueChanged;
            editor.EditingFinished -= this.OnEditingFinished;
            editor.SizeChanged -= this.child_SizeChanged;

            this.OnEditorRemoving(editor);
            this.propertyEditors.Remove(editor);
            this.UpdateChildGeometry();
        }
        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;
            }
        }
Exemple #38
0
 public PropertyEditorEventArgs(PropertyEditor e)
 {
     this.editor = e;
 }