Exemple #1
0
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     string[] ps    = Enum.GetNames(typeof(PrecisionType));
     string[] names = new string[ps.Length];
     for (int i = 0; i < ps.Length; i++)
     {
         names[i] = EnumItemDescAttribute.GetDisplayValue(ps[i], typeof(PrecisionType), Thread.CurrentThread.CurrentUICulture);
     }
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(names);
     return(svc);
 }
Exemple #2
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         string[] ps = Enum.GetNames(typeof(PrecisionType));
         foreach (string p in ps)
         {
             if (value.ToString() == p)
             {
                 return(EnumItemDescAttribute.GetDisplayValue(value.ToString(), typeof(PrecisionType), Thread.CurrentThread.CurrentUICulture));
             }
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemple #3
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            PrecisionType name = PrecisionType.None;

            if (value.GetType() == typeof(string))
            {
                string[] ps = Enum.GetNames(typeof(PrecisionType));
                foreach (string p in ps)
                {
                    if (EnumItemDescAttribute.GetDisplayValue(p, typeof(PrecisionType), Thread.CurrentThread.CurrentUICulture) == value.ToString())
                    {
                        name = (PrecisionType)Enum.Parse(typeof(PrecisionType), p);
                        break;
                    }
                }
            }
            return(name);
        }