Index: Core/Common/src/Core.Common.Gui/ExpandableArrayConverter.cs =================================================================== diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r05061cff6fc2d63d6be48e570153eb7909e01298 --- Core/Common/src/Core.Common.Gui/ExpandableArrayConverter.cs (.../ExpandableArrayConverter.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b) +++ Core/Common/src/Core.Common.Gui/ExpandableArrayConverter.cs (.../ExpandableArrayConverter.cs) (revision 05061cff6fc2d63d6be48e570153eb7909e01298) @@ -6,18 +6,78 @@ namespace Core.Common.Gui { /// - /// with modified conversion to string. + /// with modified conversion to string and shows as array + /// starting with index 1 instead of 0. /// public class ExpandableArrayConverter : ArrayConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { - if (destinationType == typeof(string) && value is Array) + var array = value as Array; + if (destinationType == typeof(string) && array != null) { - return string.Format(Resources.ExpandableArrayConverter_ConvertTo_Aantal_0_, ((Array) value).Length); + return string.Format(Resources.ExpandableArrayConverter_ConvertTo_Aantal_0_, array.GetLength(0)); } return base.ConvertTo(context, culture, value, destinationType); } + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + PropertyDescriptor[] properties = null; + var array = value as Array; + if (array != null) + { + int length = array.GetLength(0); + properties = new PropertyDescriptor[length]; + + Type type = array.GetType(); + Type elementType = type.GetElementType(); + for (int index = 0; index < length; ++index) + { + properties[index] = new ArrayPropertyDescriptor(type, elementType, index); + } + } + return new PropertyDescriptorCollection(properties); + } + + #region Nested Type: ArrayPropertyDescriptor + + /// + /// Array element property descriptor used by . + /// Properties are named based on their index + 1. + /// + private class ArrayPropertyDescriptor : SimplePropertyDescriptor + { + private readonly int index; + + /// + /// Initializes a new instance of the class. + /// + /// Type of the array. + /// Type of the elements in . + /// Index of the element corresponding with this property descriptor. + public ArrayPropertyDescriptor(Type arrayType, Type elementType, int elementIndex) + : base(arrayType, "[" + (elementIndex + 1) + "]", elementType, null) + { + index = elementIndex; + } + + public override object GetValue(object instance) + { + var array = (Array)instance; + return array.GetValue(index); + } + + public override void SetValue(object instance, object value) + { + var array = (Array)instance; + array.SetValue(value, index); + OnValueChanged(array, EventArgs.Empty); // This line is also available in the C# .Net version of this class + } + } + + #endregion + } } \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Tests.csproj =================================================================== diff -u -rcbb3c7e4f06665f1fc399e839bd0f370f8f13278 -r05061cff6fc2d63d6be48e570153eb7909e01298 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Tests.csproj (.../Core.Common.Gui.Tests.csproj) (revision cbb3c7e4f06665f1fc399e839bd0f370f8f13278) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Tests.csproj (.../Core.Common.Gui.Tests.csproj) (revision 05061cff6fc2d63d6be48e570153eb7909e01298) @@ -15,7 +15,7 @@ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) False UnitTest - false + false x86 @@ -42,6 +42,7 @@ + @@ -54,7 +55,7 @@ {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtils - +