change parameters, and added clear button (and removed code for testing button)
This commit is contained in:
parent
ecc64ca8ac
commit
7c497eb8a2
1 changed files with 17 additions and 10 deletions
|
@ -20,7 +20,6 @@ namespace Saviour_Backup_System
|
||||||
public currentTransfers() {
|
public currentTransfers() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startCopy(DriveInfo drive, string endDirectory, bool visible) { //used for validation to make sure the copy wont fail.
|
public void startCopy(DriveInfo drive, string endDirectory, bool visible) { //used for validation to make sure the copy wont fail.
|
||||||
if (!Directory.Exists(drive.Name)) { MessageBox.Show("The drive directory does not exist."); }
|
if (!Directory.Exists(drive.Name)) { MessageBox.Show("The drive directory does not exist."); }
|
||||||
|
|
||||||
|
@ -34,8 +33,7 @@ namespace Saviour_Backup_System
|
||||||
MessageBox.Show("No changes have been made to files on drive " + drive.VolumeLabel + ", Will not backup.", "No Changes", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("No changes have been made to files on drive " + drive.VolumeLabel + ", Will not backup.", "No Changes", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
return;
|
return;
|
||||||
} else { //The actual backup case
|
} else { //The actual backup case
|
||||||
databaseTools.createBackupRecord(drive, tools.getUnixTimeStamp(), 0L, hash);
|
copyFiles(drive.Name.Substring(0, 1), endDirectory, visible, drive, hash);
|
||||||
copyFiles(drive.Name.Substring(0, 1), endDirectory, visible, drive);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageBox.Show("An error occured when checking the drive. Please try again.", "Hash Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("An error occured when checking the drive. Please try again.", "Hash Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -44,7 +42,7 @@ namespace Saviour_Backup_System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFiles(string driveLetter, string endDirectory, bool display, DriveInfo drive) //actually starts the backups (and loads the dialogs)
|
private void copyFiles(string driveLetter, string endDirectory, bool display, DriveInfo drive, string hash) //actually starts the backups (and loads the dialogs)
|
||||||
{
|
{
|
||||||
backups++; //appends to the number of backups running
|
backups++; //appends to the number of backups running
|
||||||
progressBars.Add(new copyProgressBar());
|
progressBars.Add(new copyProgressBar());
|
||||||
|
@ -54,11 +52,11 @@ namespace Saviour_Backup_System
|
||||||
|
|
||||||
copyFilesList.Add(new CopyFiles.CopyFiles(driveLetter + ":\\", endDirectory));
|
copyFilesList.Add(new CopyFiles.CopyFiles(driveLetter + ":\\", endDirectory));
|
||||||
|
|
||||||
transfersList.Add(new transferWindow(backups, drive));
|
transfersList.Add(new transferWindow(backups, drive, hash));
|
||||||
transfersList[backups].SynchronizationObject = this;
|
transfersList[backups].SynchronizationObject = this;
|
||||||
copyFilesList[backups].CopyAsync(transfersList[backups]);
|
copyFilesList[backups].CopyAsync(transfersList[backups]);
|
||||||
|
|
||||||
if (!display) { transfersList[backups].Hide(); } //if it is a startup backup process, dont display the dialog.
|
if (!display) { transfersList[backups].Hide(); } //if it is a startup backup process, quickly hide the dialog.
|
||||||
}
|
}
|
||||||
|
|
||||||
private class copyProgressLabel : Label {
|
private class copyProgressLabel : Label {
|
||||||
|
@ -84,12 +82,8 @@ namespace Saviour_Backup_System
|
||||||
this.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Paused;
|
this.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Paused;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Starting...");
|
|
||||||
startCopy(USBTools.getDriveObject("F"), "E:\\Temp\\CopyTemp", true);
|
|
||||||
MessageBox.Show("Process Complete!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void currentTransfers_FormClosing(object sender, FormClosingEventArgs e)
|
private void currentTransfers_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
@ -97,5 +91,18 @@ namespace Saviour_Backup_System
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
this.Hide();
|
this.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("Are you sure you want to clear?\nThis will cancel all active transfers!", "Clear Window", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
|
||||||
|
if (result == System.Windows.Forms.DialogResult.Yes) {
|
||||||
|
foreach (transferWindow TW in transfersList) { TW.cancelCopy(); } //cancels all the copies as quickly as possible
|
||||||
|
copyFilesList.Clear();
|
||||||
|
layoutPanel.Controls.Clear();
|
||||||
|
progressBars.Clear();
|
||||||
|
MessageBox.Show("All items have been cleared!");
|
||||||
|
}
|
||||||
|
else { return; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue