Пример #1
0
 /// <summary>
 /// Gets a value indicating whether this converter can convert an object in the
 /// given source type to a Uri.
 /// </summary>
 public override bool CanConvertFrom(ITypeDescriptorContext?context, Type sourceType)
 {
     return(sourceType == typeof(string) || sourceType == typeof(Uri) || base.CanConvertFrom(context, sourceType));
 }
 public override bool GetStandardValuesExclusive(ITypeDescriptorContext?context) => false;
Пример #3
0
 public override bool CanConvertFrom(ITypeDescriptorContext?context, Type sourceType)
 => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
Пример #4
0
 /// <summary>
 /// Converts the given string to the converter's native type using the invariant culture.
 /// </summary>
 public object?ConvertFromInvariantString(ITypeDescriptorContext?context, string text)
 {
     return(ConvertFromString(context, CultureInfo.InvariantCulture, text));
 }
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext?context) => new(Icon.KnownMimeTypes);
Пример #6
0
 /// <summary>
 /// Gets a collection of standard values for the data type this type converter is designed for.
 /// </summary>
 public virtual StandardValuesCollection?GetStandardValues(ITypeDescriptorContext?context) => null;
Пример #7
0
 /// <summary>
 /// Gets a value indicating whether this object supports a standard set of values that can be picked
 /// from a list using the specified context.
 /// </summary>
 public virtual bool GetStandardValuesSupported(ITypeDescriptorContext?context) => false;
Пример #8
0
 public override bool CanConvertTo(ITypeDescriptorContext?context, Type?destinationType) => destinationType == typeof(string);
Пример #9
0
 public override object?ConvertFrom(ITypeDescriptorContext?context, CultureInfo?culture, object value) => value switch
 {
Пример #10
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext?context, object?value, Attribute[]?attributes)
        {
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Rectangle), attributes);

            return(props.Sort(s_propertySort));
        }
Пример #11
0
 public override bool CanConvertTo(ITypeDescriptorContext?context, [NotNullWhen(true)] Type?destinationType)
 {
     return(destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType));
 }
Пример #12
0
 public override bool GetCreateInstanceSupported(ITypeDescriptorContext?context) => true;
Пример #13
0
 /// <summary>
 /// Converts the given value object to
 /// the specified destination type using the specified context and arguments.
 /// </summary>
 public override object ConvertTo(ITypeDescriptorContext?context, CultureInfo?culture, object?value, Type destinationType !!)
 {
     if (value is Uri uri)
Пример #14
0
 /// <summary>
 /// Gets a value indicating whether this converter can
 /// convert an object to the given destination type using the context.
 /// </summary>
 public override bool CanConvertTo(ITypeDescriptorContext?context, Type?destinationType)
 {
     return(destinationType == typeof(Uri) || destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType));
 }
Пример #15
0
 /// <summary>
 /// Gets a value indicating whether this object supports properties using the specified context.
 /// </summary>
 public virtual bool GetPropertiesSupported(ITypeDescriptorContext?context) => false;
Пример #16
0
 public override object?ConvertTo(ITypeDescriptorContext?context, CultureInfo?culture, object?value, Type destinationType) => value switch
 {
Пример #17
0
 /// <summary>
 /// Gets a value indicating whether this converter can convert an object in the given
 /// source type to the native type of the converter using the context.
 /// </summary>
 public virtual bool CanConvertFrom(ITypeDescriptorContext?context, Type sourceType)
 => sourceType == typeof(InstanceDescriptor);
Пример #18
0
 /// <summary>
 /// Converts the specified value to a culture-invariant string representation.
 /// </summary>
 public string?ConvertToInvariantString(ITypeDescriptorContext?context, object?value)
 {
     return(ConvertToString(context, CultureInfo.InvariantCulture, value));
 }
Пример #19
0
 /// <summary>
 /// Gets a value indicating whether the collection of standard values returned from
 /// <see cref='System.ComponentModel.TypeConverter.GetStandardValues()'/> is an exclusive
 /// list of possible values, using the specified context.
 /// </summary>
 public virtual bool GetStandardValuesExclusive(ITypeDescriptorContext?context) => false;
Пример #20
0
 /// <summary>
 /// Converts the specified value to a string representation.
 /// </summary>
 public string?ConvertToString(ITypeDescriptorContext?context, CultureInfo?culture, object?value)
 {
     return((string?)ConvertTo(context, culture, value, typeof(string)));
 }
Пример #21
0
 /// <summary>
 /// Gets a value indicating whether this converter can convert an object to the given
 /// destination type using the context.
 /// </summary>
 public virtual bool CanConvertTo(ITypeDescriptorContext?context, [NotNullWhen(true)] Type?destinationType)
 {
     return(destinationType == typeof(string));
 }
Пример #22
0
 /// <summary>
 /// Re-creates an <see cref='object'/> given a set of property values for the object.
 /// </summary>
 public virtual object?CreateInstance(ITypeDescriptorContext?context, IDictionary propertyValues) => null;
Пример #23
0
 /// <summary>
 /// Converts the specified text into an object.
 /// </summary>
 public object?ConvertFromString(ITypeDescriptorContext?context, CultureInfo?culture, string text)
 {
     return(ConvertFrom(context, culture, text));
 }
Пример #24
0
 /// <summary>
 ///
 /// Gets a value indicating whether changing a value on this object requires a call to
 /// <see cref='System.ComponentModel.TypeConverter.CreateInstance(IDictionary)'/> to create a new value,
 /// using the specified context.
 ///
 /// </summary>
 public virtual bool GetCreateInstanceSupported(ITypeDescriptorContext?context) => false;
 public override bool GetStandardValuesSupported(ITypeDescriptorContext?context) => true;
Пример #26
0
 public PropertyDescriptorCollection?GetProperties(ITypeDescriptorContext?context, object value)
 {
     return(GetProperties(context, value, new Attribute[] { BrowsableAttribute.Yes }));
 }
Пример #27
0
        /// <summary>
        ///  Retrieves a collection containing a set of standard values for the data type this validator is designed for.
        /// </summary>
        /// <param name="context">
        ///  An object that provides a format context, which can be used to extract additional
        ///  information about the environment this type converter is being invoked from.
        ///  This parameter or its properties can be <see langword="null" />.
        /// </param>
        /// <returns>
        ///  A collection that holds a standard set of valid index values.If no image list is found,
        ///  this collection contains a single object with a value of -1. This method returns<see langword="null" />
        ///  if the data type doesn't support a standard set of values.
        /// </returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext?context)
        {
            if (context is not null && context.Instance is not null)
            {
                object instance = context.Instance;

                ImageList?imageList = null;

                PropertyDescriptorCollection listViewItemProps = TypeDescriptor.GetProperties(instance);
                PropertyDescriptor?          listViewProp      = listViewItemProps["ListView"];

                if (listViewProp is not null)
                {
                    // Grab the ListView property off of the TreeNode.
                    object?listViewInstance = listViewProp.GetValue(instance);

                    if (listViewInstance is not null)
                    {
                        // Get the ImageList property from the ListView and set it to be the currentImageList.
                        PropertyDescriptorCollection listViewProps             = TypeDescriptor.GetProperties(listViewInstance);
                        PropertyDescriptor?          listViewImageListProperty = listViewProps["StateImageList"];
                        if (listViewImageListProperty is not null)
                        {
                            imageList = (ImageList?)listViewImageListProperty.GetValue(listViewInstance);
                        }
                    }
                }

                if (imageList is not null)
                {
                    // Create array to contain standard values
                    object[] values;
                    int      nImages = imageList.Images.Count;
                    if (IncludeNoneAsStandardValue)
                    {
                        values          = new object[nImages + 1];
                        values[nImages] = ImageList.Indexer.DefaultIndex;
                    }
                    else
                    {
                        values = new object[nImages];
                    }

                    // Fill in the array
                    for (int i = 0; i < nImages; i++)
                    {
                        values[i] = i;
                    }

                    return(new StandardValuesCollection(values));
                }
            }

            if (IncludeNoneAsStandardValue)
            {
                return(new StandardValuesCollection(new object[] { ImageList.Indexer.DefaultIndex }));
            }
            else
            {
                return(new StandardValuesCollection(Array.Empty <object>()));
            }
        }
Пример #28
0
 public virtual PropertyDescriptorCollection?GetProperties(ITypeDescriptorContext?context, object value, Attribute[]?attributes)
 {
     return(null);
 }
Пример #29
0
 public override bool GetPropertiesSupported(ITypeDescriptorContext?context) => false;
Пример #30
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext?context, object value, Attribute[]?attributes)
        {
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Padding), attributes);

            return(props.Sort(new string[] { nameof(Padding.All), nameof(Padding.Left), nameof(Padding.Top), nameof(Padding.Right), nameof(Padding.Bottom) }));
        }