/// <internalonly/> /// <devdoc> /// <para>Converts the given object to the reference type.</para> /// </devdoc> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); if (!String.Equals(text, "")) { if (context.Instance is System.Windows.Forms.Control) { System.Windows.Forms.Control tmp = (System.Windows.Forms.Control)context.Instance; System.Windows.Forms.Form frm = null; while (frm == null && tmp.Parent != null) { if (tmp.Parent is System.Windows.Forms.Form) { frm = (System.Windows.Forms.Form)tmp.Parent; } else { tmp = tmp.Parent; } } if (frm != null && frm is HKLabs.form3) { HKLabs.form3 f3 = (HKLabs.form3)frm; if (f3.AAA != null) { PropertyInfo[] p = f3.AAA.GetProperties(); foreach (PropertyInfo tmpP in p) { if (tmpP.CanWrite && tmpP.CanRead && tmpP.Name == text) { return(tmpP); } } } } } } return(null); } return(base.ConvertFrom(context, culture, value)); }
/// <internalonly/> /// <devdoc> /// <para>Gets a collection of standard values for the reference data type.</para> /// </devdoc> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { System.Collections.Generic.List <PropertyInfo> result = new Collections.Generic.List <PropertyInfo>(); if (context.Instance is System.Windows.Forms.Control) { System.Windows.Forms.Control tmp = (System.Windows.Forms.Control)context.Instance; System.Windows.Forms.Form frm = null; while (frm == null && tmp.Parent != null) { if (tmp.Parent is System.Windows.Forms.Form) { frm = (System.Windows.Forms.Form)tmp.Parent; } else { tmp = tmp.Parent; } } if (frm != null && frm is HKLabs.form3) { HKLabs.form3 f3 = (HKLabs.form3)frm; if (f3.AAA != null) { PropertyInfo[] p = f3.AAA.GetProperties(); foreach (PropertyInfo tmpP in p) { if (tmpP.CanWrite && tmpP.CanRead) { result.Add(tmpP); } } } } } result.Sort((p1, p2) => { return(String.Compare(p1.Name, p2.Name, false, CultureInfo.InvariantCulture)); }); return(new StandardValuesCollection(result.ToArray())); }