/// <returns>A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection" /> that holds a standard set of valid values, or null if the data type does not support a standard set of values.</returns> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null.</param> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (underlyingTypeConverter != null && underlyingTypeConverter.GetStandardValuesSupported(context)) { StandardValuesCollection standardValues = underlyingTypeConverter.GetStandardValues(context); if (standardValues != null) { ArrayList arrayList = new ArrayList(standardValues); arrayList.Add(null); return(new StandardValuesCollection(arrayList)); } } return(base.GetStandardValues(context)); }
/// <summary> /// <para> /// Gets a value indicating whether this object supports a standard set of values that can /// be picked from a list using the specified context. /// </para> /// </summary> public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { return(_simpleTypeConverter.GetStandardValuesSupported(context)); } return(base.GetStandardValuesSupported(context)); }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { // Adds a "null" values to the standard values if supported and available // if (underlyingTypeConverter != null && underlyingTypeConverter.GetStandardValuesSupported(context)) { TypeConverter.StandardValuesCollection values = underlyingTypeConverter.GetStandardValues(context); if (values != null) { ArrayList valuesWithNull = new ArrayList(values); valuesWithNull.Add(null); return(new TypeConverter.StandardValuesCollection(valuesWithNull)); } } return(base.GetStandardValues(context)); }
protected internal TypeEditorHostListBox( TypeConverter typeConverter, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle) : base(UITypeEditorEditStyle.DropDown, propertyDescriptor, instance, editControlStyle) { _typeConverter = typeConverter; // UNDONE: currently, this class only supports exclusive values. // create the list box _listBox = new ListBox { BorderStyle = BorderStyle.None }; _listBox.MouseUp += OnDropDownMouseUp; _listBox.BackColor = VSColorTheme.GetThemedColor(EnvironmentColors.ComboBoxBackgroundColorKey); _listBox.ForeColor = VSColorTheme.GetThemedColor(EnvironmentColors.ComboBoxTextColorKey); if (_typeConverter != null && _typeConverter.GetStandardValuesSupported(this)) { // populate it with values from the type converter foreach (var value in _typeConverter.GetStandardValues()) { _listBox.Items.Add(value); } } // set list box as the drop control SetComponent(_listBox); }
public void CheckStandardValuesSupported(bool expect, TypeConverter conv) { bool result; result = conv.GetStandardValuesSupported(null); if (result != expect) { failed++; if (verbose > 0) { Console.WriteLine("{0}: GetStandardValuesSupported expected {1}, returned {2}", conv.ToString(), expect, result); } } }
/// <summary> /// Returns whether this object supports a standard set of values that can be picked from a list, using the specified context. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param> /// <returns> /// true if <see cref="M:System.ComponentModel.TypeConverter.GetStandardValues"></see> should be called to find a common set of values the object supports; otherwise, <c>false</c>. /// </returns> public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return(baseTypeConverter.GetStandardValuesSupported(context)); }