2 using System.Drawing.Design;
3 using System.ComponentModel;
4 using System.Windows.Forms;
5 using System.Windows.Forms.Design;
7 namespace Npgsql.Design
10 /// An UITypeEditor that simply initializes a
11 /// ConnectionStringEditorForm if possible
13 internal class ConnectionStringEditor : UITypeEditor
16 /// Edits the Value of the given Object using the EditSyle given by GetEditStyle.
18 /// <param name="context">An ITypeDescriptorContext, through wich you can get additional context information.</param>
19 /// <param name="provider">An IServiceProvider, through which this editor may order services.</param>
20 /// <param name="value">The Object to edit</param>
21 /// <returns>The new value of the Object</returns>
22 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
24 if (context != null && context.Instance != null && provider != null) {
25 IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
28 ConnectionStringEditorForm eform;
30 if(value != null && value.ToString() != String.Empty) {
31 eform = new ConnectionStringEditorForm(value.ToString());
33 eform = new ConnectionStringEditorForm();
36 if(edSvc.ShowDialog(eform) == DialogResult.OK) {
37 return eform.ConnectionString;
50 /// Requests the EditSyle to be used by EditValue
52 /// <param name="context">An ITypeDescriptorContext, through wich you can get additional context information.</param>
53 /// <returns>An UITypeEditorEditStyle-Value, indicating the EditStyle used by EditValue. If UITypeEditor doesn't support this method, GetEditStyle returns the value None.</returns>
54 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
56 if (context != null && context.Instance != null) {
57 return UITypeEditorEditStyle.Modal;
60 return base.GetEditStyle (context);