I implemented a type converter for RadPropertyGrid but it's not working.
As can be seen in the attached 'winform property grid', if a line is selected then the 'linetype' cell displays the types for various lines.
I implemented the type converter for this as the below code, but it seems RadPropertyGrid doesn't recognize it.
Can this be fixed? And can you inform me any other fundamental limits of RadPropertyGrid compared to Winform property grid?
[TypeConverter(typeof(LineTypeConverterNoExpand)), GlobalizedCategory("Misc"), GlobalizedDisplayName("LineType"), GlobalizedDescription("Get/Set the vdLinetype object that the vdFigure will be drawn with."), ScriptSerialize]
public vdLineType LineType
{
get
{
return this.mLineType;
}
set
{
if ((this.mLineType != value) && base.RaiseOnBeforeModify("LineType", value))
{
if ((!this.Deleted && (value != null)) && value.Deleted)
{
value.Deleted = false;
}
base.AddHistory("LineType", value);
this.mLineType = value;
base.RaiseOnAfterModify("LineType");
}
}
}
namespace VectorDraw.Professional.vdPrimaries
{
using System;
using System.ComponentModel;
using System.Globalization;
using VectorDraw.Professional.Utilities;
using VectorDraw.Professional.vdObjects;
public class LineTypeConverterNoExpand : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (context == null)
{
return false;
}
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
{
try
{
string name = (string) value;
vdDocument document = TypeConverterUtilities.getDocument(context);
object solid = null;
if (document != null)
{
solid = document.LineTypes.FindName(name);
}
if (solid == null)
{
solid = document.LineTypes.Solid;
}
return solid;
}
catch
{
throw new NotSupportedException("Can not convert '" + ((string) value) + "' to type LineType");
}
}
return base.ConvertFrom(context, culture, value);
}
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
vdDocument document = TypeConverterUtilities.getDocument(context);
if (document == null)
{
return new TypeConverter.StandardValuesCollection(new string[0]);
}
return new TypeConverter.StandardValuesCollection(document.LineTypes.GetNotDeletedItemsAndVisibleOnForms());
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
}