From 56f39ea5e642e894808a4e4ffd33f4849d533d5c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 24 Nov 2014 17:11:36 +0000 Subject: [PATCH] started validation for input, and dialog enlargement --- Saviour Backup System/addBackupWizard.cs | 44 +++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Saviour Backup System/addBackupWizard.cs b/Saviour Backup System/addBackupWizard.cs index 7989fb6..2dc7e86 100644 --- a/Saviour Backup System/addBackupWizard.cs +++ b/Saviour Backup System/addBackupWizard.cs @@ -5,7 +5,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Threading; using System.Windows.Forms; using System.IO; @@ -19,6 +19,7 @@ namespace Saviour_Backup_System InitializeComponent(); populateDropdown(); defaultText = introTextBox.Text; //stores it so we can append to the end at runtime + this.Size = new Size(583, 299); } private void directoryBrowseButton_Click(object sender, EventArgs e) @@ -39,5 +40,46 @@ namespace Saviour_Backup_System drivesDropdown.Items.Add(drive.Name + " " + drive.VolumeLabel); } } + + private void createButton_Click(object sender, EventArgs e) + { + statusProgress.Text = "Initialising..."; + int initHeight = 299; + while (this.Size.Height != 330) { + initHeight++; + this.Size = new Size(583, initHeight); + Thread.Sleep(10); + } + try { //check validity of input from user + + if ((folderPath.Text == "") || (previousBackupInput.Text == "") || (compressionTypeDropdown.Text == "") || (drivesDropdown.Text == "")){ + MessageBox.Show("You have not filled in every element, Please try again!", "Not everything is complete", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + + if (!Directory.Exists(folderPath.Text) { + DialogResult result = MessageBox.Show("The folder path you have entered doesnt exist, would you like to create it?", "Create Folder", MessageBoxButtons.YesNo); + if (result == DialogResult.Yes){ + try{ + Directory.CreateDirectory(folderPath.Text); + } catch{ + MessageBox.Show("Error Creating Folder!"); + return; + } + } else { + return; + } + } + } finally { + while (this.Size.Height != 299) { + initHeight--; + this.Size = new Size(583, initHeight); + Thread.Sleep(10); + } + statusProgress.ResetText(); + statusProgress.Value = 0; + } + } } }