From 285519d19217e24132bd447477edef970af19631 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 17 Jul 2016 21:32:47 -0400 Subject: [PATCH] Resolves #108 --- MsgBoxYesNoIgnore.Designer.cs | 110 +++++++++++++++++++++++++++++ MsgBoxYesNoIgnore.cs | 33 +++++++++ MsgBoxYesNoIgnore.resx | 120 ++++++++++++++++++++++++++++++++ Properties/Settings.Designer.cs | 12 ++++ Properties/Settings.settings | 3 + Start.Designer.cs | 4 +- Start.cs | 66 ++++++++++++++---- app.config | 3 + nvQuickSite.csproj | 9 +++ 9 files changed, 345 insertions(+), 15 deletions(-) create mode 100644 MsgBoxYesNoIgnore.Designer.cs create mode 100644 MsgBoxYesNoIgnore.cs create mode 100644 MsgBoxYesNoIgnore.resx diff --git a/MsgBoxYesNoIgnore.Designer.cs b/MsgBoxYesNoIgnore.Designer.cs new file mode 100644 index 00000000..538bf8e6 --- /dev/null +++ b/MsgBoxYesNoIgnore.Designer.cs @@ -0,0 +1,110 @@ +namespace nvQuickSite +{ + partial class MsgBoxYesNoIgnore + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lblMessage = new MetroFramework.Controls.MetroLabel(); + this.btnYes = new MetroFramework.Controls.MetroButton(); + this.metroButton2 = new MetroFramework.Controls.MetroButton(); + this.chkDoNotWarnAgain = new MetroFramework.Controls.MetroCheckBox(); + this.dialogIcon = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.dialogIcon)).BeginInit(); + this.SuspendLayout(); + // + // lblMessage + // + this.lblMessage.AutoSize = true; + this.lblMessage.Location = new System.Drawing.Point(97, 23); + this.lblMessage.Name = "lblMessage"; + this.lblMessage.Size = new System.Drawing.Size(60, 19); + this.lblMessage.TabIndex = 0; + this.lblMessage.Text = "Message"; + // + // btnYes + // + this.btnYes.DialogResult = System.Windows.Forms.DialogResult.Yes; + this.btnYes.Location = new System.Drawing.Point(330, 129); + this.btnYes.Name = "btnYes"; + this.btnYes.Size = new System.Drawing.Size(75, 23); + this.btnYes.TabIndex = 1; + this.btnYes.Text = "Yes"; + // + // metroButton2 + // + this.metroButton2.DialogResult = System.Windows.Forms.DialogResult.No; + this.metroButton2.Location = new System.Drawing.Point(429, 129); + this.metroButton2.Name = "metroButton2"; + this.metroButton2.Size = new System.Drawing.Size(75, 23); + this.metroButton2.TabIndex = 2; + this.metroButton2.Text = "No"; + // + // chkDoNotWarnAgain + // + this.chkDoNotWarnAgain.AutoSize = true; + this.chkDoNotWarnAgain.Location = new System.Drawing.Point(17, 129); + this.chkDoNotWarnAgain.Name = "chkDoNotWarnAgain"; + this.chkDoNotWarnAgain.Size = new System.Drawing.Size(140, 15); + this.chkDoNotWarnAgain.TabIndex = 3; + this.chkDoNotWarnAgain.Text = "Do not warn me again"; + this.chkDoNotWarnAgain.UseVisualStyleBackColor = true; + // + // dialogIcon + // + this.dialogIcon.Location = new System.Drawing.Point(17, 35); + this.dialogIcon.Name = "dialogIcon"; + this.dialogIcon.Size = new System.Drawing.Size(67, 67); + this.dialogIcon.TabIndex = 4; + this.dialogIcon.TabStop = false; + // + // MsgBoxYesNoIgnore + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BorderStyle = MetroFramework.Drawing.MetroBorderStyle.FixedSingle; + this.ClientSize = new System.Drawing.Size(527, 170); + this.Controls.Add(this.dialogIcon); + this.Controls.Add(this.chkDoNotWarnAgain); + this.Controls.Add(this.metroButton2); + this.Controls.Add(this.btnYes); + this.Controls.Add(this.lblMessage); + this.Name = "MsgBoxYesNoIgnore"; + ((System.ComponentModel.ISupportInitialize)(this.dialogIcon)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroLabel lblMessage; + private MetroFramework.Controls.MetroButton btnYes; + private MetroFramework.Controls.MetroButton metroButton2; + private MetroFramework.Controls.MetroCheckBox chkDoNotWarnAgain; + private System.Windows.Forms.PictureBox dialogIcon; + } +} \ No newline at end of file diff --git a/MsgBoxYesNoIgnore.cs b/MsgBoxYesNoIgnore.cs new file mode 100644 index 00000000..f9511f4e --- /dev/null +++ b/MsgBoxYesNoIgnore.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; + +namespace nvQuickSite +{ + public partial class MsgBoxYesNoIgnore : MetroForm + { + public MsgBoxYesNoIgnore(bool doNotWarnAgain, string dialogMessage, Image dialogIconImage) + { + InitializeComponent(); + chkDoNotWarnAgain.Checked = doNotWarnAgain; + lblMessage.Text = dialogMessage; + dialogIcon.Image = dialogIconImage; + } + + public bool DoNotWarnAgain + { + get { return chkDoNotWarnAgain.Checked; } + } + + //public string DialogMessage { get; set; } + + //public Image DialogIcon { get; set; } + } +} diff --git a/MsgBoxYesNoIgnore.resx b/MsgBoxYesNoIgnore.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/MsgBoxYesNoIgnore.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 6b381b52..f5d8981e 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -118,5 +118,17 @@ public bool RememberFieldValues { this["RememberFieldValues"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool LocationDoNotWarnAgain { + get { + return ((bool)(this["LocationDoNotWarnAgain"])); + } + set { + this["LocationDoNotWarnAgain"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index e28d5f58..90b3b268 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -26,5 +26,8 @@ True + + False + \ No newline at end of file diff --git a/Start.Designer.cs b/Start.Designer.cs index 491ddc5b..ab13f8da 100644 --- a/Start.Designer.cs +++ b/Start.Designer.cs @@ -143,10 +143,8 @@ private void InitializeComponent() this.txtLocation.FontWeight = MetroFramework.MetroTextBoxWeight.Light; this.txtLocation.Location = new System.Drawing.Point(0, 169); this.txtLocation.Name = "txtLocation"; - this.txtLocation.ReadOnly = true; this.txtLocation.Size = new System.Drawing.Size(540, 23); this.txtLocation.TabIndex = 6; - this.txtLocation.Click += new System.EventHandler(this.txtLocation_Click); // // chkDeleteSiteIfExists // @@ -322,7 +320,7 @@ private void InitializeComponent() this.tabControl.Location = new System.Drawing.Point(3, 14); this.tabControl.Multiline = true; this.tabControl.Name = "tabControl"; - this.tabControl.SelectedIndex = 0; + this.tabControl.SelectedIndex = 1; this.tabControl.Size = new System.Drawing.Size(607, 294); this.tabControl.TabIndex = 26; // diff --git a/Start.cs b/Start.cs index 797b0b67..9ef97a19 100644 --- a/Start.cs +++ b/Start.cs @@ -213,10 +213,10 @@ private void btnInstallPackageNext_Click(object sender, EventArgs e) #endregion #region "Site Info" - private void txtLocation_Click(object sender, EventArgs e) - { - openFolderDiag(); - } + //private void txtLocation_Click(object sender, EventArgs e) + //{ + // openFolderDiag(); + //} private void btnLocation_Click(object sender, EventArgs e) { @@ -252,21 +252,61 @@ private void btnSiteInfoNext_Click(object sender, EventArgs e) if (txtLocation.Text != "" && txtSiteName.Text != "") { - if (!DirectoryEmpty(txtLocation.Text)) + if (!Directory.Exists(txtLocation.Text)) { - var confirmResult = MessageBox.Show("All files and folders at this location will be deleted prior to installation of the new DNN instance. Do you wish to proceed?", - "Confirm Installation", - MessageBoxButtons.YesNo, MessageBoxIcon.Information); - if (confirmResult == DialogResult.Yes) + var dialogMessage = "The entered location does not exist. Do you wish to create it?"; + var dialogIcon = SystemIcons.Warning.ToBitmap(); + var doNotWarnAgain = Properties.Settings.Default.LocationDoNotWarnAgain; + var msgBoxYesNoIgnore = new MsgBoxYesNoIgnore(doNotWarnAgain, dialogMessage, dialogIcon); + var result = msgBoxYesNoIgnore.ShowDialog(); + if (!msgBoxYesNoIgnore.DoNotWarnAgain) + { + if (result == DialogResult.Yes) + { + Directory.CreateDirectory(txtLocation.Text); + proceed = true; + } + else + { + proceed = false; + } + } + else { + Directory.CreateDirectory(txtLocation.Text); proceed = true; + } + Properties.Settings.Default.LocationDoNotWarnAgain = msgBoxYesNoIgnore.DoNotWarnAgain; + Properties.Settings.Default.Save(); } else { proceed = true; } + if (proceed) + { + if (!DirectoryEmpty(txtLocation.Text)) + { + var confirmResult = MessageBox.Show("All files and folders at this location will be deleted prior to installation of the new DNN instance. Do you wish to proceed?", + "Confirm Installation", + MessageBoxButtons.YesNo, MessageBoxIcon.Information); + if (confirmResult == DialogResult.No) + { + proceed = false; + } + else + { + proceed = true; + } + } + else + { + proceed = true; + } + } + if (proceed) { tabInstallPackage.Enabled = false; @@ -546,9 +586,11 @@ private bool CreateDirectories() } else { - var myDBFile = - Directory.EnumerateFiles(databaseDir, "*.mdf").First().Split('_').First().Split('\\').Last(); - DropDatabase(myDBFile); + if (!DirectoryEmpty(databaseDir)) + { + var myDBFile = Directory.EnumerateFiles(databaseDir, "*.mdf").First().Split('_').First().Split('\\').Last(); + DropDatabase(myDBFile); + } Directory.Delete(databaseDir); Directory.CreateDirectory(databaseDir); SetFolderPermission(dbServiceAccount, databaseDir); diff --git a/app.config b/app.config index 7c64c738..34e5b908 100644 --- a/app.config +++ b/app.config @@ -31,6 +31,9 @@ True + + False + diff --git a/nvQuickSite.csproj b/nvQuickSite.csproj index 9e5ea351..7f951fb8 100644 --- a/nvQuickSite.csproj +++ b/nvQuickSite.csproj @@ -134,6 +134,12 @@ + + Form + + + MsgBoxYesNoIgnore.cs + UserControl @@ -149,6 +155,9 @@ + + MsgBoxYesNoIgnore.cs + Start.cs Designer