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);
 }
Exemplo n.º 3
0
 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);
		}
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
        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;
		}
Exemplo n.º 10
0
		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();
		}
Exemplo n.º 11
0
		public virtual void ConfigureEditor(PropertyEditor editor, object configureData = null)
		{
			editor.ConfigureEditor(configureData);
		}
Exemplo n.º 12
0
 protected override void OnEditorRemoving(PropertyEditor editor)
 {
     base.OnEditorRemoving(editor);
     this.UpdatePrefabModifiedState();
 }
Exemplo n.º 13
0
 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;
		}
Exemplo n.º 15
0
 public virtual Point GetChildLocation(PropertyEditor child)
 {
     return(Point.Empty);
 }
Exemplo n.º 16
0
 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;
		}
Exemplo n.º 19
0
 public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason)
     : base(editor, value)
 {
     this.reason = reason;
 }
Exemplo n.º 20
0
 public virtual MemberInfo MapEditorToMember(PropertyEditor editor)
 {
     return editor != null ? editor.EditedMember : null;
 }
Exemplo n.º 21
0
		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;
		}
Exemplo n.º 22
0
 public void UpdateFrom(PropertyEditor mainEditor)
 {
     if (mainEditor == null) return;
     foreach (GroupedPropertyEditor child in mainEditor.ChildrenDeep.OfType<GroupedPropertyEditor>())
         this.SetEditorExpanded(child, child.Expanded);
 }
Exemplo n.º 23
0
		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);
		}
Exemplo n.º 24
0
        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);
		}
Exemplo n.º 26
0
 public PropertyEditorValueEventArgs(PropertyEditor editor, object value)
 {
     this.editor = editor;
     this.value  = value;
 }
Exemplo n.º 27
0
        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;
            }
        }
Exemplo n.º 28
0
		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;
		}
Exemplo n.º 29
0
		public ProviderContext(PropertyGrid grid, PropertyEditor editor = null)
		{
			this.parentEditor = editor;
			this.parentGrid = editor != null ? editor.ParentGrid : grid;
		}
Exemplo n.º 30
0
 protected override void OnEditorAdded(PropertyEditor editor)
 {
     base.OnEditorAdded(editor);
     this.UpdatePrefabModifiedState(editor);
 }
Exemplo n.º 31
0
 private static string GetEditorFullId(PropertyEditor editor)
 {
     if (editor == null) return "";
     string fullId = "";
     while (editor != null)
     {
         fullId = GetEditorId(editor) + "/" + fullId;
         editor = editor.ParentEditor;
     }
     return fullId;
 }
Exemplo n.º 32
0
		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();
		}
Exemplo n.º 33
0
		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();
		}
Exemplo n.º 34
0
 public PropertyEditorEventArgs(PropertyEditor e)
 {
     this.editor = e;
 }