/// <summary> /// Executes the convertion. /// </summary> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { try { DataHelperBindingInfo dh = null; if (destinationType == typeof(InstanceDescriptor) && value is DataHelperBindingInfo) { dh = (DataHelperBindingInfo)value; ConstructorInfo ctor = typeof(DataHelperBindingInfo).GetConstructor(new Type[] { typeof(DataHelper), typeof(KeyValuePair <string, string>[]) }); if (ctor != null) { return(new InstanceDescriptor(ctor, new object[] { dh.BindingControl, dh.BindingParameters.ToArray() })); } } if (destinationType == typeof(string) && value is DataHelperBindingInfo) { dh = (DataHelperBindingInfo)value; if (dh.BindingControl != null) { return(dh.BindingControl.Text + " [" + dh.BindingControl.Name + "]"); } else { return(""); } } } catch { } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Constructor of the Modal View window to edit the value of the property. /// It receives the current instance (if one is set) and /// the context so it can obtain extra information. /// </summary> /// <param name="dataHelperBindingInfo"></param> /// <param name="context"></param> public DataHelperDesignerModalView(DataHelperBindingInfo dataHelperBindingInfo, ITypeDescriptorContext context) { InitializeComponent(); this._dataHelperBindingInfo = dataHelperBindingInfo; this.context = context; LoadListOfDataHelpers(); InitPropertyGrid(); }
/// <summary> /// Constructor of the Modal View window to edit the value of the property. /// It receives the current instance (if one is set) and /// the context so it can obtain extra information. /// </summary> /// <param name="dataHelperBindingInfo"></param> /// <param name="context"></param> public DataHelperDesignerModalView(DataHelperBindingInfo dataHelperBindingInfo, ITypeDescriptorContext context) { InitializeComponent(); this._dataHelperBindingInfo = dataHelperBindingInfo; this.context = context; LoadListOfDataHelpers(); InitPropertyGrid(); }
/// <summary> /// To update the information edited so far if the Ok button has been set. /// </summary> private void DataHelperDesignerModalView_FormClosing(object sender, FormClosingEventArgs e) { List <KeyValuePair <string, string> > props = new List <KeyValuePair <string, string> >(); if (DialogResult == DialogResult.OK) { for (int i = 0; i < dbGridProperties.Rows.Count; i++) { props.Add(new KeyValuePair <string, string>(dbGridProperties[0, i].Value.ToString(), dbGridProperties[1, i].Value.ToString())); } if (DHComboBox.SelectedItem != null) { _dataHelperBindingInfo = new DataHelperBindingInfo((DataHelper)DHComboBox.SelectedItem, props.ToArray()); } else { _dataHelperBindingInfo = new DataHelperBindingInfo(null, props.ToArray()); } } }
/// <summary> /// To update the information edited so far if the Ok button has been set. /// </summary> private void DataHelperDesignerModalView_FormClosing(object sender, FormClosingEventArgs e) { List<KeyValuePair<string, string>> props = new List<KeyValuePair<string, string>>(); if (DialogResult == DialogResult.OK) { for (int i = 0; i < dbGridProperties.Rows.Count; i++) { props.Add(new KeyValuePair<string, string>(dbGridProperties[0, i].Value.ToString(), dbGridProperties[1, i].Value.ToString())); } if (DHComboBox.SelectedItem != null) _dataHelperBindingInfo = new DataHelperBindingInfo((DataHelper)DHComboBox.SelectedItem, props.ToArray()); else _dataHelperBindingInfo = new DataHelperBindingInfo(null, props.ToArray()); } }