我有從StringConvertor類繼承videoformates類的哈希表。有兩個功能ConvertFrom
和ConvertTo
覆蓋那裏。這兩個函數如何將視頻合成器顯示爲字符串。propertyGrid與字符串轉換器中的hastable繼承類
public class VideoFormate : StringConverter
{
private Hashtable VideoFormates;
public VideoFormate() {
VideoFormates = new Hashtable();
VideoFormates[".3g2"] = "3GPP2";
VideoFormates[".3gp"] = "3GPP";
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(VideoFormates);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
類視頻屬性是
class videoProperties
{
private string _VideoFormat;
[TypeConverter(typeof(VideoFormate)),
CategoryAttribute("Video Setting"),
DefaultValueAttribute(0),
DescriptionAttribute("Select a Formate from the list")]
public string VideoFormat
{
get { return _VideoFormat; }
set { _VideoFormat = value; }
}
}
我想顯示3GPP2作爲顯示部件和.3gp2如在PropertyGrid中組合框中值構件。
1)這是.NET 1.1嗎? 2)理想的轉換應該如何?用戶應該看到什麼值 - 「.3g2」或「3GPP2」? 'videoProperties.VideoFormat'應該包含什麼值? – Dennis
泰克你問。 .NET 2,用戶看起來像「3GPP2」,並且'videoProperties.VideoFormat'中包含的值是.3gp2 – Abubakar