/// <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)); }
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)); }
private void OnLoadingTypeConverter() { StandardValues = null; StandardValuesExclusive = false; //Populate properties using TypeConverter if (m_TypeConverter != null) { StandardValues = m_TypeConverter.GetStandardValues(); if (StandardValues != null && StandardValues.Count > 0) { StandardValuesExclusive = m_TypeConverter.GetStandardValuesExclusive(); } else { StandardValuesExclusive = false; } } }
/// <summary> /// Initializes a new instance of the <see cref="ValidatorTypeConverter"/> class. /// </summary> /// <param name="type">Can not be null.</param> /// <param name="typeConverter">Can be null to don't allow any conversion.</param> public ValidatorTypeConverter(Type type, TypeConverter typeConverter) : base(type) { this.typeConverter = typeConverter; // Populate properties using TypeConverter if (typeConverter != null) { StandardValues = typeConverter.GetStandardValues(); if (StandardValues != null && StandardValues.Count > 0) { StandardValuesExclusive = typeConverter.GetStandardValuesExclusive(); } else { StandardValuesExclusive = false; } } }
/// <summary> /// <para>Gets a collection of standard values for the data type this type converter is designed for.</para> /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { StandardValuesCollection values = _simpleTypeConverter.GetStandardValues(context); if (GetStandardValuesSupported(context) && values != null) { // Create a set of standard values around nullable instances. object[] wrappedValues = new object[values.Count + 1]; int idx = 0; wrappedValues[idx++] = null; foreach (object value in values) { wrappedValues[idx++] = value; } return(new StandardValuesCollection(wrappedValues)); } } 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 CheckStandardValues(object[] expected, TypeConverter conv) { TypeConverter.StandardValuesCollection values; values = conv.GetStandardValues(null); if (values == null && expected != null) { failed++; if (verbose > 0) { Console.WriteLine("{0}: GetStandardValues expected {0} values, got null", conv.ToString(), expected.Length); } return; } if (values != null && expected == null) { failed++; if (verbose > 0) { Console.WriteLine("{0}: GetStandardValues expected no values, got {1} values", conv.ToString(), values.Count); } return; } if (values != null) { if (values.Count != expected.Length) { if (verbose > 0) { Console.WriteLine("{0} GetStandardValues expected {1} values, returned {2}", conv.ToString(), expected.Length, values.Count); } failed++; } if (debug > 0) { Console.WriteLine("{0} Got {1} standard values", conv.ToString(), values.Count); } for (int i = 0; i < Math.Min(values.Count, expected.Length); i++) { if (debug > 0) { Console.WriteLine("{0}: Index {1:2} expecting:{2}, returned {3}", conv.ToString(), i, expected[i], values[i]); } if (!expected[i].Equals(values[i].ToString())) { if (verbose > 0) { Console.WriteLine("{0}: GetStandardValues Index {1} values don't match ({2} != {3})", conv.ToString(), i, expected[i], values[i]); } failed++; } } } }
/// <summary> /// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> 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> /// <returns> /// A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection"></see> that holds a standard set of valid values, or null if the data type does not support a standard set of values. /// </returns> public override StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return(baseTypeConverter.GetStandardValues(context)); }