Datei: NDOPackage/ConfigurationDialog.cs
Last Commit (e424d5f)
| 1 | // |
| 2 | // Copyright (c) 2002-2019 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.Linq; |
| 25 | using System.IO; |
| 26 | using System.Windows.Forms; |
| 27 | using MessageBox = System.Windows.Forms.MessageBox; |
| 28 | using Project = EnvDTE.Project; |
| 29 | using System.Diagnostics; |
| 30 | using Microsoft.VisualStudio.ComponentModelHost; |
| 31 | using NuGet.VisualStudio; |
| 32 | using NDO.UISupport; |
| 33 | using System.Drawing; |
| 34 | |
| 35 | #pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread |
| 36 | |
| 37 | namespace NDOVsPackage |
| 38 | { |
| 39 | ····/// <summary> |
| 40 | ····/// Summary description for ConfigurationDialog. |
| 41 | ····/// </summary> |
| 42 | ····internal class ConfigurationDialog : System.Windows.Forms.Form |
| 43 | ····{ |
| 44 | ········private System.ComponentModel.IContainer components; |
| 45 | |
| 46 | ········private Project project; |
| 47 | ········private System.Windows.Forms.ToolTip toolTip1; |
| 48 | ········private TabControl tabControl; |
| 49 | ········private TabPage tabPageGeneral; |
| 50 | ········private TextBox txtTargetMappingFileName; |
| 51 | ········private Label label1; |
| 52 | ········private CheckBox chkVerboseMode; |
| 53 | ········private TextBox txtSchemaVersion; |
| 54 | ········private Label label5; |
| 55 | ········private Button btnNewDatabase; |
| 56 | ········private Button btnSaveAs; |
| 57 | ········private Button btnPresetApp; |
| 58 | ········private TextBox txtDbOwner; |
| 59 | ········private TextBox txtConnectionString; |
| 60 | ········private Label label3; |
| 61 | ········private GroupBox groupBox1; |
| 62 | ········private CheckBox chkDropExistingElements; |
| 63 | ········private CheckBox chkGenerateFkConstraints; |
| 64 | ········private CheckBox chkIncludeTypecodes; |
| 65 | ········private RadioButton radioDefaultEncoding; |
| 66 | ········private RadioButton radioUtf8Encoding; |
| 67 | ········private Label label4; |
| 68 | ········private ComboBox cbSqlDialect; |
| 69 | ········private CheckBox chkGenerateSQLScript; |
| 70 | ········private CheckBox chkUseTimeStamps; |
| 71 | ········private CheckBox chkChangeEvents; |
| 72 | ········private Label label2; |
| 73 | ········private Button btnConnString; |
| 74 | ········private Button btnOK; |
| 75 | ········private Button btnPresetLibrary; |
| 76 | ········private Button btnCancel; |
| 77 | ········private CheckBox chkMappingNew; |
| 78 | ········private CheckBox chkActivateEnhancer; |
| 79 | ········private CheckBox chkActivateAddIn; |
| 80 | ········private TabPage tabPageAssemblies; |
| 81 | ········private Label label6; |
| 82 | ········private CheckedListBox chlbAssemblies; |
| 83 | ········private ProjectDescription projectDescription; |
| 84 | ········private Button btnInstallProvider; |
| 85 | ········private NDOReference[] references; |
| 86 | |
| 87 | ········public ConfigurationDialog(Project project, ProjectDescription projectDescription) |
| 88 | ········{ |
| 89 | ············try |
| 90 | ············{ |
| 91 | ················this.project = project; |
| 92 | ················this.projectDescription = projectDescription; |
| 93 | ················this.projectDescription.BuildReferences(); |
| 94 | ················this.projectDescription.FixDllState(); |
| 95 | ················InitializeComponent(); |
| 96 | if ( Screen. FromControl( this ) . Bounds. Width >= 2600) |
| 97 | Font = new Font( "Segoe UI", 11f, FontStyle. Regular, GraphicsUnit. Point, 0 ) ; |
| 98 | ················var lbAssemblies = (ListBox)this.chlbAssemblies; |
| 99 | ················this.references = projectDescription.References.Values.ToArray(); |
| 100 | ················lbAssemblies.DataSource = this.references; |
| 101 | ················lbAssemblies.DisplayMember = nameof( NDOReference.Name ); |
| 102 | ················lbAssemblies.ValueMember = nameof( NDOReference.CheckState ); |
| 103 | ················int i = 0; |
| 104 | ················foreach (var item in this.references) |
| 105 | ················{ |
| 106 | ····················this.chlbAssemblies.SetItemCheckState( i++, item.CheckState ); |
| 107 | ················} |
| 108 | ············} |
| 109 | ············catch (Exception ex) |
| 110 | ············{ |
| 111 | ················Debug.WriteLine( ex.ToString() ); |
| 112 | ············} |
| 113 | ········} |
| 114 | |
| 115 | ········void CheckEnabledStateForLoadProviderButton() |
| 116 | ········{ |
| 117 | ············string providerName = this.cbSqlDialect.Text; |
| 118 | |
| 119 | ············if (string.IsNullOrEmpty( providerName )) |
| 120 | ············{ |
| 121 | ················this.btnInstallProvider.Enabled = false; |
| 122 | ················return; |
| 123 | ············} |
| 124 | |
| 125 | ············if (IsProviderInstalled(providerName)) |
| 126 | ············{ |
| 127 | ················this.btnInstallProvider.Enabled = false; |
| 128 | ················return; |
| 129 | ············} |
| 130 | |
| 131 | ············this.btnInstallProvider.Enabled = true; |
| 132 | ········} |
| 133 | |
| 134 | ········bool IsProviderInstalled(string providerName) |
| 135 | ········{ |
| 136 | ············IComponentModel componentModel; |
| 137 | ············var installerService = GetInstallerService( out componentModel ); |
| 138 | |
| 139 | ············string packageName = $"ndo.{providerName.ToLower()}"; |
| 140 | ············return installerService.IsPackageInstalled( this.project, packageName ); |
| 141 | ········} |
| 142 | |
| 143 | ········/// <summary> |
| 144 | ········/// Clean up any resources being used. |
| 145 | ········/// </summary> |
| 146 | ········protected override void Dispose( bool disposing ) |
| 147 | ········{ |
| 148 | ············if( disposing ) |
| 149 | ············{ |
| 150 | ················if(components != null) |
| 151 | ················{ |
| 152 | ····················components.Dispose(); |
| 153 | ················} |
| 154 | ············} |
| 155 | ············base.Dispose( disposing ); |
| 156 | ········} |
| 157 | |
| 158 | ········#region Windows Form Designer generated code |
| 159 | ········/// <summary> |
| 160 | ········/// Required method for Designer support - do not modify |
| 161 | ········/// the contents of this method with the code editor. |
| 162 | ········/// </summary> |
| 163 | ········private void InitializeComponent() |
| 164 | ········{ |
| 165 | ············this.components = new System.ComponentModel.Container(); |
| 166 | ············System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConfigurationDialog)); |
| 167 | ············this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); |
| 168 | ············this.chkVerboseMode = new System.Windows.Forms.CheckBox(); |
| 169 | ············this.btnNewDatabase = new System.Windows.Forms.Button(); |
| 170 | ············this.btnSaveAs = new System.Windows.Forms.Button(); |
| 171 | ············this.btnPresetApp = new System.Windows.Forms.Button(); |
| 172 | ············this.txtDbOwner = new System.Windows.Forms.TextBox(); |
| 173 | ············this.txtConnectionString = new System.Windows.Forms.TextBox(); |
| 174 | ············this.chkDropExistingElements = new System.Windows.Forms.CheckBox(); |
| 175 | ············this.chkGenerateFkConstraints = new System.Windows.Forms.CheckBox(); |
| 176 | ············this.chkIncludeTypecodes = new System.Windows.Forms.CheckBox(); |
| 177 | ············this.radioDefaultEncoding = new System.Windows.Forms.RadioButton(); |
| 178 | ············this.radioUtf8Encoding = new System.Windows.Forms.RadioButton(); |
| 179 | ············this.cbSqlDialect = new System.Windows.Forms.ComboBox(); |
| 180 | ············this.chkGenerateSQLScript = new System.Windows.Forms.CheckBox(); |
| 181 | ············this.chkUseTimeStamps = new System.Windows.Forms.CheckBox(); |
| 182 | ············this.chkChangeEvents = new System.Windows.Forms.CheckBox(); |
| 183 | ············this.btnConnString = new System.Windows.Forms.Button(); |
| 184 | ············this.btnPresetLibrary = new System.Windows.Forms.Button(); |
| 185 | ············this.chkMappingNew = new System.Windows.Forms.CheckBox(); |
| 186 | ············this.chkActivateEnhancer = new System.Windows.Forms.CheckBox(); |
| 187 | ············this.chkActivateAddIn = new System.Windows.Forms.CheckBox(); |
| 188 | ············this.tabControl = new System.Windows.Forms.TabControl(); |
| 189 | ············this.tabPageGeneral = new System.Windows.Forms.TabPage(); |
| 190 | ············this.txtTargetMappingFileName = new System.Windows.Forms.TextBox(); |
| 191 | ············this.label1 = new System.Windows.Forms.Label(); |
| 192 | ············this.txtSchemaVersion = new System.Windows.Forms.TextBox(); |
| 193 | ············this.label5 = new System.Windows.Forms.Label(); |
| 194 | ············this.label3 = new System.Windows.Forms.Label(); |
| 195 | ············this.groupBox1 = new System.Windows.Forms.GroupBox(); |
| 196 | ············this.btnInstallProvider = new System.Windows.Forms.Button(); |
| 197 | ············this.label4 = new System.Windows.Forms.Label(); |
| 198 | ············this.label2 = new System.Windows.Forms.Label(); |
| 199 | ············this.tabPageAssemblies = new System.Windows.Forms.TabPage(); |
| 200 | ············this.label6 = new System.Windows.Forms.Label(); |
| 201 | ············this.chlbAssemblies = new System.Windows.Forms.CheckedListBox(); |
| 202 | ············this.btnOK = new System.Windows.Forms.Button(); |
| 203 | ············this.btnCancel = new System.Windows.Forms.Button(); |
| 204 | ············this.tabControl.SuspendLayout(); |
| 205 | ············this.tabPageGeneral.SuspendLayout(); |
| 206 | ············this.groupBox1.SuspendLayout(); |
| 207 | ············this.tabPageAssemblies.SuspendLayout(); |
| 208 | ············this.SuspendLayout(); |
| 209 | ············// |
| 210 | ············// chkVerboseMode |
| 211 | ············// |
| 212 | ············this.chkVerboseMode.Location = new System.Drawing.Point(21, 72); |
| 213 | ············this.chkVerboseMode.Name = "chkVerboseMode"; |
| 214 | ············this.chkVerboseMode.Size = new System.Drawing.Size(238, 21); |
| 215 | ············this.chkVerboseMode.TabIndex = 51; |
| 216 | ············this.chkVerboseMode.Text = "Add-in Verbose Mode"; |
| 217 | ············this.toolTip1.SetToolTip(this.chkVerboseMode, "Causes the Add-in and the Enhancer to show more information for debugging purpose" + |
| 218 | ········"s."); |
| 219 | ············// |
| 220 | ············// btnNewDatabase |
| 221 | ············// |
| 222 | ············this.btnNewDatabase.Location = new System.Drawing.Point(583, 313); |
| 223 | ············this.btnNewDatabase.Name = "btnNewDatabase"; |
| 224 | ············this.btnNewDatabase.Size = new System.Drawing.Size(42, 21); |
| 225 | ············this.btnNewDatabase.TabIndex = 48; |
| 226 | ············this.btnNewDatabase.Text = "New"; |
| 227 | ············this.toolTip1.SetToolTip(this.btnNewDatabase, "Create new database"); |
| 228 | ············this.btnNewDatabase.Click += new System.EventHandler(this.btnNewDatabase_Click); |
| 229 | ············// |
| 230 | ············// btnSaveAs |
| 231 | ············// |
| 232 | ············this.btnSaveAs.DialogResult = System.Windows.Forms.DialogResult.OK; |
| 233 | ············this.btnSaveAs.Location = new System.Drawing.Point(249, 385); |
| 234 | ············this.btnSaveAs.Name = "btnSaveAs"; |
| 235 | ············this.btnSaveAs.Size = new System.Drawing.Size(100, 39); |
| 236 | ············this.btnSaveAs.TabIndex = 47; |
| 237 | ············this.btnSaveAs.Text = "Save as..."; |
| 238 | ············this.toolTip1.SetToolTip(this.btnSaveAs, "Save the options to be used in unattended builds with the stand-alone enhancer."); |
| 239 | ············this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); |
| 240 | ············// |
| 241 | ············// btnPresetApp |
| 242 | ············// |
| 243 | ············this.btnPresetApp.Location = new System.Drawing.Point(135, 385); |
| 244 | ············this.btnPresetApp.Name = "btnPresetApp"; |
| 245 | ············this.btnPresetApp.Size = new System.Drawing.Size(100, 39); |
| 246 | ············this.btnPresetApp.TabIndex = 46; |
| 247 | ············this.btnPresetApp.Text = "Preset for Application"; |
| 248 | ············this.toolTip1.SetToolTip(this.btnPresetApp, "Selects all settings used for applications which don\'t contain but reference pers" + |
| 249 | ········"istent types."); |
| 250 | ············this.btnPresetApp.Click += new System.EventHandler(this.btnPresetApp_Click); |
| 251 | ············// |
| 252 | ············// txtDbOwner |
| 253 | ············// |
| 254 | ············this.txtDbOwner.Location = new System.Drawing.Point(145, 126); |
| 255 | ············this.txtDbOwner.Name = "txtDbOwner"; |
| 256 | ············this.txtDbOwner.Size = new System.Drawing.Size(160, 20); |
| 257 | ············this.txtDbOwner.TabIndex = 45; |
| 258 | ············this.toolTip1.SetToolTip(this.txtDbOwner, "Enter an owner name, if you like your tables to be written like owner.tablename."); |
| 259 | ············// |
| 260 | ············// txtConnectionString |
| 261 | ············// |
| 262 | ············this.txtConnectionString.Location = new System.Drawing.Point(18, 313); |
| 263 | ············this.txtConnectionString.Name = "txtConnectionString"; |
| 264 | ············this.txtConnectionString.Size = new System.Drawing.Size(514, 20); |
| 265 | ············this.txtConnectionString.TabIndex = 39; |
| 266 | ············this.toolTip1.SetToolTip(this.txtConnectionString, "This string will be copied into the mapping file, if there doesn\'t exist a valid " + |
| 267 | ········"connection string. Otherwise it will be ignored."); |
| 268 | ············// |
| 269 | ············// chkDropExistingElements |
| 270 | ············// |
| 271 | ············this.chkDropExistingElements.Location = new System.Drawing.Point(13, 202); |
| 272 | ············this.chkDropExistingElements.Name = "chkDropExistingElements"; |
| 273 | ············this.chkDropExistingElements.Size = new System.Drawing.Size(235, 21); |
| 274 | ············this.chkDropExistingElements.TabIndex = 24; |
| 275 | ············this.chkDropExistingElements.Text = "Insert Drop Statements in the Script"; |
| 276 | ············this.toolTip1.SetToolTip(this.chkDropExistingElements, "If checked, NDO generates instructions to remove existing tables and constraints." + |
| 277 | ········""); |
| 278 | ············// |
| 279 | ············// chkGenerateFkConstraints |
| 280 | ············// |
| 281 | ············this.chkGenerateFkConstraints.Location = new System.Drawing.Point(13, 152); |
| 282 | ············this.chkGenerateFkConstraints.Name = "chkGenerateFkConstraints"; |
| 283 | ············this.chkGenerateFkConstraints.Size = new System.Drawing.Size(235, 21); |
| 284 | ············this.chkGenerateFkConstraints.TabIndex = 23; |
| 285 | ············this.chkGenerateFkConstraints.Text = "Generate Foreign Key Constraints"; |
| 286 | ············this.toolTip1.SetToolTip(this.chkGenerateFkConstraints, "If checked, NDO generates foreign key constraints for the relations in the databa" + |
| 287 | ········"se."); |
| 288 | ············// |
| 289 | ············// chkIncludeTypecodes |
| 290 | ············// |
| 291 | ············this.chkIncludeTypecodes.Location = new System.Drawing.Point(13, 177); |
| 292 | ············this.chkIncludeTypecodes.Name = "chkIncludeTypecodes"; |
| 293 | ············this.chkIncludeTypecodes.Size = new System.Drawing.Size(235, 21); |
| 294 | ············this.chkIncludeTypecodes.TabIndex = 22; |
| 295 | ············this.chkIncludeTypecodes.Text = "Include Typecodes in the Script"; |
| 296 | ············this.toolTip1.SetToolTip(this.chkIncludeTypecodes, "If checked, NDO generates instructions to build an additional table with the type" + |
| 297 | ········" code information."); |
| 298 | ············// |
| 299 | ············// radioDefaultEncoding |
| 300 | ············// |
| 301 | ············this.radioDefaultEncoding.Location = new System.Drawing.Point(13, 121); |
| 302 | ············this.radioDefaultEncoding.Name = "radioDefaultEncoding"; |
| 303 | ············this.radioDefaultEncoding.Size = new System.Drawing.Size(140, 20); |
| 304 | ············this.radioDefaultEncoding.TabIndex = 21; |
| 305 | ············this.radioDefaultEncoding.Text = "Default Encoding"; |
| 306 | ············this.toolTip1.SetToolTip(this.radioDefaultEncoding, "Check this option, if the script files should use windows encoding."); |
| 307 | ············// |
| 308 | ············// radioUtf8Encoding |
| 309 | ············// |
| 310 | ············this.radioUtf8Encoding.Checked = true; |
| 311 | ············this.radioUtf8Encoding.Location = new System.Drawing.Point(13, 99); |
| 312 | ············this.radioUtf8Encoding.Name = "radioUtf8Encoding"; |
| 313 | ············this.radioUtf8Encoding.Size = new System.Drawing.Size(140, 21); |
| 314 | ············this.radioUtf8Encoding.TabIndex = 20; |
| 315 | ············this.radioUtf8Encoding.TabStop = true; |
| 316 | ············this.radioUtf8Encoding.Text = "UTF-8 Encoding"; |
| 317 | ············this.toolTip1.SetToolTip(this.radioUtf8Encoding, "Check this option, if the script files should be UTF-8 encoded."); |
| 318 | ············// |
| 319 | ············// cbSqlDialect |
| 320 | ············// |
| 321 | ············this.cbSqlDialect.Location = new System.Drawing.Point(13, 70); |
| 322 | ············this.cbSqlDialect.Name = "cbSqlDialect"; |
| 323 | ············this.cbSqlDialect.Size = new System.Drawing.Size(220, 21); |
| 324 | ············this.cbSqlDialect.TabIndex = 18; |
| 325 | ············this.toolTip1.SetToolTip(this.cbSqlDialect, "Choose an available NDO provider."); |
| 326 | ············this.cbSqlDialect.SelectedIndexChanged += new System.EventHandler(this.cbSqlDialect_SelectedIndexChanged); |
| 327 | ············// |
| 328 | ············// chkGenerateSQLScript |
| 329 | ············// |
| 330 | ············this.chkGenerateSQLScript.Location = new System.Drawing.Point(13, 21); |
| 331 | ············this.chkGenerateSQLScript.Name = "chkGenerateSQLScript"; |
| 332 | ············this.chkGenerateSQLScript.Size = new System.Drawing.Size(187, 21); |
| 333 | ············this.chkGenerateSQLScript.TabIndex = 13; |
| 334 | ············this.chkGenerateSQLScript.Text = "Generate SQL Script"; |
| 335 | ············this.toolTip1.SetToolTip(this.chkGenerateSQLScript, "If checked, NDO will create a script with DDL code, which can be used to construc" + |
| 336 | ········"t a database structure."); |
| 337 | ············this.chkGenerateSQLScript.CheckedChanged += new System.EventHandler(this.chkGenerateSQLScript_CheckedChanged); |
| 338 | ············// |
| 339 | ············// chkUseTimeStamps |
| 340 | ············// |
| 341 | ············this.chkUseTimeStamps.Location = new System.Drawing.Point(21, 153); |
| 342 | ············this.chkUseTimeStamps.Name = "chkUseTimeStamps"; |
| 343 | ············this.chkUseTimeStamps.Size = new System.Drawing.Size(302, 20); |
| 344 | ············this.chkUseTimeStamps.TabIndex = 42; |
| 345 | ············this.chkUseTimeStamps.Text = "Generate Time Stamp Columns for each class"; |
| 346 | ············this.toolTip1.SetToolTip(this.chkUseTimeStamps, "Check this option, if all tables should be protected by collistion detection."); |
| 347 | ············// |
| 348 | ············// chkChangeEvents |
| 349 | ············// |
| 350 | ············this.chkChangeEvents.Location = new System.Drawing.Point(21, 179); |
| 351 | ············this.chkChangeEvents.Name = "chkChangeEvents"; |
| 352 | ············this.chkChangeEvents.Size = new System.Drawing.Size(302, 21); |
| 353 | ············this.chkChangeEvents.TabIndex = 41; |
| 354 | ············this.chkChangeEvents.Text = "Generate change events with Add Accessor"; |
| 355 | ············this.toolTip1.SetToolTip(this.chkChangeEvents, "Check this option, if you intend to bind the UI directly to the accessor properti" + |
| 356 | ········"es of your persistent classes."); |
| 357 | ············// |
| 358 | ············// btnConnString |
| 359 | ············// |
| 360 | ············this.btnConnString.Location = new System.Drawing.Point(538, 313); |
| 361 | ············this.btnConnString.Name = "btnConnString"; |
| 362 | ············this.btnConnString.Size = new System.Drawing.Size(42, 21); |
| 363 | ············this.btnConnString.TabIndex = 38; |
| 364 | ············this.btnConnString.Text = "..."; |
| 365 | ············this.toolTip1.SetToolTip(this.btnConnString, "Enter existing database connection"); |
| 366 | ············this.btnConnString.Click += new System.EventHandler(this.btnConnString_Click); |
| 367 | ············// |
| 368 | ············// btnPresetLibrary |
| 369 | ············// |
| 370 | ············this.btnPresetLibrary.Location = new System.Drawing.Point(21, 385); |
| 371 | ············this.btnPresetLibrary.Name = "btnPresetLibrary"; |
| 372 | ············this.btnPresetLibrary.Size = new System.Drawing.Size(100, 39); |
| 373 | ············this.btnPresetLibrary.TabIndex = 36; |
| 374 | ············this.btnPresetLibrary.Text = "Preset for Library"; |
| 375 | ············this.toolTip1.SetToolTip(this.btnPresetLibrary, "Selects all settings necessary for projects containing persistent types."); |
| 376 | ············this.btnPresetLibrary.Click += new System.EventHandler(this.btnPresetLibrary_Click); |
| 377 | ············// |
| 378 | ············// chkMappingNew |
| 379 | ············// |
| 380 | ············this.chkMappingNew.Location = new System.Drawing.Point(21, 99); |
| 381 | ············this.chkMappingNew.Name = "chkMappingNew"; |
| 382 | ············this.chkMappingNew.Size = new System.Drawing.Size(272, 21); |
| 383 | ············this.chkMappingNew.TabIndex = 34; |
| 384 | ············this.chkMappingNew.Text = "Always Generate a new mapping File"; |
| 385 | ············this.toolTip1.SetToolTip(this.chkMappingNew, "Choose this options, if NDO should discard and rebuild all mapping information."); |
| 386 | ············// |
| 387 | ············// chkActivateEnhancer |
| 388 | ············// |
| 389 | ············this.chkActivateEnhancer.Location = new System.Drawing.Point(21, 46); |
| 390 | ············this.chkActivateEnhancer.Name = "chkActivateEnhancer"; |
| 391 | ············this.chkActivateEnhancer.Size = new System.Drawing.Size(188, 20); |
| 392 | ············this.chkActivateEnhancer.TabIndex = 33; |
| 393 | ············this.chkActivateEnhancer.Text = "Activate enhancer"; |
| 394 | ············this.toolTip1.SetToolTip(this.chkActivateEnhancer, "Choose this option, if your project contains persistent types."); |
| 395 | ············// |
| 396 | ············// chkActivateAddIn |
| 397 | ············// |
| 398 | ············this.chkActivateAddIn.Location = new System.Drawing.Point(21, 19); |
| 399 | ············this.chkActivateAddIn.Name = "chkActivateAddIn"; |
| 400 | ············this.chkActivateAddIn.Size = new System.Drawing.Size(188, 21); |
| 401 | ············this.chkActivateAddIn.TabIndex = 32; |
| 402 | ············this.chkActivateAddIn.Text = "Activate NDO AddIn"; |
| 403 | ············this.toolTip1.SetToolTip(this.chkActivateAddIn, "Choose this options, if your project contains or references persistent types."); |
| 404 | ············this.chkActivateAddIn.Click += new System.EventHandler(this.chkActivateAddIn_CheckedChanged); |
| 405 | ············// |
| 406 | ············// tabControl |
| 407 | ············// |
| 408 | ············this.tabControl.Controls.Add(this.tabPageGeneral); |
| 409 | ············this.tabControl.Controls.Add(this.tabPageAssemblies); |
| 410 | ············this.tabControl.Dock = System.Windows.Forms.DockStyle.Top; |
| 411 | ············this.tabControl.Location = new System.Drawing.Point(0, 0); |
| 412 | ············this.tabControl.Name = "tabControl"; |
| 413 | ············this.tabControl.SelectedIndex = 0; |
| 414 | ············this.tabControl.Size = new System.Drawing.Size(661, 374); |
| 415 | ············this.tabControl.TabIndex = 0; |
| 416 | ············// |
| 417 | ············// tabPageGeneral |
| 418 | ············// |
| 419 | ············this.tabPageGeneral.Controls.Add(this.txtTargetMappingFileName); |
| 420 | ············this.tabPageGeneral.Controls.Add(this.label1); |
| 421 | ············this.tabPageGeneral.Controls.Add(this.chkVerboseMode); |
| 422 | ············this.tabPageGeneral.Controls.Add(this.txtSchemaVersion); |
| 423 | ············this.tabPageGeneral.Controls.Add(this.label5); |
| 424 | ············this.tabPageGeneral.Controls.Add(this.btnNewDatabase); |
| 425 | ············this.tabPageGeneral.Controls.Add(this.txtDbOwner); |
| 426 | ············this.tabPageGeneral.Controls.Add(this.txtConnectionString); |
| 427 | ············this.tabPageGeneral.Controls.Add(this.label3); |
| 428 | ············this.tabPageGeneral.Controls.Add(this.groupBox1); |
| 429 | ············this.tabPageGeneral.Controls.Add(this.chkUseTimeStamps); |
| 430 | ············this.tabPageGeneral.Controls.Add(this.chkChangeEvents); |
| 431 | ············this.tabPageGeneral.Controls.Add(this.label2); |
| 432 | ············this.tabPageGeneral.Controls.Add(this.btnConnString); |
| 433 | ············this.tabPageGeneral.Controls.Add(this.chkMappingNew); |
| 434 | ············this.tabPageGeneral.Controls.Add(this.chkActivateEnhancer); |
| 435 | ············this.tabPageGeneral.Controls.Add(this.chkActivateAddIn); |
| 436 | ············this.tabPageGeneral.Location = new System.Drawing.Point(4, 22); |
| 437 | ············this.tabPageGeneral.Name = "tabPageGeneral"; |
| 438 | ············this.tabPageGeneral.Padding = new System.Windows.Forms.Padding(3); |
| 439 | ············this.tabPageGeneral.Size = new System.Drawing.Size(653, 348); |
| 440 | ············this.tabPageGeneral.TabIndex = 0; |
| 441 | ············this.tabPageGeneral.Text = "General"; |
| 442 | ············this.tabPageGeneral.UseVisualStyleBackColor = true; |
| 443 | ············// |
| 444 | ············// txtTargetMappingFileName |
| 445 | ············// |
| 446 | ············this.txtTargetMappingFileName.Location = new System.Drawing.Point(145, 245); |
| 447 | ············this.txtTargetMappingFileName.Name = "txtTargetMappingFileName"; |
| 448 | ············this.txtTargetMappingFileName.Size = new System.Drawing.Size(160, 20); |
| 449 | ············this.txtTargetMappingFileName.TabIndex = 53; |
| 450 | ············// |
| 451 | ············// label1 |
| 452 | ············// |
| 453 | ············this.label1.Location = new System.Drawing.Point(18, 246); |
| 454 | ············this.label1.Name = "label1"; |
| 455 | ············this.label1.Size = new System.Drawing.Size(121, 21); |
| 456 | ············this.label1.TabIndex = 52; |
| 457 | ············this.label1.Text = "Mapping File Name"; |
| 458 | ············// |
| 459 | ············// txtSchemaVersion |
| 460 | ············// |
| 461 | ············this.txtSchemaVersion.Location = new System.Drawing.Point(145, 219); |
| 462 | ············this.txtSchemaVersion.Name = "txtSchemaVersion"; |
| 463 | ············this.txtSchemaVersion.Size = new System.Drawing.Size(160, 20); |
| 464 | ············this.txtSchemaVersion.TabIndex = 50; |
| 465 | ············// |
| 466 | ············// label5 |
| 467 | ············// |
| 468 | ············this.label5.Location = new System.Drawing.Point(18, 220); |
| 469 | ············this.label5.Name = "label5"; |
| 470 | ············this.label5.Size = new System.Drawing.Size(121, 21); |
| 471 | ············this.label5.TabIndex = 49; |
| 472 | ············this.label5.Text = "Schema Version"; |
| 473 | ············// |
| 474 | ············// label3 |
| 475 | ············// |
| 476 | ············this.label3.Location = new System.Drawing.Point(18, 128); |
| 477 | ············this.label3.Name = "label3"; |
| 478 | ············this.label3.Size = new System.Drawing.Size(127, 21); |
| 479 | ············this.label3.TabIndex = 44; |
| 480 | ············this.label3.Text = "Owner / Schema Name"; |
| 481 | ············// |
| 482 | ············// groupBox1 |
| 483 | ············// |
| 484 | ············this.groupBox1.Controls.Add(this.btnInstallProvider); |
| 485 | ············this.groupBox1.Controls.Add(this.chkDropExistingElements); |
| 486 | ············this.groupBox1.Controls.Add(this.chkGenerateFkConstraints); |
| 487 | ············this.groupBox1.Controls.Add(this.chkIncludeTypecodes); |
| 488 | ············this.groupBox1.Controls.Add(this.radioDefaultEncoding); |
| 489 | ············this.groupBox1.Controls.Add(this.radioUtf8Encoding); |
| 490 | ············this.groupBox1.Controls.Add(this.label4); |
| 491 | ············this.groupBox1.Controls.Add(this.cbSqlDialect); |
| 492 | ············this.groupBox1.Controls.Add(this.chkGenerateSQLScript); |
| 493 | ············this.groupBox1.Location = new System.Drawing.Point(343, 21); |
| 494 | ············this.groupBox1.Name = "groupBox1"; |
| 495 | ············this.groupBox1.Size = new System.Drawing.Size(265, 244); |
| 496 | ············this.groupBox1.TabIndex = 43; |
| 497 | ············this.groupBox1.TabStop = false; |
| 498 | ············this.groupBox1.Text = " SQL "; |
| 499 | ············// |
| 500 | ············// btnInstallProvider |
| 501 | ············// |
| 502 | ············this.btnInstallProvider.Location = new System.Drawing.Point(142, 102); |
| 503 | ············this.btnInstallProvider.Name = "btnInstallProvider"; |
| 504 | ············this.btnInstallProvider.Size = new System.Drawing.Size(91, 22); |
| 505 | ············this.btnInstallProvider.TabIndex = 25; |
| 506 | ············this.btnInstallProvider.Text = "Install Provider"; |
| 507 | ············this.btnInstallProvider.UseVisualStyleBackColor = true; |
| 508 | ············this.btnInstallProvider.Click += new System.EventHandler(this.btnInstallProvider_Click); |
| 509 | ············// |
| 510 | ············// label4 |
| 511 | ············// |
| 512 | ············this.label4.Location = new System.Drawing.Point(13, 50); |
| 513 | ············this.label4.Name = "label4"; |
| 514 | ············this.label4.Size = new System.Drawing.Size(200, 17); |
| 515 | ············this.label4.TabIndex = 19; |
| 516 | ············this.label4.Text = "SQL Dialect"; |
| 517 | ············// |
| 518 | ············// label2 |
| 519 | ············// |
| 520 | ············this.label2.Location = new System.Drawing.Point(18, 292); |
| 521 | ············this.label2.Name = "label2"; |
| 522 | ············this.label2.Size = new System.Drawing.Size(360, 21); |
| 523 | ············this.label2.TabIndex = 40; |
| 524 | ············this.label2.Text = "Default Connection String"; |
| 525 | ············// |
| 526 | ············// tabPageAssemblies |
| 527 | ············// |
| 528 | ············this.tabPageAssemblies.Controls.Add(this.label6); |
| 529 | ············this.tabPageAssemblies.Controls.Add(this.chlbAssemblies); |
| 530 | ············this.tabPageAssemblies.Location = new System.Drawing.Point(4, 22); |
| 531 | ············this.tabPageAssemblies.Name = "tabPageAssemblies"; |
| 532 | ············this.tabPageAssemblies.Padding = new System.Windows.Forms.Padding(3); |
| 533 | ············this.tabPageAssemblies.Size = new System.Drawing.Size(653, 348); |
| 534 | ············this.tabPageAssemblies.TabIndex = 1; |
| 535 | ············this.tabPageAssemblies.Text = "Assemblies"; |
| 536 | ············this.tabPageAssemblies.UseVisualStyleBackColor = true; |
| 537 | ············// |
| 538 | ············// label6 |
| 539 | ············// |
| 540 | ············this.label6.AutoSize = true; |
| 541 | ············this.label6.Location = new System.Drawing.Point(10, 12); |
| 542 | ············this.label6.Name = "label6"; |
| 543 | ············this.label6.Size = new System.Drawing.Size(328, 13); |
| 544 | ············this.label6.TabIndex = 1; |
| 545 | ············this.label6.Text = "Choose Assemblies which should be analyzed by the NDOEnhancer"; |
| 546 | ············// |
| 547 | ············// chlbAssemblies |
| 548 | ············// |
| 549 | ············this.chlbAssemblies.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
| 550 | ············| System.Windows.Forms.AnchorStyles.Left) |
| 551 | ············| System.Windows.Forms.AnchorStyles.Right))); |
| 552 | ············this.chlbAssemblies.FormattingEnabled = true; |
| 553 | ············this.chlbAssemblies.Location = new System.Drawing.Point(10, 39); |
| 554 | ············this.chlbAssemblies.Name = "chlbAssemblies"; |
| 555 | ············this.chlbAssemblies.Size = new System.Drawing.Size(631, 289); |
| 556 | ············this.chlbAssemblies.TabIndex = 0; |
| 557 | ············this.chlbAssemblies.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.chlbAssemblies_ItemCheck); |
| 558 | ············// |
| 559 | ············// btnOK |
| 560 | ············// |
| 561 | ············this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; |
| 562 | ············this.btnOK.Location = new System.Drawing.Point(363, 385); |
| 563 | ············this.btnOK.Name = "btnOK"; |
| 564 | ············this.btnOK.Size = new System.Drawing.Size(100, 39); |
| 565 | ············this.btnOK.TabIndex = 37; |
| 566 | ············this.btnOK.Text = "OK"; |
| 567 | ············this.btnOK.Click += new System.EventHandler(this.btnOK_Click); |
| 568 | ············// |
| 569 | ············// btnCancel |
| 570 | ············// |
| 571 | ············this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
| 572 | ············this.btnCancel.Location = new System.Drawing.Point(477, 385); |
| 573 | ············this.btnCancel.Name = "btnCancel"; |
| 574 | ············this.btnCancel.Size = new System.Drawing.Size(100, 39); |
| 575 | ············this.btnCancel.TabIndex = 35; |
| 576 | ············this.btnCancel.Text = "Cancel"; |
| 577 | ············// |
| 578 | ············// ConfigurationDialog |
| 579 | ············// |
| 580 | ············this.AutoScaleMode = AutoScaleMode.Font; |
| 581 | ············this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
| 582 | ············this.CancelButton = this.btnCancel; |
| 583 | ············this.ClientSize = new System.Drawing.Size(661, 439); |
| 584 | ············this.Controls.Add(this.btnSaveAs); |
| 585 | ············this.Controls.Add(this.btnPresetApp); |
| 586 | ············this.Controls.Add(this.btnOK); |
| 587 | ············this.Controls.Add(this.btnPresetLibrary); |
| 588 | ············this.Controls.Add(this.btnCancel); |
| 589 | ············this.Controls.Add(this.tabControl); |
| 590 | ············this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); |
| 591 | ············this.Name = "ConfigurationDialog"; |
| 592 | ············this.Text = "NDO Configuration"; |
| 593 | ············this.Load += new System.EventHandler(this.ConfigurationDialog_Load); |
| 594 | ············this.tabControl.ResumeLayout(false); |
| 595 | ············this.tabPageGeneral.ResumeLayout(false); |
| 596 | ············this.tabPageGeneral.PerformLayout(); |
| 597 | ············this.groupBox1.ResumeLayout(false); |
| 598 | ············this.tabPageAssemblies.ResumeLayout(false); |
| 599 | ············this.tabPageAssemblies.PerformLayout(); |
| 600 | ············this.ResumeLayout(false); |
| 601 | |
| 602 | ········} |
| 603 | ········#endregion |
| 604 | |
| 605 | ········private void chkActivateAddIn_CheckedChanged(object sender, System.EventArgs e) |
| 606 | ········{ |
| 607 | ············EnableAddin(this.chkActivateAddIn.Checked); |
| 608 | ········} |
| 609 | |
| 610 | |
| 611 | ········void EnableAddin(bool enabled) |
| 612 | ········{ |
| 613 | ············if (project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 614 | ················chkActivateEnhancer.Enabled = false; |
| 615 | ············else |
| 616 | ················chkActivateEnhancer.Enabled = enabled; |
| 617 | ········} |
| 618 | |
| 619 | ········private void ConfigurationDialog_Load(object sender, System.EventArgs e) |
| 620 | ········{ |
| 621 | ············try |
| 622 | ············{ |
| 623 | ················ConfigurationOptions options = new ConfigurationOptions(project); |
| 624 | ················this.Text = "NDO Configuration - " + project.Name; |
| 625 | ················chkIncludeTypecodes.Checked = options.IncludeTypecodes; |
| 626 | ················chkDropExistingElements.Checked = options.DropExistingElements; |
| 627 | ················chkGenerateFkConstraints.Checked = options.GenerateConstraints; |
| 628 | ················chkVerboseMode.Checked = options.VerboseMode; |
| 629 | ················chkChangeEvents.Checked = options.GenerateChangeEvents; |
| 630 | ················chkActivateAddIn.Checked = options.EnableAddIn; |
| 631 | ················chkActivateEnhancer.Checked = options.EnableEnhancer; |
| 632 | ················chkMappingNew.Checked = options.NewMapping; |
| 633 | ················if (chkActivateAddIn.Checked == false) |
| 634 | ····················EnableAddin(false); |
| 635 | ················chkGenerateSQLScript.Checked = options.GenerateSQL; |
| 636 | ················txtSchemaVersion.Text = options.SchemaVersion; |
| 637 | ················if (string.IsNullOrEmpty(txtSchemaVersion.Text)) |
| 638 | ····················txtSchemaVersion.Text = "1.0"; |
| 639 | ················this.chkUseTimeStamps.Checked = options.UseTimeStamps; |
| 640 | ················int i = 0; |
| 641 | ················this.cbSqlDialect.Items.Clear(); |
| 642 | ················int currentDialectIndex = -1; |
| 643 | |
| 644 | ················foreach (string s in NdoUIProviderFactory.Instance.Keys) |
| 645 | ················{ |
| 646 | ····················this.cbSqlDialect.Items.Add( s ); |
| 647 | ····················if (options.SQLScriptLanguage == s) |
| 648 | ························currentDialectIndex = i; |
| 649 | ····················i++; |
| 650 | ················} |
| 651 | ················if (currentDialectIndex > -1) |
| 652 | ····················cbSqlDialect.SelectedIndex = currentDialectIndex; |
| 653 | |
| 654 | ················// Must be initialized after changing the cbSqlDialect index |
| 655 | ················txtConnectionString.Text = options.DefaultConnection; |
| 656 | ················txtTargetMappingFileName.Text = options.TargetMappingFileName; |
| 657 | ················txtDbOwner.Text = options.DatabaseOwner; |
| 658 | ················chkActivateAddIn_CheckedChanged(null, EventArgs.Empty); |
| 659 | ················chkGenerateSQLScript_CheckedChanged(null, EventArgs.Empty); |
| 660 | ················if (options.Utf8Encoding) |
| 661 | ····················radioUtf8Encoding.Checked = true; |
| 662 | ················else |
| 663 | ····················radioDefaultEncoding.Checked = true; |
| 664 | ················if (project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 665 | ····················this.chkActivateEnhancer.Enabled = false; |
| 666 | |
| 667 | ················CheckEnabledStateForLoadProviderButton(); |
| 668 | ············} |
| 669 | ············catch (Exception ex) |
| 670 | ············{ |
| 671 | #if !DEBUG |
| 672 | ················MessageBox.Show(ex.Message, "NDO Configuration"); |
| 673 | #else |
| 674 | ················MessageBox.Show(ex.ToString(), "NDO Configuration"); |
| 675 | #endif |
| 676 | ············} |
| 677 | ········} |
| 678 | |
| 679 | ········private void btnPresetLibrary_Click(object sender, System.EventArgs e) |
| 680 | ········{ |
| 681 | //············ConfigurationOptions options = new ConfigurationOptions( project ); |
| 682 | ············try |
| 683 | ············{ |
| 684 | ················EnableCheckBoxes(); |
| 685 | |
| 686 | ················this.chkVerboseMode.Checked = false; |
| 687 | ················this.chkActivateAddIn.Checked = true; |
| 688 | ················this.chkActivateEnhancer.Checked = true; |
| 689 | ················this.chkMappingNew.Checked = false; |
| 690 | ················this.chkChangeEvents.Checked = false; |
| 691 | ················this.chkIncludeTypecodes.Checked = false; |
| 692 | ················this.chkGenerateFkConstraints.Checked = false; |
| 693 | ················this.chkDropExistingElements.Checked = false; |
| 694 | ················this.chkUseTimeStamps.Checked = false;···· |
| 695 | ················this.txtDbOwner.Text = ""; |
| 696 | ················this.chkGenerateSQLScript.Checked = false; |
| 697 | ················this.txtSchemaVersion.Text = ""; |
| 698 | ············} |
| 699 | ············catch (Exception ex) |
| 700 | ············{ |
| 701 | ················ShowError(ex); |
| 702 | ············} |
| 703 | ········} |
| 704 | |
| 705 | |
| 706 | ········private void btnOK_Click(object sender, System.EventArgs e) |
| 707 | ········{ |
| 708 | ············try |
| 709 | ············{ |
| 710 | ················ConfigurationOptions options = new ConfigurationOptions( project ); |
| 711 | |
| 712 | ················string connType = options.SQLScriptLanguage; |
| 713 | ················string connName = options.DefaultConnection; |
| 714 | ················WriteBack(options); |
| 715 | ················if (options.SQLScriptLanguage != connType || options.DefaultConnection != connName) |
| 716 | ················{ |
| 717 | ····················string mappingFileName = this.project.MappingFilePath(); |
| 718 | ····················if (mappingFileName != null) |
| 719 | ····················{ |
| 720 | ························NDOMapping mapping = new NDOMapping(mappingFileName); |
| 721 | ························bool connectionExists = false; |
| 722 | ························foreach (Connection conn in mapping.Connections) |
| 723 | ························{ |
| 724 | ····························if (conn.Type == options.SQLScriptLanguage && conn.Name == options.DefaultConnection) |
| 725 | ····························{ |
| 726 | ································connectionExists = true; |
| 727 | ································break; |
| 728 | ····························} |
| 729 | ························} |
| 730 | ························if (!connectionExists) |
| 731 | ························{ |
| 732 | ····························if (MessageBox.Show("The database connection settings have been changed. Should NDO change the connection settings in the mapping file " + Path.GetFileName(mappingFileName) + " too?", "NDO Configuration", MessageBoxButtons.YesNo) == DialogResult.Yes) |
| 733 | ····························{ |
| 734 | ································Connection conn = null; |
| 735 | ································if (mapping.Connections.Count() == 1) |
| 736 | ································{ |
| 737 | ····································conn = (Connection)mapping.Connections.FirstOrDefault(); |
| 738 | ································} |
| 739 | ································else |
| 740 | ································{ |
| 741 | ····································conn = mapping.NewConnection(String.Empty, String.Empty); |
| 742 | ····································MessageBox.Show("Added a connection with the ID " + conn.ID, "NDO Configuration"); |
| 743 | ································} |
| 744 | ································conn.Type = options.SQLScriptLanguage; |
| 745 | ································conn.Name = options.DefaultConnection; |
| 746 | ································mapping.Save(); |
| 747 | ····························} |
| 748 | ························} |
| 749 | ····················} |
| 750 | ················} |
| 751 | |
| 752 | ················if ( options.EnableAddIn ) |
| 753 | ················{ |
| 754 | ····················GeneratePackageReference(); |
| 755 | ················} |
| 756 | |
| 757 | ················ThreadHelper.JoinableTaskFactory.Run( async () => await options.SaveAsync( this.projectDescription ) ); |
| 758 | ················ |
| 759 | ············} |
| 760 | ············catch (Exception ex) |
| 761 | ············{ |
| 762 | #if DEBUG |
| 763 | ················MessageBox.Show( "The following error occured while saving your options: " + ex.ToString(), "NDO Add-in" ); |
| 764 | #else |
| 765 | ················MessageBox.Show("The following error occured while saving your options: " + ex.Message, "NDO Add-in"); |
| 766 | #endif |
| 767 | ············} |
| 768 | ········} |
| 769 | |
| 770 | |
| 771 | ········void GeneratePackageReference() |
| 772 | ········{ |
| 773 | ············try |
| 774 | ············{ |
| 775 | ················IComponentModel componentModel; |
| 776 | ················var installerService = GetInstallerService( out componentModel ); |
| 777 | |
| 778 | ················if (!installerService.IsPackageInstalled( this.project, "ndo.dll" )) |
| 779 | ················{ |
| 780 | ····················var installer = componentModel.GetService<IVsPackageInstaller>(); |
| 781 | ····················// The newest version of NDO will be v5.x at the time, this package is released. |
| 782 | ····················// NDO5 needs the NDO.build package in all use cases. |
| 783 | ····················// If the enhancer is not to be used, uninstalling ndo.build is sufficient |
| 784 | ····················// because it will only be reinstalled if the NDO.dll package is missing. |
| 785 | ····················installer.InstallPackage( null, this.project, "NDO.dll", (string)null, false ); |
| 786 | ····················installer.InstallPackage( null, this.project, "NDO.build", (string) null, false ); |
| 787 | ················} |
| 788 | ············} |
| 789 | ············catch (Exception ex) |
| 790 | ············{ |
| 791 | ················MessageBox.Show( "Error while installing the ndo.dll package: " + ex.ToString() ); |
| 792 | ············} |
| 793 | ········} |
| 794 | |
| 795 | ········private static IVsPackageInstallerServices GetInstallerService( out IComponentModel componentModel ) |
| 796 | ········{ |
| 797 | ············componentModel = (IComponentModel)Package.GetGlobalService( typeof( SComponentModel ) ); |
| 798 | ············var installerService = componentModel.GetService<IVsPackageInstallerServices>(); |
| 799 | ············return installerService; |
| 800 | ········} |
| 801 | |
| 802 | ········void ShowError(Exception ex) |
| 803 | ········{ |
| 804 | ············MessageBox.Show("The following error occured: " + ex.Message, "NDO Add-in"); |
| 805 | ········} |
| 806 | |
| 807 | ········private void btnConnString_Click(object sender, System.EventArgs e) |
| 808 | ········{ |
| 809 | ············try |
| 810 | ············{ |
| 811 | ················string connType = cbSqlDialect.Text; |
| 812 | ················if (connType == string.Empty) |
| 813 | ····················connType = "SqlServer"; |
| 814 | ················var provider = NdoUIProviderFactory.Instance[connType]; |
| 815 | ················if (provider == null) |
| 816 | ················{ |
| 817 | ····················MessageBox.Show("Can't find a NDO UI provider for the sql dialect " + connType); |
| 818 | ····················return; |
| 819 | ················} |
| 820 | |
| 821 | ················string temp = this.txtConnectionString.Text; |
| 822 | ················NdoDialogResult r = provider.ShowConnectionDialog(ref temp); |
| 823 | ················if (r == NdoDialogResult.Cancel) |
| 824 | ····················return; |
| 825 | ················this.txtConnectionString.Text = temp; |
| 826 | ············} |
| 827 | ············catch (Exception ex) |
| 828 | ············{ |
| 829 | ················ShowError(ex); |
| 830 | ············} |
| 831 | ········} |
| 832 | |
| 833 | |
| 834 | ········private void chkGenerateSQLScript_CheckedChanged(object sender, System.EventArgs e) |
| 835 | ········{ |
| 836 | ············bool genSql = this.chkGenerateSQLScript.Checked; |
| 837 | |
| 838 | ············this.cbSqlDialect.Enabled = genSql; |
| 839 | ············this.chkIncludeTypecodes.Enabled = genSql; |
| 840 | ············this.chkDropExistingElements.Enabled = genSql; |
| 841 | ············this.chkGenerateFkConstraints.Enabled = genSql; |
| 842 | ············this.radioUtf8Encoding.Enabled = genSql; |
| 843 | ············this.radioDefaultEncoding.Enabled = genSql; |
| 844 | ········} |
| 845 | |
| 846 | ········private void EnableCheckBoxes() |
| 847 | ········{ |
| 848 | ············foreach(Control c in this.Controls) |
| 849 | ············{ |
| 850 | ················CheckBox cb = c as CheckBox; |
| 851 | ················if (c == null) |
| 852 | ····················continue; |
| 853 | ················c.Enabled = true; |
| 854 | ············} |
| 855 | ············if (this.project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 856 | ················this.chkActivateEnhancer.Enabled = false; |
| 857 | ········} |
| 858 | |
| 859 | ········private void btnPresetApp_Click(object sender, System.EventArgs e) |
| 860 | ········{ |
| 861 | ············try |
| 862 | ············{ |
| 863 | ················EnableCheckBoxes(); |
| 864 | ················this.chkVerboseMode.Checked = false; |
| 865 | ················this.chkActivateAddIn.Checked = true; |
| 866 | ················this.chkActivateEnhancer.Checked = false; |
| 867 | ················this.chkMappingNew.Checked = false; |
| 868 | ················this.chkGenerateSQLScript.Checked = true; |
| 869 | ················this.chkChangeEvents.Checked = false; |
| 870 | ················this.chkIncludeTypecodes.Checked = false; |
| 871 | ················this.chkDropExistingElements.Checked = false; |
| 872 | ················this.chkGenerateFkConstraints.Checked = false; |
| 873 | ················this.txtConnectionString.Text = ""; |
| 874 | ················this.chkUseTimeStamps.Checked = false; |
| 875 | ················this.txtDbOwner.Text = ""; |
| 876 | ················this.txtSchemaVersion.Text = "1.0"; |
| 877 | ················if (this.txtConnectionString.Text == string.Empty) |
| 878 | ····················this.btnConnString_Click(null, null); |
| 879 | ············} |
| 880 | ············catch (Exception ex) |
| 881 | ············{ |
| 882 | ················ShowError(ex); |
| 883 | ············} |
| 884 | ········} |
| 885 | |
| 886 | //········private void MakeNode(string name, object value, XmlNode parentNode, XmlDocument doc) |
| 887 | //········{ |
| 888 | //············XmlElement el = doc.CreateElement(name); |
| 889 | //············parentNode.AppendChild(el); |
| 890 | //············if (value != null) |
| 891 | //················el.InnerText = value.ToString(); |
| 892 | //········} |
| 893 | |
| 894 | ········void WriteBack(ConfigurationOptions options) |
| 895 | ········{ |
| 896 | ············options.EnableAddIn = chkActivateAddIn.Checked; |
| 897 | ············options.EnableEnhancer = chkActivateEnhancer.Checked; |
| 898 | ············options.IncludeTypecodes = chkIncludeTypecodes.Checked; |
| 899 | ············options.GenerateConstraints = chkGenerateFkConstraints.Checked; |
| 900 | ············options.DropExistingElements = chkDropExistingElements.Checked; |
| 901 | ············options.VerboseMode = chkVerboseMode.Checked; |
| 902 | ············options.NewMapping = chkMappingNew.Checked; |
| 903 | ············options.GenerateSQL = chkGenerateSQLScript.Checked; |
| 904 | ············options.DefaultConnection = txtConnectionString.Text; |
| 905 | ············options.TargetMappingFileName = txtTargetMappingFileName.Text; |
| 906 | ············options.GenerateChangeEvents = chkChangeEvents.Checked; |
| 907 | ············options.UseTimeStamps = chkUseTimeStamps.Checked; |
| 908 | ············options.SQLScriptLanguage = this.cbSqlDialect.Text; |
| 909 | ············options.DatabaseOwner = this.txtDbOwner.Text; |
| 910 | ············options.Utf8Encoding = this.radioUtf8Encoding.Checked; |
| 911 | ············options.SchemaVersion = this.txtSchemaVersion.Text; |
| 912 | ········} |
| 913 | |
| 914 | ········private void btnSaveAs_Click(object sender, System.EventArgs e) |
| 915 | ········{ |
| 916 | ············try |
| 917 | ············{ |
| 918 | ················string projDir = Path.GetDirectoryName(project.FullName); |
| 919 | ················SaveFileDialog sfd = new SaveFileDialog(); |
| 920 | ················sfd.CheckFileExists = false; |
| 921 | ················sfd.DefaultExt = "xml"; |
| 922 | ················sfd.Filter = "NDO Configuration Files (*.ndoproj)|*.ndoproj"; |
| 923 | ················sfd.FileName = "EnhancerParameters.ndoproj"; |
| 924 | ················sfd.InitialDirectory = projDir; |
| 925 | ················if (sfd.ShowDialog(this) != DialogResult.OK) |
| 926 | ····················return; |
| 927 | |
| 928 | ················ConfigurationOptions options = new ConfigurationOptions(project);················ |
| 929 | ················WriteBack(options); |
| 930 | ················options.SaveAs(sfd.FileName, this.projectDescription); |
| 931 | ············} |
| 932 | ············catch (Exception ex) |
| 933 | ············{ |
| 934 | ················ShowError(ex); |
| 935 | ············}········ |
| 936 | ········} |
| 937 | |
| 938 | ········private void cbSqlDialect_SelectedIndexChanged(object sender, System.EventArgs e) |
| 939 | ········{ |
| 940 | ············this.txtConnectionString.Text = string.Empty; |
| 941 | ············CheckEnabledStateForLoadProviderButton(); |
| 942 | ········} |
| 943 | |
| 944 | ········private void btnNewDatabase_Click(object sender, System.EventArgs e) |
| 945 | ········{ |
| 946 | ············string connType = cbSqlDialect.Text; |
| 947 | ············if (connType == string.Empty) |
| 948 | ················connType = "SqlServer"; |
| 949 | ············IDbUISupport provider = NdoUIProviderFactory.Instance[connType]; |
| 950 | ············if (provider == null) |
| 951 | ············{ |
| 952 | ················MessageBox.Show("Can't find a NDO UI provider for the sql dialect " + connType); |
| 953 | ················return; |
| 954 | ············} |
| 955 | ············object necessaryData = null; |
| 956 | ············try |
| 957 | ············{ |
| 958 | ················if (provider.ShowCreateDbDialog(ref necessaryData) == NdoDialogResult.Cancel) |
| 959 | ····················return; |
| 960 | ················this.txtConnectionString.Text = provider.CreateDatabase(necessaryData); |
| 961 | ············} |
| 962 | ············catch (Exception ex) |
| 963 | ············{ |
| 964 | #if !DEBUG |
| 965 | ················MessageBox.Show("Can't construct the database: " + ex.Message); |
| 966 | #else |
| 967 | ················MessageBox.Show("Can't construct the database: " + ex.ToString()); |
| 968 | #endif |
| 969 | ············} |
| 970 | ········} |
| 971 | |
| 972 | ········private void chlbAssemblies_ItemCheck( object sender, ItemCheckEventArgs e ) |
| 973 | ········{ |
| 974 | ············this.references[e.Index].CheckState = e.NewValue; |
| 975 | ········} |
| 976 | |
| 977 | ········private void btnInstallProvider_Click( object sender, EventArgs e ) |
| 978 | ········{ |
| 979 | ············try |
| 980 | ············{ |
| 981 | ················string providerName = this.cbSqlDialect.Text; |
| 982 | |
| 983 | ················if (string.IsNullOrEmpty( providerName )) |
| 984 | ················{ |
| 985 | ····················MessageBox.Show( "Please choose a provider" ); |
| 986 | ····················return; |
| 987 | ················} |
| 988 | |
| 989 | ················IComponentModel componentModel; |
| 990 | ················var installerService = GetInstallerService( out componentModel ); |
| 991 | |
| 992 | ················string packageName = $"ndo.{providerName.ToLower()}"; |
| 993 | ················if (!installerService.IsPackageInstalled( this.project, packageName )) |
| 994 | ················{ |
| 995 | ····················var installer = componentModel.GetService<IVsPackageInstaller>(); |
| 996 | ····················installer.InstallPackage( null, this.project, packageName, (string)null, false ); |
| 997 | ················} |
| 998 | |
| 999 | ················this.btnInstallProvider.Enabled = false; |
| 1000 | ············} |
| 1001 | ············catch (Exception ex) |
| 1002 | ············{ |
| 1003 | ················MessageBox.Show( "Error while installing the ndo.dll package: " + ex.ToString() ); |
| 1004 | ············} |
| 1005 | ········} |
| 1006 | ····} |
| 1007 | } |
| 1008 | |
| 1009 | #pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread |
| 1010 |
New Commit (5192672)
| 1 | // |
| 2 | // Copyright (c) 2002-2019 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.Linq; |
| 25 | using System.IO; |
| 26 | using System.Windows.Forms; |
| 27 | using MessageBox = System.Windows.Forms.MessageBox; |
| 28 | using Project = EnvDTE.Project; |
| 29 | using System.Diagnostics; |
| 30 | using Microsoft.VisualStudio.ComponentModelHost; |
| 31 | using NuGet.VisualStudio; |
| 32 | using NDO.UISupport; |
| 33 | using System.Drawing; |
| 34 | using WinForms.FontSize; |
| 35 | |
| 36 | #pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread |
| 37 | |
| 38 | namespace NDOVsPackage |
| 39 | { |
| 40 | ····/// <summary> |
| 41 | ····/// Summary description for ConfigurationDialog. |
| 42 | ····/// </summary> |
| 43 | ····internal class ConfigurationDialog : System.Windows.Forms.Form |
| 44 | ····{ |
| 45 | ········private System.ComponentModel.IContainer components; |
| 46 | |
| 47 | ········private Project project; |
| 48 | ········private System.Windows.Forms.ToolTip toolTip1; |
| 49 | ········private TabControl tabControl; |
| 50 | ········private TabPage tabPageGeneral; |
| 51 | ········private TextBox txtTargetMappingFileName; |
| 52 | ········private Label label1; |
| 53 | ········private CheckBox chkVerboseMode; |
| 54 | ········private TextBox txtSchemaVersion; |
| 55 | ········private Label label5; |
| 56 | ········private Button btnNewDatabase; |
| 57 | ········private Button btnSaveAs; |
| 58 | ········private Button btnPresetApp; |
| 59 | ········private TextBox txtDbOwner; |
| 60 | ········private TextBox txtConnectionString; |
| 61 | ········private Label label3; |
| 62 | ········private GroupBox groupBox1; |
| 63 | ········private CheckBox chkDropExistingElements; |
| 64 | ········private CheckBox chkGenerateFkConstraints; |
| 65 | ········private CheckBox chkIncludeTypecodes; |
| 66 | ········private RadioButton radioDefaultEncoding; |
| 67 | ········private RadioButton radioUtf8Encoding; |
| 68 | ········private Label label4; |
| 69 | ········private ComboBox cbSqlDialect; |
| 70 | ········private CheckBox chkGenerateSQLScript; |
| 71 | ········private CheckBox chkUseTimeStamps; |
| 72 | ········private CheckBox chkChangeEvents; |
| 73 | ········private Label label2; |
| 74 | ········private Button btnConnString; |
| 75 | ········private Button btnOK; |
| 76 | ········private Button btnPresetLibrary; |
| 77 | ········private Button btnCancel; |
| 78 | ········private CheckBox chkMappingNew; |
| 79 | ········private CheckBox chkActivateEnhancer; |
| 80 | ········private CheckBox chkActivateAddIn; |
| 81 | ········private TabPage tabPageAssemblies; |
| 82 | ········private Label label6; |
| 83 | ········private CheckedListBox chlbAssemblies; |
| 84 | ········private ProjectDescription projectDescription; |
| 85 | ········private Button btnInstallProvider; |
| 86 | ········private NDOReference[] references; |
| 87 | |
| 88 | ········public ConfigurationDialog(Project project, ProjectDescription projectDescription) |
| 89 | ········{ |
| 90 | ············try |
| 91 | ············{ |
| 92 | ················this.project = project; |
| 93 | ················this.projectDescription = projectDescription; |
| 94 | ················this.projectDescription.BuildReferences(); |
| 95 | ················this.projectDescription.FixDllState(); |
| 96 | ················InitializeComponent(); |
| 97 | |
| 98 | // Calculate the new font size after InitializeComponent |
| 99 | ················var newFontSize = FontCalculator.Calculate(Screen.FromControl(this), Font.Size); |
| 100 | ················if (newFontSize > Font.Size) |
| 101 | ····················Font = new Font( Font.FontFamily, newFontSize, FontStyle.Regular, GraphicsUnit.Point, 0 ); |
| 102 | |
| 103 | ················var lbAssemblies = (ListBox)this.chlbAssemblies; |
| 104 | ················this.references = projectDescription.References.Values.ToArray(); |
| 105 | ················lbAssemblies.DataSource = this.references; |
| 106 | ················lbAssemblies.DisplayMember = nameof( NDOReference.Name ); |
| 107 | ················lbAssemblies.ValueMember = nameof( NDOReference.CheckState ); |
| 108 | ················int i = 0; |
| 109 | ················foreach (var item in this.references) |
| 110 | ················{ |
| 111 | ····················this.chlbAssemblies.SetItemCheckState( i++, item.CheckState ); |
| 112 | ················} |
| 113 | ············} |
| 114 | ············catch (Exception ex) |
| 115 | ············{ |
| 116 | ················Debug.WriteLine( ex.ToString() ); |
| 117 | ············} |
| 118 | ········} |
| 119 | |
| 120 | ········void CheckEnabledStateForLoadProviderButton() |
| 121 | ········{ |
| 122 | ············string providerName = this.cbSqlDialect.Text; |
| 123 | |
| 124 | ············if (string.IsNullOrEmpty( providerName )) |
| 125 | ············{ |
| 126 | ················this.btnInstallProvider.Enabled = false; |
| 127 | ················return; |
| 128 | ············} |
| 129 | |
| 130 | ············if (IsProviderInstalled(providerName)) |
| 131 | ············{ |
| 132 | ················this.btnInstallProvider.Enabled = false; |
| 133 | ················return; |
| 134 | ············} |
| 135 | |
| 136 | ············this.btnInstallProvider.Enabled = true; |
| 137 | ········} |
| 138 | |
| 139 | ········bool IsProviderInstalled(string providerName) |
| 140 | ········{ |
| 141 | ············IComponentModel componentModel; |
| 142 | ············var installerService = GetInstallerService( out componentModel ); |
| 143 | |
| 144 | ············string packageName = $"ndo.{providerName.ToLower()}"; |
| 145 | ············return installerService.IsPackageInstalled( this.project, packageName ); |
| 146 | ········} |
| 147 | |
| 148 | ········/// <summary> |
| 149 | ········/// Clean up any resources being used. |
| 150 | ········/// </summary> |
| 151 | ········protected override void Dispose( bool disposing ) |
| 152 | ········{ |
| 153 | ············if( disposing ) |
| 154 | ············{ |
| 155 | ················if(components != null) |
| 156 | ················{ |
| 157 | ····················components.Dispose(); |
| 158 | ················} |
| 159 | ············} |
| 160 | ············base.Dispose( disposing ); |
| 161 | ········} |
| 162 | |
| 163 | ········#region Windows Form Designer generated code |
| 164 | ········/// <summary> |
| 165 | ········/// Required method for Designer support - do not modify |
| 166 | ········/// the contents of this method with the code editor. |
| 167 | ········/// </summary> |
| 168 | ········private void InitializeComponent() |
| 169 | ········{ |
| 170 | ············this.components = new System.ComponentModel.Container(); |
| 171 | ············System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConfigurationDialog)); |
| 172 | ············this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); |
| 173 | ············this.chkVerboseMode = new System.Windows.Forms.CheckBox(); |
| 174 | ············this.btnNewDatabase = new System.Windows.Forms.Button(); |
| 175 | ············this.btnSaveAs = new System.Windows.Forms.Button(); |
| 176 | ············this.btnPresetApp = new System.Windows.Forms.Button(); |
| 177 | ············this.txtDbOwner = new System.Windows.Forms.TextBox(); |
| 178 | ············this.txtConnectionString = new System.Windows.Forms.TextBox(); |
| 179 | ············this.chkDropExistingElements = new System.Windows.Forms.CheckBox(); |
| 180 | ············this.chkGenerateFkConstraints = new System.Windows.Forms.CheckBox(); |
| 181 | ············this.chkIncludeTypecodes = new System.Windows.Forms.CheckBox(); |
| 182 | ············this.radioDefaultEncoding = new System.Windows.Forms.RadioButton(); |
| 183 | ············this.radioUtf8Encoding = new System.Windows.Forms.RadioButton(); |
| 184 | ············this.cbSqlDialect = new System.Windows.Forms.ComboBox(); |
| 185 | ············this.chkGenerateSQLScript = new System.Windows.Forms.CheckBox(); |
| 186 | ············this.chkUseTimeStamps = new System.Windows.Forms.CheckBox(); |
| 187 | ············this.chkChangeEvents = new System.Windows.Forms.CheckBox(); |
| 188 | ············this.btnConnString = new System.Windows.Forms.Button(); |
| 189 | ············this.btnPresetLibrary = new System.Windows.Forms.Button(); |
| 190 | ············this.chkMappingNew = new System.Windows.Forms.CheckBox(); |
| 191 | ············this.chkActivateEnhancer = new System.Windows.Forms.CheckBox(); |
| 192 | ············this.chkActivateAddIn = new System.Windows.Forms.CheckBox(); |
| 193 | ············this.tabControl = new System.Windows.Forms.TabControl(); |
| 194 | ············this.tabPageGeneral = new System.Windows.Forms.TabPage(); |
| 195 | ············this.txtTargetMappingFileName = new System.Windows.Forms.TextBox(); |
| 196 | ············this.label1 = new System.Windows.Forms.Label(); |
| 197 | ············this.txtSchemaVersion = new System.Windows.Forms.TextBox(); |
| 198 | ············this.label5 = new System.Windows.Forms.Label(); |
| 199 | ············this.label3 = new System.Windows.Forms.Label(); |
| 200 | ············this.groupBox1 = new System.Windows.Forms.GroupBox(); |
| 201 | ············this.btnInstallProvider = new System.Windows.Forms.Button(); |
| 202 | ············this.label4 = new System.Windows.Forms.Label(); |
| 203 | ············this.label2 = new System.Windows.Forms.Label(); |
| 204 | ············this.tabPageAssemblies = new System.Windows.Forms.TabPage(); |
| 205 | ············this.label6 = new System.Windows.Forms.Label(); |
| 206 | ············this.chlbAssemblies = new System.Windows.Forms.CheckedListBox(); |
| 207 | ············this.btnOK = new System.Windows.Forms.Button(); |
| 208 | ············this.btnCancel = new System.Windows.Forms.Button(); |
| 209 | ············this.tabControl.SuspendLayout(); |
| 210 | ············this.tabPageGeneral.SuspendLayout(); |
| 211 | ············this.groupBox1.SuspendLayout(); |
| 212 | ············this.tabPageAssemblies.SuspendLayout(); |
| 213 | ············this.SuspendLayout(); |
| 214 | ············// |
| 215 | ············// chkVerboseMode |
| 216 | ············// |
| 217 | ············this.chkVerboseMode.Location = new System.Drawing.Point(21, 72); |
| 218 | ············this.chkVerboseMode.Name = "chkVerboseMode"; |
| 219 | ············this.chkVerboseMode.Size = new System.Drawing.Size(238, 21); |
| 220 | ············this.chkVerboseMode.TabIndex = 51; |
| 221 | ············this.chkVerboseMode.Text = "Add-in Verbose Mode"; |
| 222 | ············this.toolTip1.SetToolTip(this.chkVerboseMode, "Causes the Add-in and the Enhancer to show more information for debugging purpose" + |
| 223 | ········"s."); |
| 224 | ············// |
| 225 | ············// btnNewDatabase |
| 226 | ············// |
| 227 | ············this.btnNewDatabase.Location = new System.Drawing.Point(583, 313); |
| 228 | ············this.btnNewDatabase.Name = "btnNewDatabase"; |
| 229 | ············this.btnNewDatabase.Size = new System.Drawing.Size(42, 21); |
| 230 | ············this.btnNewDatabase.TabIndex = 48; |
| 231 | ············this.btnNewDatabase.Text = "New"; |
| 232 | ············this.toolTip1.SetToolTip(this.btnNewDatabase, "Create new database"); |
| 233 | ············this.btnNewDatabase.Click += new System.EventHandler(this.btnNewDatabase_Click); |
| 234 | ············// |
| 235 | ············// btnSaveAs |
| 236 | ············// |
| 237 | ············this.btnSaveAs.DialogResult = System.Windows.Forms.DialogResult.OK; |
| 238 | ············this.btnSaveAs.Location = new System.Drawing.Point(249, 385); |
| 239 | ············this.btnSaveAs.Name = "btnSaveAs"; |
| 240 | ············this.btnSaveAs.Size = new System.Drawing.Size(100, 39); |
| 241 | ············this.btnSaveAs.TabIndex = 47; |
| 242 | ············this.btnSaveAs.Text = "Save as..."; |
| 243 | ············this.toolTip1.SetToolTip(this.btnSaveAs, "Save the options to be used in unattended builds with the stand-alone enhancer."); |
| 244 | ············this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); |
| 245 | ············// |
| 246 | ············// btnPresetApp |
| 247 | ············// |
| 248 | ············this.btnPresetApp.Location = new System.Drawing.Point(135, 385); |
| 249 | ············this.btnPresetApp.Name = "btnPresetApp"; |
| 250 | ············this.btnPresetApp.Size = new System.Drawing.Size(100, 39); |
| 251 | ············this.btnPresetApp.TabIndex = 46; |
| 252 | ············this.btnPresetApp.Text = "Preset for Application"; |
| 253 | ············this.toolTip1.SetToolTip(this.btnPresetApp, "Selects all settings used for applications which don\'t contain but reference pers" + |
| 254 | ········"istent types."); |
| 255 | ············this.btnPresetApp.Click += new System.EventHandler(this.btnPresetApp_Click); |
| 256 | ············// |
| 257 | ············// txtDbOwner |
| 258 | ············// |
| 259 | ············this.txtDbOwner.Location = new System.Drawing.Point(145, 126); |
| 260 | ············this.txtDbOwner.Name = "txtDbOwner"; |
| 261 | ············this.txtDbOwner.Size = new System.Drawing.Size(160, 20); |
| 262 | ············this.txtDbOwner.TabIndex = 45; |
| 263 | ············this.toolTip1.SetToolTip(this.txtDbOwner, "Enter an owner name, if you like your tables to be written like owner.tablename."); |
| 264 | ············// |
| 265 | ············// txtConnectionString |
| 266 | ············// |
| 267 | ············this.txtConnectionString.Location = new System.Drawing.Point(18, 313); |
| 268 | ············this.txtConnectionString.Name = "txtConnectionString"; |
| 269 | ············this.txtConnectionString.Size = new System.Drawing.Size(514, 20); |
| 270 | ············this.txtConnectionString.TabIndex = 39; |
| 271 | ············this.toolTip1.SetToolTip(this.txtConnectionString, "This string will be copied into the mapping file, if there doesn\'t exist a valid " + |
| 272 | ········"connection string. Otherwise it will be ignored."); |
| 273 | ············// |
| 274 | ············// chkDropExistingElements |
| 275 | ············// |
| 276 | ············this.chkDropExistingElements.Location = new System.Drawing.Point(13, 202); |
| 277 | ············this.chkDropExistingElements.Name = "chkDropExistingElements"; |
| 278 | ············this.chkDropExistingElements.Size = new System.Drawing.Size(235, 21); |
| 279 | ············this.chkDropExistingElements.TabIndex = 24; |
| 280 | ············this.chkDropExistingElements.Text = "Insert Drop Statements in the Script"; |
| 281 | ············this.toolTip1.SetToolTip(this.chkDropExistingElements, "If checked, NDO generates instructions to remove existing tables and constraints." + |
| 282 | ········""); |
| 283 | ············// |
| 284 | ············// chkGenerateFkConstraints |
| 285 | ············// |
| 286 | ············this.chkGenerateFkConstraints.Location = new System.Drawing.Point(13, 152); |
| 287 | ············this.chkGenerateFkConstraints.Name = "chkGenerateFkConstraints"; |
| 288 | ············this.chkGenerateFkConstraints.Size = new System.Drawing.Size(235, 21); |
| 289 | ············this.chkGenerateFkConstraints.TabIndex = 23; |
| 290 | ············this.chkGenerateFkConstraints.Text = "Generate Foreign Key Constraints"; |
| 291 | ············this.toolTip1.SetToolTip(this.chkGenerateFkConstraints, "If checked, NDO generates foreign key constraints for the relations in the databa" + |
| 292 | ········"se."); |
| 293 | ············// |
| 294 | ············// chkIncludeTypecodes |
| 295 | ············// |
| 296 | ············this.chkIncludeTypecodes.Location = new System.Drawing.Point(13, 177); |
| 297 | ············this.chkIncludeTypecodes.Name = "chkIncludeTypecodes"; |
| 298 | ············this.chkIncludeTypecodes.Size = new System.Drawing.Size(235, 21); |
| 299 | ············this.chkIncludeTypecodes.TabIndex = 22; |
| 300 | ············this.chkIncludeTypecodes.Text = "Include Typecodes in the Script"; |
| 301 | ············this.toolTip1.SetToolTip(this.chkIncludeTypecodes, "If checked, NDO generates instructions to build an additional table with the type" + |
| 302 | ········" code information."); |
| 303 | ············// |
| 304 | ············// radioDefaultEncoding |
| 305 | ············// |
| 306 | ············this.radioDefaultEncoding.Location = new System.Drawing.Point(13, 121); |
| 307 | ············this.radioDefaultEncoding.Name = "radioDefaultEncoding"; |
| 308 | ············this.radioDefaultEncoding.Size = new System.Drawing.Size(140, 20); |
| 309 | ············this.radioDefaultEncoding.TabIndex = 21; |
| 310 | ············this.radioDefaultEncoding.Text = "Default Encoding"; |
| 311 | ············this.toolTip1.SetToolTip(this.radioDefaultEncoding, "Check this option, if the script files should use windows encoding."); |
| 312 | ············// |
| 313 | ············// radioUtf8Encoding |
| 314 | ············// |
| 315 | ············this.radioUtf8Encoding.Checked = true; |
| 316 | ············this.radioUtf8Encoding.Location = new System.Drawing.Point(13, 99); |
| 317 | ············this.radioUtf8Encoding.Name = "radioUtf8Encoding"; |
| 318 | ············this.radioUtf8Encoding.Size = new System.Drawing.Size(140, 21); |
| 319 | ············this.radioUtf8Encoding.TabIndex = 20; |
| 320 | ············this.radioUtf8Encoding.TabStop = true; |
| 321 | ············this.radioUtf8Encoding.Text = "UTF-8 Encoding"; |
| 322 | ············this.toolTip1.SetToolTip(this.radioUtf8Encoding, "Check this option, if the script files should be UTF-8 encoded."); |
| 323 | ············// |
| 324 | ············// cbSqlDialect |
| 325 | ············// |
| 326 | ············this.cbSqlDialect.Location = new System.Drawing.Point(13, 70); |
| 327 | ············this.cbSqlDialect.Name = "cbSqlDialect"; |
| 328 | ············this.cbSqlDialect.Size = new System.Drawing.Size(220, 21); |
| 329 | ············this.cbSqlDialect.TabIndex = 18; |
| 330 | ············this.toolTip1.SetToolTip(this.cbSqlDialect, "Choose an available NDO provider."); |
| 331 | ············this.cbSqlDialect.SelectedIndexChanged += new System.EventHandler(this.cbSqlDialect_SelectedIndexChanged); |
| 332 | ············// |
| 333 | ············// chkGenerateSQLScript |
| 334 | ············// |
| 335 | ············this.chkGenerateSQLScript.Location = new System.Drawing.Point(13, 21); |
| 336 | ············this.chkGenerateSQLScript.Name = "chkGenerateSQLScript"; |
| 337 | ············this.chkGenerateSQLScript.Size = new System.Drawing.Size(187, 21); |
| 338 | ············this.chkGenerateSQLScript.TabIndex = 13; |
| 339 | ············this.chkGenerateSQLScript.Text = "Generate SQL Script"; |
| 340 | ············this.toolTip1.SetToolTip(this.chkGenerateSQLScript, "If checked, NDO will create a script with DDL code, which can be used to construc" + |
| 341 | ········"t a database structure."); |
| 342 | ············this.chkGenerateSQLScript.CheckedChanged += new System.EventHandler(this.chkGenerateSQLScript_CheckedChanged); |
| 343 | ············// |
| 344 | ············// chkUseTimeStamps |
| 345 | ············// |
| 346 | ············this.chkUseTimeStamps.Location = new System.Drawing.Point(21, 153); |
| 347 | ············this.chkUseTimeStamps.Name = "chkUseTimeStamps"; |
| 348 | ············this.chkUseTimeStamps.Size = new System.Drawing.Size(302, 20); |
| 349 | ············this.chkUseTimeStamps.TabIndex = 42; |
| 350 | ············this.chkUseTimeStamps.Text = "Generate Time Stamp Columns for each class"; |
| 351 | ············this.toolTip1.SetToolTip(this.chkUseTimeStamps, "Check this option, if all tables should be protected by collistion detection."); |
| 352 | ············// |
| 353 | ············// chkChangeEvents |
| 354 | ············// |
| 355 | ············this.chkChangeEvents.Location = new System.Drawing.Point(21, 179); |
| 356 | ············this.chkChangeEvents.Name = "chkChangeEvents"; |
| 357 | ············this.chkChangeEvents.Size = new System.Drawing.Size(302, 21); |
| 358 | ············this.chkChangeEvents.TabIndex = 41; |
| 359 | ············this.chkChangeEvents.Text = "Generate change events with Add Accessor"; |
| 360 | ············this.toolTip1.SetToolTip(this.chkChangeEvents, "Check this option, if you intend to bind the UI directly to the accessor properti" + |
| 361 | ········"es of your persistent classes."); |
| 362 | ············// |
| 363 | ············// btnConnString |
| 364 | ············// |
| 365 | ············this.btnConnString.Location = new System.Drawing.Point(538, 313); |
| 366 | ············this.btnConnString.Name = "btnConnString"; |
| 367 | ············this.btnConnString.Size = new System.Drawing.Size(42, 21); |
| 368 | ············this.btnConnString.TabIndex = 38; |
| 369 | ············this.btnConnString.Text = "..."; |
| 370 | ············this.toolTip1.SetToolTip(this.btnConnString, "Enter existing database connection"); |
| 371 | ············this.btnConnString.Click += new System.EventHandler(this.btnConnString_Click); |
| 372 | ············// |
| 373 | ············// btnPresetLibrary |
| 374 | ············// |
| 375 | ············this.btnPresetLibrary.Location = new System.Drawing.Point(21, 385); |
| 376 | ············this.btnPresetLibrary.Name = "btnPresetLibrary"; |
| 377 | ············this.btnPresetLibrary.Size = new System.Drawing.Size(100, 39); |
| 378 | ············this.btnPresetLibrary.TabIndex = 36; |
| 379 | ············this.btnPresetLibrary.Text = "Preset for Library"; |
| 380 | ············this.toolTip1.SetToolTip(this.btnPresetLibrary, "Selects all settings necessary for projects containing persistent types."); |
| 381 | ············this.btnPresetLibrary.Click += new System.EventHandler(this.btnPresetLibrary_Click); |
| 382 | ············// |
| 383 | ············// chkMappingNew |
| 384 | ············// |
| 385 | ············this.chkMappingNew.Location = new System.Drawing.Point(21, 99); |
| 386 | ············this.chkMappingNew.Name = "chkMappingNew"; |
| 387 | ············this.chkMappingNew.Size = new System.Drawing.Size(272, 21); |
| 388 | ············this.chkMappingNew.TabIndex = 34; |
| 389 | ············this.chkMappingNew.Text = "Always Generate a new mapping File"; |
| 390 | ············this.toolTip1.SetToolTip(this.chkMappingNew, "Choose this options, if NDO should discard and rebuild all mapping information."); |
| 391 | ············// |
| 392 | ············// chkActivateEnhancer |
| 393 | ············// |
| 394 | ············this.chkActivateEnhancer.Location = new System.Drawing.Point(21, 46); |
| 395 | ············this.chkActivateEnhancer.Name = "chkActivateEnhancer"; |
| 396 | ············this.chkActivateEnhancer.Size = new System.Drawing.Size(188, 20); |
| 397 | ············this.chkActivateEnhancer.TabIndex = 33; |
| 398 | ············this.chkActivateEnhancer.Text = "Activate enhancer"; |
| 399 | ············this.toolTip1.SetToolTip(this.chkActivateEnhancer, "Choose this option, if your project contains persistent types."); |
| 400 | ············// |
| 401 | ············// chkActivateAddIn |
| 402 | ············// |
| 403 | ············this.chkActivateAddIn.Location = new System.Drawing.Point(21, 19); |
| 404 | ············this.chkActivateAddIn.Name = "chkActivateAddIn"; |
| 405 | ············this.chkActivateAddIn.Size = new System.Drawing.Size(188, 21); |
| 406 | ············this.chkActivateAddIn.TabIndex = 32; |
| 407 | ············this.chkActivateAddIn.Text = "Activate NDO AddIn"; |
| 408 | ············this.toolTip1.SetToolTip(this.chkActivateAddIn, "Choose this options, if your project contains or references persistent types."); |
| 409 | ············this.chkActivateAddIn.Click += new System.EventHandler(this.chkActivateAddIn_CheckedChanged); |
| 410 | ············// |
| 411 | ············// tabControl |
| 412 | ············// |
| 413 | ············this.tabControl.Controls.Add(this.tabPageGeneral); |
| 414 | ············this.tabControl.Controls.Add(this.tabPageAssemblies); |
| 415 | ············this.tabControl.Dock = System.Windows.Forms.DockStyle.Top; |
| 416 | ············this.tabControl.Location = new System.Drawing.Point(0, 0); |
| 417 | ············this.tabControl.Name = "tabControl"; |
| 418 | ············this.tabControl.SelectedIndex = 0; |
| 419 | ············this.tabControl.Size = new System.Drawing.Size(661, 374); |
| 420 | ············this.tabControl.TabIndex = 0; |
| 421 | ············// |
| 422 | ············// tabPageGeneral |
| 423 | ············// |
| 424 | ············this.tabPageGeneral.Controls.Add(this.txtTargetMappingFileName); |
| 425 | ············this.tabPageGeneral.Controls.Add(this.label1); |
| 426 | ············this.tabPageGeneral.Controls.Add(this.chkVerboseMode); |
| 427 | ············this.tabPageGeneral.Controls.Add(this.txtSchemaVersion); |
| 428 | ············this.tabPageGeneral.Controls.Add(this.label5); |
| 429 | ············this.tabPageGeneral.Controls.Add(this.btnNewDatabase); |
| 430 | ············this.tabPageGeneral.Controls.Add(this.txtDbOwner); |
| 431 | ············this.tabPageGeneral.Controls.Add(this.txtConnectionString); |
| 432 | ············this.tabPageGeneral.Controls.Add(this.label3); |
| 433 | ············this.tabPageGeneral.Controls.Add(this.groupBox1); |
| 434 | ············this.tabPageGeneral.Controls.Add(this.chkUseTimeStamps); |
| 435 | ············this.tabPageGeneral.Controls.Add(this.chkChangeEvents); |
| 436 | ············this.tabPageGeneral.Controls.Add(this.label2); |
| 437 | ············this.tabPageGeneral.Controls.Add(this.btnConnString); |
| 438 | ············this.tabPageGeneral.Controls.Add(this.chkMappingNew); |
| 439 | ············this.tabPageGeneral.Controls.Add(this.chkActivateEnhancer); |
| 440 | ············this.tabPageGeneral.Controls.Add(this.chkActivateAddIn); |
| 441 | ············this.tabPageGeneral.Location = new System.Drawing.Point(4, 22); |
| 442 | ············this.tabPageGeneral.Name = "tabPageGeneral"; |
| 443 | ············this.tabPageGeneral.Padding = new System.Windows.Forms.Padding(3); |
| 444 | ············this.tabPageGeneral.Size = new System.Drawing.Size(653, 348); |
| 445 | ············this.tabPageGeneral.TabIndex = 0; |
| 446 | ············this.tabPageGeneral.Text = "General"; |
| 447 | ············this.tabPageGeneral.UseVisualStyleBackColor = true; |
| 448 | ············// |
| 449 | ············// txtTargetMappingFileName |
| 450 | ············// |
| 451 | ············this.txtTargetMappingFileName.Location = new System.Drawing.Point(145, 245); |
| 452 | ············this.txtTargetMappingFileName.Name = "txtTargetMappingFileName"; |
| 453 | ············this.txtTargetMappingFileName.Size = new System.Drawing.Size(160, 20); |
| 454 | ············this.txtTargetMappingFileName.TabIndex = 53; |
| 455 | ············// |
| 456 | ············// label1 |
| 457 | ············// |
| 458 | ············this.label1.Location = new System.Drawing.Point(18, 246); |
| 459 | ············this.label1.Name = "label1"; |
| 460 | ············this.label1.Size = new System.Drawing.Size(121, 21); |
| 461 | ············this.label1.TabIndex = 52; |
| 462 | ············this.label1.Text = "Mapping File Name"; |
| 463 | ············// |
| 464 | ············// txtSchemaVersion |
| 465 | ············// |
| 466 | ············this.txtSchemaVersion.Location = new System.Drawing.Point(145, 219); |
| 467 | ············this.txtSchemaVersion.Name = "txtSchemaVersion"; |
| 468 | ············this.txtSchemaVersion.Size = new System.Drawing.Size(160, 20); |
| 469 | ············this.txtSchemaVersion.TabIndex = 50; |
| 470 | ············// |
| 471 | ············// label5 |
| 472 | ············// |
| 473 | ············this.label5.Location = new System.Drawing.Point(18, 220); |
| 474 | ············this.label5.Name = "label5"; |
| 475 | ············this.label5.Size = new System.Drawing.Size(121, 21); |
| 476 | ············this.label5.TabIndex = 49; |
| 477 | ············this.label5.Text = "Schema Version"; |
| 478 | ············// |
| 479 | ············// label3 |
| 480 | ············// |
| 481 | ············this.label3.Location = new System.Drawing.Point(18, 128); |
| 482 | ············this.label3.Name = "label3"; |
| 483 | ············this.label3.Size = new System.Drawing.Size(127, 21); |
| 484 | ············this.label3.TabIndex = 44; |
| 485 | ············this.label3.Text = "Owner / Schema Name"; |
| 486 | ············// |
| 487 | ············// groupBox1 |
| 488 | ············// |
| 489 | ············this.groupBox1.Controls.Add(this.btnInstallProvider); |
| 490 | ············this.groupBox1.Controls.Add(this.chkDropExistingElements); |
| 491 | ············this.groupBox1.Controls.Add(this.chkGenerateFkConstraints); |
| 492 | ············this.groupBox1.Controls.Add(this.chkIncludeTypecodes); |
| 493 | ············this.groupBox1.Controls.Add(this.radioDefaultEncoding); |
| 494 | ············this.groupBox1.Controls.Add(this.radioUtf8Encoding); |
| 495 | ············this.groupBox1.Controls.Add(this.label4); |
| 496 | ············this.groupBox1.Controls.Add(this.cbSqlDialect); |
| 497 | ············this.groupBox1.Controls.Add(this.chkGenerateSQLScript); |
| 498 | ············this.groupBox1.Location = new System.Drawing.Point(343, 21); |
| 499 | ············this.groupBox1.Name = "groupBox1"; |
| 500 | ············this.groupBox1.Size = new System.Drawing.Size(265, 244); |
| 501 | ············this.groupBox1.TabIndex = 43; |
| 502 | ············this.groupBox1.TabStop = false; |
| 503 | ············this.groupBox1.Text = " SQL "; |
| 504 | ············// |
| 505 | ············// btnInstallProvider |
| 506 | ············// |
| 507 | ············this.btnInstallProvider.Location = new System.Drawing.Point(142, 102); |
| 508 | ············this.btnInstallProvider.Name = "btnInstallProvider"; |
| 509 | ············this.btnInstallProvider.Size = new System.Drawing.Size(91, 22); |
| 510 | ············this.btnInstallProvider.TabIndex = 25; |
| 511 | ············this.btnInstallProvider.Text = "Install Provider"; |
| 512 | ············this.btnInstallProvider.UseVisualStyleBackColor = true; |
| 513 | ············this.btnInstallProvider.Click += new System.EventHandler(this.btnInstallProvider_Click); |
| 514 | ············// |
| 515 | ············// label4 |
| 516 | ············// |
| 517 | ············this.label4.Location = new System.Drawing.Point(13, 50); |
| 518 | ············this.label4.Name = "label4"; |
| 519 | ············this.label4.Size = new System.Drawing.Size(200, 17); |
| 520 | ············this.label4.TabIndex = 19; |
| 521 | ············this.label4.Text = "SQL Dialect"; |
| 522 | ············// |
| 523 | ············// label2 |
| 524 | ············// |
| 525 | ············this.label2.Location = new System.Drawing.Point(18, 292); |
| 526 | ············this.label2.Name = "label2"; |
| 527 | ············this.label2.Size = new System.Drawing.Size(360, 21); |
| 528 | ············this.label2.TabIndex = 40; |
| 529 | ············this.label2.Text = "Default Connection String"; |
| 530 | ············// |
| 531 | ············// tabPageAssemblies |
| 532 | ············// |
| 533 | ············this.tabPageAssemblies.Controls.Add(this.label6); |
| 534 | ············this.tabPageAssemblies.Controls.Add(this.chlbAssemblies); |
| 535 | ············this.tabPageAssemblies.Location = new System.Drawing.Point(4, 22); |
| 536 | ············this.tabPageAssemblies.Name = "tabPageAssemblies"; |
| 537 | ············this.tabPageAssemblies.Padding = new System.Windows.Forms.Padding(3); |
| 538 | ············this.tabPageAssemblies.Size = new System.Drawing.Size(653, 348); |
| 539 | ············this.tabPageAssemblies.TabIndex = 1; |
| 540 | ············this.tabPageAssemblies.Text = "Assemblies"; |
| 541 | ············this.tabPageAssemblies.UseVisualStyleBackColor = true; |
| 542 | ············// |
| 543 | ············// label6 |
| 544 | ············// |
| 545 | ············this.label6.AutoSize = true; |
| 546 | ············this.label6.Location = new System.Drawing.Point(10, 12); |
| 547 | ············this.label6.Name = "label6"; |
| 548 | ············this.label6.Size = new System.Drawing.Size(328, 13); |
| 549 | ············this.label6.TabIndex = 1; |
| 550 | ············this.label6.Text = "Choose Assemblies which should be analyzed by the NDOEnhancer"; |
| 551 | ············// |
| 552 | ············// chlbAssemblies |
| 553 | ············// |
| 554 | ············this.chlbAssemblies.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
| 555 | ············| System.Windows.Forms.AnchorStyles.Left) |
| 556 | ············| System.Windows.Forms.AnchorStyles.Right))); |
| 557 | ············this.chlbAssemblies.FormattingEnabled = true; |
| 558 | ············this.chlbAssemblies.Location = new System.Drawing.Point(10, 39); |
| 559 | ············this.chlbAssemblies.Name = "chlbAssemblies"; |
| 560 | ············this.chlbAssemblies.Size = new System.Drawing.Size(631, 289); |
| 561 | ············this.chlbAssemblies.TabIndex = 0; |
| 562 | ············this.chlbAssemblies.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.chlbAssemblies_ItemCheck); |
| 563 | ············// |
| 564 | ············// btnOK |
| 565 | ············// |
| 566 | ············this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; |
| 567 | ············this.btnOK.Location = new System.Drawing.Point(363, 385); |
| 568 | ············this.btnOK.Name = "btnOK"; |
| 569 | ············this.btnOK.Size = new System.Drawing.Size(100, 39); |
| 570 | ············this.btnOK.TabIndex = 37; |
| 571 | ············this.btnOK.Text = "OK"; |
| 572 | ············this.btnOK.Click += new System.EventHandler(this.btnOK_Click); |
| 573 | ············// |
| 574 | ············// btnCancel |
| 575 | ············// |
| 576 | ············this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
| 577 | ············this.btnCancel.Location = new System.Drawing.Point(477, 385); |
| 578 | ············this.btnCancel.Name = "btnCancel"; |
| 579 | ············this.btnCancel.Size = new System.Drawing.Size(100, 39); |
| 580 | ············this.btnCancel.TabIndex = 35; |
| 581 | ············this.btnCancel.Text = "Cancel"; |
| 582 | ············// |
| 583 | ············// ConfigurationDialog |
| 584 | ············// |
| 585 | ············this.AutoScaleMode = AutoScaleMode.Font; |
| 586 | ············this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
| 587 | ············this.CancelButton = this.btnCancel; |
| 588 | ············this.ClientSize = new System.Drawing.Size(661, 439); |
| 589 | ············this.Controls.Add(this.btnSaveAs); |
| 590 | ············this.Controls.Add(this.btnPresetApp); |
| 591 | ············this.Controls.Add(this.btnOK); |
| 592 | ············this.Controls.Add(this.btnPresetLibrary); |
| 593 | ············this.Controls.Add(this.btnCancel); |
| 594 | ············this.Controls.Add(this.tabControl); |
| 595 | ············this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); |
| 596 | ············this.Name = "ConfigurationDialog"; |
| 597 | ············this.Text = "NDO Configuration"; |
| 598 | ············this.Load += new System.EventHandler(this.ConfigurationDialog_Load); |
| 599 | ············this.tabControl.ResumeLayout(false); |
| 600 | ············this.tabPageGeneral.ResumeLayout(false); |
| 601 | ············this.tabPageGeneral.PerformLayout(); |
| 602 | ············this.groupBox1.ResumeLayout(false); |
| 603 | ············this.tabPageAssemblies.ResumeLayout(false); |
| 604 | ············this.tabPageAssemblies.PerformLayout(); |
| 605 | ············this.ResumeLayout(false); |
| 606 | |
| 607 | ········} |
| 608 | ········#endregion |
| 609 | |
| 610 | ········private void chkActivateAddIn_CheckedChanged(object sender, System.EventArgs e) |
| 611 | ········{ |
| 612 | ············EnableAddin(this.chkActivateAddIn.Checked); |
| 613 | ········} |
| 614 | |
| 615 | |
| 616 | ········void EnableAddin(bool enabled) |
| 617 | ········{ |
| 618 | ············if (project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 619 | ················chkActivateEnhancer.Enabled = false; |
| 620 | ············else |
| 621 | ················chkActivateEnhancer.Enabled = enabled; |
| 622 | ········} |
| 623 | |
| 624 | ········private void ConfigurationDialog_Load(object sender, System.EventArgs e) |
| 625 | ········{ |
| 626 | ············try |
| 627 | ············{ |
| 628 | ················ConfigurationOptions options = new ConfigurationOptions(project); |
| 629 | ················this.Text = "NDO Configuration - " + project.Name; |
| 630 | ················chkIncludeTypecodes.Checked = options.IncludeTypecodes; |
| 631 | ················chkDropExistingElements.Checked = options.DropExistingElements; |
| 632 | ················chkGenerateFkConstraints.Checked = options.GenerateConstraints; |
| 633 | ················chkVerboseMode.Checked = options.VerboseMode; |
| 634 | ················chkChangeEvents.Checked = options.GenerateChangeEvents; |
| 635 | ················chkActivateAddIn.Checked = options.EnableAddIn; |
| 636 | ················chkActivateEnhancer.Checked = options.EnableEnhancer; |
| 637 | ················chkMappingNew.Checked = options.NewMapping; |
| 638 | ················if (chkActivateAddIn.Checked == false) |
| 639 | ····················EnableAddin(false); |
| 640 | ················chkGenerateSQLScript.Checked = options.GenerateSQL; |
| 641 | ················txtSchemaVersion.Text = options.SchemaVersion; |
| 642 | ················if (string.IsNullOrEmpty(txtSchemaVersion.Text)) |
| 643 | ····················txtSchemaVersion.Text = "1.0"; |
| 644 | ················this.chkUseTimeStamps.Checked = options.UseTimeStamps; |
| 645 | ················int i = 0; |
| 646 | ················this.cbSqlDialect.Items.Clear(); |
| 647 | ················int currentDialectIndex = -1; |
| 648 | |
| 649 | ················foreach (string s in NdoUIProviderFactory.Instance.Keys) |
| 650 | ················{ |
| 651 | ····················this.cbSqlDialect.Items.Add( s ); |
| 652 | ····················if (options.SQLScriptLanguage == s) |
| 653 | ························currentDialectIndex = i; |
| 654 | ····················i++; |
| 655 | ················} |
| 656 | ················if (currentDialectIndex > -1) |
| 657 | ····················cbSqlDialect.SelectedIndex = currentDialectIndex; |
| 658 | |
| 659 | ················// Must be initialized after changing the cbSqlDialect index |
| 660 | ················txtConnectionString.Text = options.DefaultConnection; |
| 661 | ················txtTargetMappingFileName.Text = options.TargetMappingFileName; |
| 662 | ················txtDbOwner.Text = options.DatabaseOwner; |
| 663 | ················chkActivateAddIn_CheckedChanged(null, EventArgs.Empty); |
| 664 | ················chkGenerateSQLScript_CheckedChanged(null, EventArgs.Empty); |
| 665 | ················if (options.Utf8Encoding) |
| 666 | ····················radioUtf8Encoding.Checked = true; |
| 667 | ················else |
| 668 | ····················radioDefaultEncoding.Checked = true; |
| 669 | ················if (project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 670 | ····················this.chkActivateEnhancer.Enabled = false; |
| 671 | |
| 672 | ················CheckEnabledStateForLoadProviderButton(); |
| 673 | ············} |
| 674 | ············catch (Exception ex) |
| 675 | ············{ |
| 676 | #if !DEBUG |
| 677 | ················MessageBox.Show(ex.Message, "NDO Configuration"); |
| 678 | #else |
| 679 | ················MessageBox.Show(ex.ToString(), "NDO Configuration"); |
| 680 | #endif |
| 681 | ············} |
| 682 | ········} |
| 683 | |
| 684 | ········private void btnPresetLibrary_Click(object sender, System.EventArgs e) |
| 685 | ········{ |
| 686 | //············ConfigurationOptions options = new ConfigurationOptions( project ); |
| 687 | ············try |
| 688 | ············{ |
| 689 | ················EnableCheckBoxes(); |
| 690 | |
| 691 | ················this.chkVerboseMode.Checked = false; |
| 692 | ················this.chkActivateAddIn.Checked = true; |
| 693 | ················this.chkActivateEnhancer.Checked = true; |
| 694 | ················this.chkMappingNew.Checked = false; |
| 695 | ················this.chkChangeEvents.Checked = false; |
| 696 | ················this.chkIncludeTypecodes.Checked = false; |
| 697 | ················this.chkGenerateFkConstraints.Checked = false; |
| 698 | ················this.chkDropExistingElements.Checked = false; |
| 699 | ················this.chkUseTimeStamps.Checked = false;···· |
| 700 | ················this.txtDbOwner.Text = ""; |
| 701 | ················this.chkGenerateSQLScript.Checked = false; |
| 702 | ················this.txtSchemaVersion.Text = ""; |
| 703 | ············} |
| 704 | ············catch (Exception ex) |
| 705 | ············{ |
| 706 | ················ShowError(ex); |
| 707 | ············} |
| 708 | ········} |
| 709 | |
| 710 | |
| 711 | ········private void btnOK_Click(object sender, System.EventArgs e) |
| 712 | ········{ |
| 713 | ············try |
| 714 | ············{ |
| 715 | ················ConfigurationOptions options = new ConfigurationOptions( project ); |
| 716 | |
| 717 | ················string connType = options.SQLScriptLanguage; |
| 718 | ················string connName = options.DefaultConnection; |
| 719 | ················WriteBack(options); |
| 720 | ················if (options.SQLScriptLanguage != connType || options.DefaultConnection != connName) |
| 721 | ················{ |
| 722 | ····················string mappingFileName = this.project.MappingFilePath(); |
| 723 | ····················if (mappingFileName != null) |
| 724 | ····················{ |
| 725 | ························NDOMapping mapping = new NDOMapping(mappingFileName); |
| 726 | ························bool connectionExists = false; |
| 727 | ························foreach (Connection conn in mapping.Connections) |
| 728 | ························{ |
| 729 | ····························if (conn.Type == options.SQLScriptLanguage && conn.Name == options.DefaultConnection) |
| 730 | ····························{ |
| 731 | ································connectionExists = true; |
| 732 | ································break; |
| 733 | ····························} |
| 734 | ························} |
| 735 | ························if (!connectionExists) |
| 736 | ························{ |
| 737 | ····························if (MessageBox.Show("The database connection settings have been changed. Should NDO change the connection settings in the mapping file " + Path.GetFileName(mappingFileName) + " too?", "NDO Configuration", MessageBoxButtons.YesNo) == DialogResult.Yes) |
| 738 | ····························{ |
| 739 | ································Connection conn = null; |
| 740 | ································if (mapping.Connections.Count() == 1) |
| 741 | ································{ |
| 742 | ····································conn = (Connection)mapping.Connections.FirstOrDefault(); |
| 743 | ································} |
| 744 | ································else |
| 745 | ································{ |
| 746 | ····································conn = mapping.NewConnection(String.Empty, String.Empty); |
| 747 | ····································MessageBox.Show("Added a connection with the ID " + conn.ID, "NDO Configuration"); |
| 748 | ································} |
| 749 | ································conn.Type = options.SQLScriptLanguage; |
| 750 | ································conn.Name = options.DefaultConnection; |
| 751 | ································mapping.Save(); |
| 752 | ····························} |
| 753 | ························} |
| 754 | ····················} |
| 755 | ················} |
| 756 | |
| 757 | ················if ( options.EnableAddIn ) |
| 758 | ················{ |
| 759 | ····················GeneratePackageReference(); |
| 760 | ················} |
| 761 | |
| 762 | ················ThreadHelper.JoinableTaskFactory.Run( async () => await options.SaveAsync( this.projectDescription ) ); |
| 763 | ················ |
| 764 | ············} |
| 765 | ············catch (Exception ex) |
| 766 | ············{ |
| 767 | #if DEBUG |
| 768 | ················MessageBox.Show( "The following error occured while saving your options: " + ex.ToString(), "NDO Add-in" ); |
| 769 | #else |
| 770 | ················MessageBox.Show("The following error occured while saving your options: " + ex.Message, "NDO Add-in"); |
| 771 | #endif |
| 772 | ············} |
| 773 | ········} |
| 774 | |
| 775 | |
| 776 | ········void GeneratePackageReference() |
| 777 | ········{ |
| 778 | ············try |
| 779 | ············{ |
| 780 | ················IComponentModel componentModel; |
| 781 | ················var installerService = GetInstallerService( out componentModel ); |
| 782 | |
| 783 | ················if (!installerService.IsPackageInstalled( this.project, "ndo.dll" )) |
| 784 | ················{ |
| 785 | ····················var installer = componentModel.GetService<IVsPackageInstaller>(); |
| 786 | ····················// The newest version of NDO will be v5.x at the time, this package is released. |
| 787 | ····················// NDO5 needs the NDO.build package in all use cases. |
| 788 | ····················// If the enhancer is not to be used, uninstalling ndo.build is sufficient |
| 789 | ····················// because it will only be reinstalled if the NDO.dll package is missing. |
| 790 | ····················installer.InstallPackage( null, this.project, "NDO.dll", (string)null, false ); |
| 791 | ····················installer.InstallPackage( null, this.project, "NDO.build", (string) null, false ); |
| 792 | ················} |
| 793 | ············} |
| 794 | ············catch (Exception ex) |
| 795 | ············{ |
| 796 | ················MessageBox.Show( "Error while installing the ndo.dll package: " + ex.ToString() ); |
| 797 | ············} |
| 798 | ········} |
| 799 | |
| 800 | ········private static IVsPackageInstallerServices GetInstallerService( out IComponentModel componentModel ) |
| 801 | ········{ |
| 802 | ············componentModel = (IComponentModel)Package.GetGlobalService( typeof( SComponentModel ) ); |
| 803 | ············var installerService = componentModel.GetService<IVsPackageInstallerServices>(); |
| 804 | ············return installerService; |
| 805 | ········} |
| 806 | |
| 807 | ········void ShowError(Exception ex) |
| 808 | ········{ |
| 809 | ············MessageBox.Show("The following error occured: " + ex.Message, "NDO Add-in"); |
| 810 | ········} |
| 811 | |
| 812 | ········private void btnConnString_Click(object sender, System.EventArgs e) |
| 813 | ········{ |
| 814 | ············try |
| 815 | ············{ |
| 816 | ················string connType = cbSqlDialect.Text; |
| 817 | ················if (connType == string.Empty) |
| 818 | ····················connType = "SqlServer"; |
| 819 | ················var provider = NdoUIProviderFactory.Instance[connType]; |
| 820 | ················if (provider == null) |
| 821 | ················{ |
| 822 | ····················MessageBox.Show("Can't find a NDO UI provider for the sql dialect " + connType); |
| 823 | ····················return; |
| 824 | ················} |
| 825 | |
| 826 | ················string temp = this.txtConnectionString.Text; |
| 827 | ················NdoDialogResult r = provider.ShowConnectionDialog(ref temp); |
| 828 | ················if (r == NdoDialogResult.Cancel) |
| 829 | ····················return; |
| 830 | ················this.txtConnectionString.Text = temp; |
| 831 | ············} |
| 832 | ············catch (Exception ex) |
| 833 | ············{ |
| 834 | ················ShowError(ex); |
| 835 | ············} |
| 836 | ········} |
| 837 | |
| 838 | |
| 839 | ········private void chkGenerateSQLScript_CheckedChanged(object sender, System.EventArgs e) |
| 840 | ········{ |
| 841 | ············bool genSql = this.chkGenerateSQLScript.Checked; |
| 842 | |
| 843 | ············this.cbSqlDialect.Enabled = genSql; |
| 844 | ············this.chkIncludeTypecodes.Enabled = genSql; |
| 845 | ············this.chkDropExistingElements.Enabled = genSql; |
| 846 | ············this.chkGenerateFkConstraints.Enabled = genSql; |
| 847 | ············this.radioUtf8Encoding.Enabled = genSql; |
| 848 | ············this.radioDefaultEncoding.Enabled = genSql; |
| 849 | ········} |
| 850 | |
| 851 | ········private void EnableCheckBoxes() |
| 852 | ········{ |
| 853 | ············foreach(Control c in this.Controls) |
| 854 | ············{ |
| 855 | ················CheckBox cb = c as CheckBox; |
| 856 | ················if (c == null) |
| 857 | ····················continue; |
| 858 | ················c.Enabled = true; |
| 859 | ············} |
| 860 | ············if (this.project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}") |
| 861 | ················this.chkActivateEnhancer.Enabled = false; |
| 862 | ········} |
| 863 | |
| 864 | ········private void btnPresetApp_Click(object sender, System.EventArgs e) |
| 865 | ········{ |
| 866 | ············try |
| 867 | ············{ |
| 868 | ················EnableCheckBoxes(); |
| 869 | ················this.chkVerboseMode.Checked = false; |
| 870 | ················this.chkActivateAddIn.Checked = true; |
| 871 | ················this.chkActivateEnhancer.Checked = false; |
| 872 | ················this.chkMappingNew.Checked = false; |
| 873 | ················this.chkGenerateSQLScript.Checked = true; |
| 874 | ················this.chkChangeEvents.Checked = false; |
| 875 | ················this.chkIncludeTypecodes.Checked = false; |
| 876 | ················this.chkDropExistingElements.Checked = false; |
| 877 | ················this.chkGenerateFkConstraints.Checked = false; |
| 878 | ················this.txtConnectionString.Text = ""; |
| 879 | ················this.chkUseTimeStamps.Checked = false; |
| 880 | ················this.txtDbOwner.Text = ""; |
| 881 | ················this.txtSchemaVersion.Text = "1.0"; |
| 882 | ················if (this.txtConnectionString.Text == string.Empty) |
| 883 | ····················this.btnConnString_Click(null, null); |
| 884 | ············} |
| 885 | ············catch (Exception ex) |
| 886 | ············{ |
| 887 | ················ShowError(ex); |
| 888 | ············} |
| 889 | ········} |
| 890 | |
| 891 | //········private void MakeNode(string name, object value, XmlNode parentNode, XmlDocument doc) |
| 892 | //········{ |
| 893 | //············XmlElement el = doc.CreateElement(name); |
| 894 | //············parentNode.AppendChild(el); |
| 895 | //············if (value != null) |
| 896 | //················el.InnerText = value.ToString(); |
| 897 | //········} |
| 898 | |
| 899 | ········void WriteBack(ConfigurationOptions options) |
| 900 | ········{ |
| 901 | ············options.EnableAddIn = chkActivateAddIn.Checked; |
| 902 | ············options.EnableEnhancer = chkActivateEnhancer.Checked; |
| 903 | ············options.IncludeTypecodes = chkIncludeTypecodes.Checked; |
| 904 | ············options.GenerateConstraints = chkGenerateFkConstraints.Checked; |
| 905 | ············options.DropExistingElements = chkDropExistingElements.Checked; |
| 906 | ············options.VerboseMode = chkVerboseMode.Checked; |
| 907 | ············options.NewMapping = chkMappingNew.Checked; |
| 908 | ············options.GenerateSQL = chkGenerateSQLScript.Checked; |
| 909 | ············options.DefaultConnection = txtConnectionString.Text; |
| 910 | ············options.TargetMappingFileName = txtTargetMappingFileName.Text; |
| 911 | ············options.GenerateChangeEvents = chkChangeEvents.Checked; |
| 912 | ············options.UseTimeStamps = chkUseTimeStamps.Checked; |
| 913 | ············options.SQLScriptLanguage = this.cbSqlDialect.Text; |
| 914 | ············options.DatabaseOwner = this.txtDbOwner.Text; |
| 915 | ············options.Utf8Encoding = this.radioUtf8Encoding.Checked; |
| 916 | ············options.SchemaVersion = this.txtSchemaVersion.Text; |
| 917 | ········} |
| 918 | |
| 919 | ········private void btnSaveAs_Click(object sender, System.EventArgs e) |
| 920 | ········{ |
| 921 | ············try |
| 922 | ············{ |
| 923 | ················string projDir = Path.GetDirectoryName(project.FullName); |
| 924 | ················SaveFileDialog sfd = new SaveFileDialog(); |
| 925 | ················sfd.CheckFileExists = false; |
| 926 | ················sfd.DefaultExt = "xml"; |
| 927 | ················sfd.Filter = "NDO Configuration Files (*.ndoproj)|*.ndoproj"; |
| 928 | ················sfd.FileName = "EnhancerParameters.ndoproj"; |
| 929 | ················sfd.InitialDirectory = projDir; |
| 930 | ················if (sfd.ShowDialog(this) != DialogResult.OK) |
| 931 | ····················return; |
| 932 | |
| 933 | ················ConfigurationOptions options = new ConfigurationOptions(project);················ |
| 934 | ················WriteBack(options); |
| 935 | ················options.SaveAs(sfd.FileName, this.projectDescription); |
| 936 | ············} |
| 937 | ············catch (Exception ex) |
| 938 | ············{ |
| 939 | ················ShowError(ex); |
| 940 | ············}········ |
| 941 | ········} |
| 942 | |
| 943 | ········private void cbSqlDialect_SelectedIndexChanged(object sender, System.EventArgs e) |
| 944 | ········{ |
| 945 | ············this.txtConnectionString.Text = string.Empty; |
| 946 | ············CheckEnabledStateForLoadProviderButton(); |
| 947 | ········} |
| 948 | |
| 949 | ········private void btnNewDatabase_Click(object sender, System.EventArgs e) |
| 950 | ········{ |
| 951 | ············string connType = cbSqlDialect.Text; |
| 952 | ············if (connType == string.Empty) |
| 953 | ················connType = "SqlServer"; |
| 954 | ············IDbUISupport provider = NdoUIProviderFactory.Instance[connType]; |
| 955 | ············if (provider == null) |
| 956 | ············{ |
| 957 | ················MessageBox.Show("Can't find a NDO UI provider for the sql dialect " + connType); |
| 958 | ················return; |
| 959 | ············} |
| 960 | ············object necessaryData = null; |
| 961 | ············try |
| 962 | ············{ |
| 963 | ················if (provider.ShowCreateDbDialog(ref necessaryData) == NdoDialogResult.Cancel) |
| 964 | ····················return; |
| 965 | ················this.txtConnectionString.Text = provider.CreateDatabase(necessaryData); |
| 966 | ············} |
| 967 | ············catch (Exception ex) |
| 968 | ············{ |
| 969 | #if !DEBUG |
| 970 | ················MessageBox.Show("Can't construct the database: " + ex.Message); |
| 971 | #else |
| 972 | ················MessageBox.Show("Can't construct the database: " + ex.ToString()); |
| 973 | #endif |
| 974 | ············} |
| 975 | ········} |
| 976 | |
| 977 | ········private void chlbAssemblies_ItemCheck( object sender, ItemCheckEventArgs e ) |
| 978 | ········{ |
| 979 | ············this.references[e.Index].CheckState = e.NewValue; |
| 980 | ········} |
| 981 | |
| 982 | ········private void btnInstallProvider_Click( object sender, EventArgs e ) |
| 983 | ········{ |
| 984 | ············try |
| 985 | ············{ |
| 986 | ················string providerName = this.cbSqlDialect.Text; |
| 987 | |
| 988 | ················if (string.IsNullOrEmpty( providerName )) |
| 989 | ················{ |
| 990 | ····················MessageBox.Show( "Please choose a provider" ); |
| 991 | ····················return; |
| 992 | ················} |
| 993 | |
| 994 | ················IComponentModel componentModel; |
| 995 | ················var installerService = GetInstallerService( out componentModel ); |
| 996 | |
| 997 | ················string packageName = $"ndo.{providerName.ToLower()}"; |
| 998 | ················if (!installerService.IsPackageInstalled( this.project, packageName )) |
| 999 | ················{ |
| 1000 | ····················var installer = componentModel.GetService<IVsPackageInstaller>(); |
| 1001 | ····················installer.InstallPackage( null, this.project, packageName, (string)null, false ); |
| 1002 | ················} |
| 1003 | |
| 1004 | ················this.btnInstallProvider.Enabled = false; |
| 1005 | ············} |
| 1006 | ············catch (Exception ex) |
| 1007 | ············{ |
| 1008 | ················MessageBox.Show( "Error while installing the ndo.dll package: " + ex.ToString() ); |
| 1009 | ············} |
| 1010 | ········} |
| 1011 | ····} |
| 1012 | } |
| 1013 | |
| 1014 | #pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread |
| 1015 |