Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Experiments / Attic / Generator / Castle.ActiveRecord.Generator / Dialogs / DatabaseConnectionDialog.cs
blob9bfad425e2db945c36727bbc1e415b3124088702
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord.Generator.Dialogs
17 using System;
18 using System.Drawing;
19 using System.Collections;
20 using System.ComponentModel;
21 using System.Windows.Forms;
23 /// <summary>
24 /// Summary description for DatabaseConnectionDialog.
25 /// </summary>
26 public class DatabaseConnectionDialog : System.Windows.Forms.Form
28 private System.Windows.Forms.Button button1;
29 private System.Windows.Forms.Button button2;
30 private System.Windows.Forms.Label label1;
31 private System.Windows.Forms.TextBox textBox1;
32 private System.Windows.Forms.Label label2;
33 private System.Windows.Forms.Button button3;
34 private System.Windows.Forms.TextBox connectionString;
35 /// <summary>
36 /// Required designer variable.
37 /// </summary>
38 private System.ComponentModel.Container components = null;
40 public DatabaseConnectionDialog()
43 // Required for Windows Form Designer support
45 InitializeComponent();
48 // TODO: Add any constructor code after InitializeComponent call
51 #if DEBUG
52 // textBox1.Text = "MyAlias";
53 // connectionString.Text = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test;Data Source=.";
54 #endif
57 /// <summary>
58 /// Clean up any resources being used.
59 /// </summary>
60 protected override void Dispose( bool disposing )
62 if( disposing )
64 if(components != null)
66 components.Dispose();
69 base.Dispose( disposing );
72 #region Windows Form Designer generated code
73 /// <summary>
74 /// Required method for Designer support - do not modify
75 /// the contents of this method with the code editor.
76 /// </summary>
77 private void InitializeComponent()
79 this.button1 = new System.Windows.Forms.Button();
80 this.button2 = new System.Windows.Forms.Button();
81 this.label1 = new System.Windows.Forms.Label();
82 this.textBox1 = new System.Windows.Forms.TextBox();
83 this.connectionString = new System.Windows.Forms.TextBox();
84 this.label2 = new System.Windows.Forms.Label();
85 this.button3 = new System.Windows.Forms.Button();
86 this.SuspendLayout();
87 //
88 // button1
89 //
90 this.button1.Location = new System.Drawing.Point(360, 160);
91 this.button1.Name = "button1";
92 this.button1.TabIndex = 4;
93 this.button1.Text = "OK";
94 this.button1.Click += new System.EventHandler(this.button1_Click);
95 //
96 // button2
97 //
98 this.button2.Location = new System.Drawing.Point(272, 160);
99 this.button2.Name = "button2";
100 this.button2.TabIndex = 1;
101 this.button2.Text = "Cancel";
102 this.button2.Click += new System.EventHandler(this.button2_Click);
104 // label1
106 this.label1.Location = new System.Drawing.Point(16, 24);
107 this.label1.Name = "label1";
108 this.label1.TabIndex = 0;
109 this.label1.Text = "Alias:";
110 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
112 // textBox1
114 this.textBox1.Location = new System.Drawing.Point(128, 24);
115 this.textBox1.Name = "textBox1";
116 this.textBox1.Size = new System.Drawing.Size(160, 21);
117 this.textBox1.TabIndex = 1;
118 this.textBox1.Text = "";
120 // connectionString
122 this.connectionString.Location = new System.Drawing.Point(128, 64);
123 this.connectionString.Name = "connectionString";
124 this.connectionString.Size = new System.Drawing.Size(272, 21);
125 this.connectionString.TabIndex = 3;
126 this.connectionString.Text = "";
128 // label2
130 this.label2.Location = new System.Drawing.Point(16, 64);
131 this.label2.Name = "label2";
132 this.label2.TabIndex = 2;
133 this.label2.Text = "Connection String:";
134 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
136 // button3
138 this.button3.Location = new System.Drawing.Point(408, 64);
139 this.button3.Name = "button3";
140 this.button3.Size = new System.Drawing.Size(24, 23);
141 this.button3.TabIndex = 6;
142 this.button3.Text = "...";
143 this.button3.Click += new System.EventHandler(this.button3_Click);
145 // DatabaseConnectionDialog
147 this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
148 this.ClientSize = new System.Drawing.Size(448, 194);
149 this.Controls.Add(this.button3);
150 this.Controls.Add(this.connectionString);
151 this.Controls.Add(this.textBox1);
152 this.Controls.Add(this.label2);
153 this.Controls.Add(this.label1);
154 this.Controls.Add(this.button2);
155 this.Controls.Add(this.button1);
156 this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
157 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
158 this.MaximizeBox = false;
159 this.Name = "DatabaseConnectionDialog";
160 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
161 this.Text = "Add Database Connection";
162 this.ResumeLayout(false);
165 #endregion
167 private void button3_Click(object sender, System.EventArgs e)
169 MSDASC.DataLinks dataLinks = new MSDASC.DataLinksClass();
170 ADODB._Connection connection;
172 if (connectionString.Text == String.Empty)
176 connection = (ADODB._Connection) dataLinks.PromptNew();
178 connectionString.Text = connection.ConnectionString.ToString();
180 catch (Exception ex)
182 MessageBox.Show(ex.ToString());
185 else
187 connection = new ADODB.ConnectionClass();
188 connection.ConnectionString = connectionString.Text;
190 object oConnection = connection;
194 if (dataLinks.PromptEdit(ref oConnection))
196 connectionString.Text = connection.ConnectionString;
199 catch (Exception ex)
201 MessageBox.Show(ex.ToString());
206 private void button2_Click(object sender, System.EventArgs e)
208 DialogResult = DialogResult.Cancel;
209 this.Close();
212 private void button1_Click(object sender, System.EventArgs e)
214 // TODO: Validate fields
216 DialogResult = DialogResult.OK;
217 this.Close();
220 public String Alias
222 get { return textBox1.Text; }
225 public String ConnectionString
227 get { return connectionString.Text; }