Datei: Provider/MySqlConnectorProvider/MySqlConnectorUISupport/ConnectionDialog.cs
Last Commit (4b01a93)
| 1 | -- File didn't exist -- |
New Commit (e404055)
| 1 | // |
| 2 | // Copyright (c) 2002-2016 Mirko Matytschak |
| 3 | // (www.netdataobjects.de) |
| 4 | // |
| 5 | // Author: Mirko Matytschak |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
| 11 | // conditions: |
| 12 | |
| 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 14 | // of the Software. |
| 15 | // |
| 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | |
| 23 | using System; |
| 24 | using System.Text; |
| 25 | using System.Collections.Specialized; |
| 26 | using System.Drawing; |
| 27 | using System.Collections; |
| 28 | using System.ComponentModel; |
| 29 | using System.Windows.Forms; |
| 30 | |
| 31 | namespace MySqlUISupport |
| 32 | { |
| 33 | ····/// <summary> |
| 34 | ····/// Zusammenfassung für ConnectionDialog. |
| 35 | ····/// </summary> |
| 36 | ····internal class ConnectionDialog : System.Windows.Forms.Form |
| 37 | ····{ |
| 38 | ········private System.Windows.Forms.Label label1; |
| 39 | ········private System.Windows.Forms.Label label2; |
| 40 | ········private System.Windows.Forms.Label label3; |
| 41 | ········private System.Windows.Forms.Label label4; |
| 42 | ········private System.Windows.Forms.Button btnOK; |
| 43 | ········private System.Windows.Forms.Button btnCancel; |
| 44 | ········private System.Windows.Forms.TextBox txtDatabaseName; |
| 45 | ········private System.Windows.Forms.TextBox txtHost; |
| 46 | ········private System.Windows.Forms.TextBox txtUserName; |
| 47 | ········private System.Windows.Forms.TextBox txtPassword; |
| 48 | ········/// <summary> |
| 49 | ········/// Erforderliche Designervariable. |
| 50 | ········/// </summary> |
| 51 | ········private System.ComponentModel.Container components = null; |
| 52 | |
| 53 | ········NameValueCollection values = new NameValueCollection(); |
| 54 | |
| 55 | ········bool createDatabase; |
| 56 | |
| 57 | ········public ConnectionDialog(string connectionString, bool createDatabase) |
| 58 | ········{ |
| 59 | ············// |
| 60 | ············// Erforderlich für die Windows Form-Designerunterstützung |
| 61 | ············// |
| 62 | ············InitializeComponent(); |
| 63 | |
| 64 | ············this.createDatabase = createDatabase; |
| 65 | |
| 66 | ············if (connectionString != null) |
| 67 | ············{ |
| 68 | ················string[] arr = connectionString.Split(';'); |
| 69 | ················foreach(string s in arr) |
| 70 | ················{ |
| 71 | ····················if (s.Trim() == string.Empty) |
| 72 | ························continue; |
| 73 | ····················string[] arr2 = s.Split('='); |
| 74 | ····················if (arr2[1].Trim().Length > 0) |
| 75 | ························values.Add(arr2[0].Trim(), arr2[1].Trim()); |
| 76 | ····················object o; |
| 77 | ····················if ((o = values["Database"]) != null) |
| 78 | ························this.txtDatabaseName.Text = (string) o; |
| 79 | ····················if ((o = values["Password"]) != null) |
| 80 | ························this.txtPassword.Text = (string) o; |
| 81 | ····················if ((o = values["Data Source"]) != null) |
| 82 | ························this.txtHost.Text = (string) o; |
| 83 | ····················if ((o = values["User Id"]) != null) |
| 84 | ························this.txtUserName.Text = (string) o; |
| 85 | ················} |
| 86 | ············} |
| 87 | ········} |
| 88 | |
| 89 | ········public string Database |
| 90 | ········{ |
| 91 | ············get { return this.txtDatabaseName.Text; } |
| 92 | ········} |
| 93 | |
| 94 | ········public string ConnectionString |
| 95 | ········{ |
| 96 | ············get |
| 97 | ············{ |
| 98 | ················StringBuilder sb = new StringBuilder(); |
| 99 | ················if (!this.createDatabase && this.txtDatabaseName.Text.Trim() != string.Empty) |
| 100 | ················{ |
| 101 | ····················sb.Append("Database="); |
| 102 | ····················sb.Append(this.txtDatabaseName.Text); |
| 103 | ····················sb.Append(';'); |
| 104 | ················} |
| 105 | ················if (this.txtHost.Text.Trim() != string.Empty) |
| 106 | ················{ |
| 107 | ····················sb.Append("Data Source="); |
| 108 | ····················sb.Append(this.txtHost.Text); |
| 109 | ····················sb.Append(';'); |
| 110 | ················} |
| 111 | ················if (this.txtUserName.Text.Trim() != string.Empty) |
| 112 | ················{ |
| 113 | ····················sb.Append("User Id="); |
| 114 | ····················sb.Append(this.txtUserName.Text); |
| 115 | ····················sb.Append(';'); |
| 116 | ················} |
| 117 | ················if (this.txtPassword.Text.Trim() != string.Empty) |
| 118 | ················{ |
| 119 | ····················sb.Append("Password="); |
| 120 | ····················sb.Append(this.txtPassword.Text); |
| 121 | ····················sb.Append(';'); |
| 122 | ················} |
| 123 | ················return sb.ToString(); |
| 124 | ············} |
| 125 | ········} |
| 126 | |
| 127 | |
| 128 | ········/// <summary> |
| 129 | ········/// Die verwendeten Ressourcen bereinigen. |
| 130 | ········/// </summary> |
| 131 | ········protected override void Dispose( bool disposing ) |
| 132 | ········{ |
| 133 | ············if( disposing ) |
| 134 | ············{ |
| 135 | ················if(components != null) |
| 136 | ················{ |
| 137 | ····················components.Dispose(); |
| 138 | ················} |
| 139 | ············} |
| 140 | ············base.Dispose( disposing ); |
| 141 | ········} |
| 142 | |
| 143 | ········#region Vom Windows Form-Designer generierter Code |
| 144 | ········/// <summary> |
| 145 | ········/// Erforderliche Methode für die Designerunterstützung. |
| 146 | ········/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. |
| 147 | ········/// </summary> |
| 148 | ········private void InitializeComponent() |
| 149 | ········{ |
| 150 | ············System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ConnectionDialog)); |
| 151 | ············this.label1 = new System.Windows.Forms.Label(); |
| 152 | ············this.label2 = new System.Windows.Forms.Label(); |
| 153 | ············this.label3 = new System.Windows.Forms.Label(); |
| 154 | ············this.label4 = new System.Windows.Forms.Label(); |
| 155 | ············this.btnOK = new System.Windows.Forms.Button(); |
| 156 | ············this.btnCancel = new System.Windows.Forms.Button(); |
| 157 | ············this.txtDatabaseName = new System.Windows.Forms.TextBox(); |
| 158 | ············this.txtHost = new System.Windows.Forms.TextBox(); |
| 159 | ············this.txtUserName = new System.Windows.Forms.TextBox(); |
| 160 | ············this.txtPassword = new System.Windows.Forms.TextBox(); |
| 161 | ············this.SuspendLayout(); |
| 162 | ············// |
| 163 | ············// label1 |
| 164 | ············// |
| 165 | ············this.label1.Location = new System.Drawing.Point(8, 16); |
| 166 | ············this.label1.Name = "label1"; |
| 167 | ············this.label1.Size = new System.Drawing.Size(136, 24); |
| 168 | ············this.label1.TabIndex = 0; |
| 169 | ············this.label1.Text = "Database Name"; |
| 170 | ············// |
| 171 | ············// label2 |
| 172 | ············// |
| 173 | ············this.label2.Location = new System.Drawing.Point(8, 48); |
| 174 | ············this.label2.Name = "label2"; |
| 175 | ············this.label2.Size = new System.Drawing.Size(136, 24); |
| 176 | ············this.label2.TabIndex = 1; |
| 177 | ············this.label2.Text = "Host"; |
| 178 | ············// |
| 179 | ············// label3 |
| 180 | ············// |
| 181 | ············this.label3.Location = new System.Drawing.Point(8, 80); |
| 182 | ············this.label3.Name = "label3"; |
| 183 | ············this.label3.Size = new System.Drawing.Size(136, 24); |
| 184 | ············this.label3.TabIndex = 2; |
| 185 | ············this.label3.Text = "User Name"; |
| 186 | ············// |
| 187 | ············// label4 |
| 188 | ············// |
| 189 | ············this.label4.Location = new System.Drawing.Point(8, 112); |
| 190 | ············this.label4.Name = "label4"; |
| 191 | ············this.label4.Size = new System.Drawing.Size(136, 24); |
| 192 | ············this.label4.TabIndex = 3; |
| 193 | ············this.label4.Text = "Password"; |
| 194 | ············// |
| 195 | ············// btnOK |
| 196 | ············// |
| 197 | ············this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; |
| 198 | ············this.btnOK.Location = new System.Drawing.Point(312, 152); |
| 199 | ············this.btnOK.Name = "btnOK"; |
| 200 | ············this.btnOK.Size = new System.Drawing.Size(88, 32); |
| 201 | ············this.btnOK.TabIndex = 4; |
| 202 | ············this.btnOK.Text = "OK"; |
| 203 | ············// |
| 204 | ············// btnCancel |
| 205 | ············// |
| 206 | ············this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
| 207 | ············this.btnCancel.Location = new System.Drawing.Point(208, 152); |
| 208 | ············this.btnCancel.Name = "btnCancel"; |
| 209 | ············this.btnCancel.Size = new System.Drawing.Size(88, 32); |
| 210 | ············this.btnCancel.TabIndex = 5; |
| 211 | ············this.btnCancel.Text = "Cancel"; |
| 212 | ············// |
| 213 | ············// txtDatabaseName |
| 214 | ············// |
| 215 | ············this.txtDatabaseName.Location = new System.Drawing.Point(144, 16); |
| 216 | ············this.txtDatabaseName.Name = "txtDatabaseName"; |
| 217 | ············this.txtDatabaseName.Size = new System.Drawing.Size(256, 22); |
| 218 | ············this.txtDatabaseName.TabIndex = 6; |
| 219 | ············this.txtDatabaseName.Text = ""; |
| 220 | ············// |
| 221 | ············// txtHost |
| 222 | ············// |
| 223 | ············this.txtHost.Location = new System.Drawing.Point(144, 48); |
| 224 | ············this.txtHost.Name = "txtHost"; |
| 225 | ············this.txtHost.Size = new System.Drawing.Size(256, 22); |
| 226 | ············this.txtHost.TabIndex = 7; |
| 227 | ············this.txtHost.Text = "localhost"; |
| 228 | ············// |
| 229 | ············// txtUserName |
| 230 | ············// |
| 231 | ············this.txtUserName.Location = new System.Drawing.Point(144, 80); |
| 232 | ············this.txtUserName.Name = "txtUserName"; |
| 233 | ············this.txtUserName.Size = new System.Drawing.Size(256, 22); |
| 234 | ············this.txtUserName.TabIndex = 8; |
| 235 | ············this.txtUserName.Text = "root"; |
| 236 | ············// |
| 237 | ············// txtPassword |
| 238 | ············// |
| 239 | ············this.txtPassword.Location = new System.Drawing.Point(144, 112); |
| 240 | ············this.txtPassword.Name = "txtPassword"; |
| 241 | ············this.txtPassword.Size = new System.Drawing.Size(256, 22); |
| 242 | ············this.txtPassword.TabIndex = 9; |
| 243 | ············this.txtPassword.Text = ""; |
| 244 | ············// |
| 245 | ············// ConnectionDialog |
| 246 | ············// |
| 247 | ············this.AcceptButton = this.btnOK; |
| 248 | ············this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); |
| 249 | ············this.CancelButton = this.btnCancel; |
| 250 | ············this.ClientSize = new System.Drawing.Size(416, 192); |
| 251 | ············this.Controls.Add(this.txtPassword); |
| 252 | ············this.Controls.Add(this.txtUserName); |
| 253 | ············this.Controls.Add(this.txtHost); |
| 254 | ············this.Controls.Add(this.txtDatabaseName); |
| 255 | ············this.Controls.Add(this.btnCancel); |
| 256 | ············this.Controls.Add(this.btnOK); |
| 257 | ············this.Controls.Add(this.label4); |
| 258 | ············this.Controls.Add(this.label3); |
| 259 | ············this.Controls.Add(this.label2); |
| 260 | ············this.Controls.Add(this.label1); |
| 261 | ············this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); |
| 262 | ············this.Name = "ConnectionDialog"; |
| 263 | ············this.Text = "MySQL Connection Dialog"; |
| 264 | ············this.ResumeLayout(false); |
| 265 | |
| 266 | ········} |
| 267 | ········#endregion |
| 268 | ····} |
| 269 | } |
| 270 |