Browse Source

PropertyGrid: added color editor.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
2043db6035
  1. 1
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ColorEditor.cs
  2. 37
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs

1
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ColorEditor.cs

@ -1,4 +1,5 @@
using System;
using Microsoft.Windows.Controls.Core.Converters;
namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{

37
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs

@ -67,7 +67,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid
if (Properties != null)
Properties.Filter(newValue);
}
#endregion //Filter
#region IsCategorized
@ -133,13 +133,15 @@ namespace Microsoft.Windows.Controls.PropertyGrid
protected virtual void OnSelectedObjectChanged(object oldValue, object newValue)
{
SetSelectedObjectNameBinding(newValue);
SelectedObjectType = newValue.GetType();
_propertyItemsCache = GetObjectProperties(newValue);
InitializePropertyGrid(IsCategorized);
if (newValue == null)
ResetPropertyGrid();
else
{
SetSelectedObjectNameBinding(newValue);
SelectedObjectType = newValue.GetType();
_propertyItemsCache = GetObjectProperties(newValue);
InitializePropertyGrid(IsCategorized);
}
}
#endregion //SelectedObject
@ -162,8 +164,13 @@ namespace Microsoft.Windows.Controls.PropertyGrid
protected virtual void OnSelectedObjectTypeChanged(Type oldValue, Type newValue)
{
DisplayNameAttribute displayNameAttribute = newValue.GetCustomAttributes(false).OfType<DisplayNameAttribute>().FirstOrDefault();
SelectedObjectTypeName = displayNameAttribute == null ? newValue.Name : displayNameAttribute.DisplayName;
if (newValue == null)
SelectedObjectTypeName = string.Empty;
else
{
DisplayNameAttribute displayNameAttribute = newValue.GetCustomAttributes(false).OfType<DisplayNameAttribute>().FirstOrDefault();
SelectedObjectTypeName = displayNameAttribute == null ? newValue.Name : displayNameAttribute.DisplayName;
}
}
#endregion //SelectedObjectType
@ -407,6 +414,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid
editor = new IntegerUpDownEditor();
else if (propertyItem.PropertyType == typeof(DateTime))
editor = new DateTimeUpDownEditor();
else if ((propertyItem.PropertyType == typeof(Color)))
editor = new ColorEditor();
else if (propertyItem.PropertyType.IsEnum)
editor = new EnumComboBoxEditor();
else if (propertyItem.PropertyType == typeof(FontFamily) || propertyItem.PropertyType == typeof(FontWeight) || propertyItem.PropertyType == typeof(FontStyle) || propertyItem.PropertyType == typeof(FontStretch))
@ -464,6 +473,14 @@ namespace Microsoft.Windows.Controls.PropertyGrid
_dragThumb.Margin = new Thickness(-1, 0, 0, 0);
}
private void ResetPropertyGrid()
{
SelectedObjectName = String.Empty;
SelectedObjectType = null;
_propertyItemsCache = null;
Properties = null;
}
#endregion //Methods
}
}

Loading…
Cancel
Save