diff --git a/Saviour Backup System/addBackupWizard.cs b/Saviour Backup System/addBackupWizard.cs
index 949686b..981085a 100644
--- a/Saviour Backup System/addBackupWizard.cs
+++ b/Saviour Backup System/addBackupWizard.cs
@@ -22,6 +22,9 @@ namespace Saviour_Backup_System
this.Size = new Size(583, 269);
}
+ ///
+ /// Add the tooltips to controls
+ ///
private void assignToolTips() {
ToolTip tempTip = new ToolTip();
tempTip.AutoPopDelay = 5000;
@@ -40,6 +43,11 @@ namespace Saviour_Backup_System
tempTip.SetToolTip(this.directoryBrowseButton, "Where?\nClick here to browse your computer to find where to store the backup.");
}
+ ///
+ /// Browse through window directory to select backup directory
+ ///
+ ///
+ ///
private void directoryBrowseButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
@@ -50,6 +58,9 @@ namespace Saviour_Backup_System
folderBrowserDialog.Dispose(); //memory management
}
+ ///
+ /// Fill dropdown with available drives
+ ///
private void populateDropdown()
{
DriveInfo[] drives = USBTools.getConnectedDrives();
@@ -58,6 +69,10 @@ namespace Saviour_Backup_System
drivesDropdown.Items.Add(drive.Name + " " + drive.VolumeLabel);
}
}
+
+ ///
+ /// Remove all content from inputs
+ ///
private void clearControls()
{
backupNameInput.Text = "";
@@ -67,6 +82,11 @@ namespace Saviour_Backup_System
previousBackupInput.Value = 0;
folderPath.Text = "";
}
+
+ ///
+ /// Mark all controls as read only, or unmark
+ ///
+ ///
private void lockControls(bool state)
{
backupNameInput.ReadOnly = state;
@@ -76,6 +96,12 @@ namespace Saviour_Backup_System
previousBackupInput.Enabled = !state;
folderPath.ReadOnly = state;
}
+
+ ///
+ /// Create the backup record from given information
+ ///
+ ///
+ ///
private void createButton_Click(object sender, EventArgs e) {
DriveInfo drive = USBTools.getDriveObject(drivesDropdown.Text.Substring(0, 1));
lockControls(true);
@@ -122,6 +148,10 @@ namespace Saviour_Backup_System
}
}
+
+ ///
+ /// Create record for drive
+ ///
private void createRecord() {
SqlCeConnection conn = databaseTools.conn;
SqlCeCommand cmd = conn.CreateCommand();
@@ -170,6 +200,11 @@ namespace Saviour_Backup_System
private void insertionSwitch_Click(object sender, EventArgs e) { insertionSwitch.Value = !insertionSwitch.Value; }
+ ///
+ /// Display warning for compression time
+ ///
+ ///
+ ///
private void unifiedFileSwitch_Click(object sender, EventArgs e) {
compressionSwitch.Value = !compressionSwitch.Value;
if(compressionSwitch.Value) {
diff --git a/Saviour Backup System/currentTransfers.cs b/Saviour Backup System/currentTransfers.cs
index c56a9db..69eb52e 100644
--- a/Saviour Backup System/currentTransfers.cs
+++ b/Saviour Backup System/currentTransfers.cs
@@ -21,7 +21,12 @@ namespace Saviour_Backup_System
InitializeComponent();
}
-
+ ///
+ /// Starts a backup for a drive
+ ///
+ /// Drive object of backup drive
+ /// Directory to store files
+ /// Will the progress window be displayed?
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."); }
@@ -51,7 +56,15 @@ namespace Saviour_Backup_System
}
}
- private void copyFiles(string driveLetter, string endDirectory, bool display, DriveInfo drive, string hash) //actually starts the backups (and loads the dialogs)
+ ///
+ /// Run a backup of a drive
+ ///
+ /// Windows drive letter for drive
+ /// Directory to store backed up files
+ /// Will the progress window be displayed
+ /// Drive object for backup drive
+ /// Current hash of drive
+ private void copyFiles(string driveLetter, string endDirectory, bool display, DriveInfo drive, string hash)
{
backups++; //appends to the number of backups running
progressBars.Add(new copyProgressBar());
@@ -68,6 +81,9 @@ namespace Saviour_Backup_System
if (!display) { transfersList[backups].Hide(); } //if it is a startup backup process, quickly hide the dialog.
}
+ ///
+ /// Label for displaying backup information
+ ///
private class copyProgressLabel : Label {
public copyProgressLabel()
{
@@ -78,6 +94,9 @@ namespace Saviour_Backup_System
}
}
+ ///
+ /// Progressbar for displaying backup progress
+ ///
private class copyProgressBar : DevComponents.DotNetBar.Controls.ProgressBarX
{
public copyProgressBar()
@@ -101,6 +120,11 @@ namespace Saviour_Backup_System
this.Hide();
}
+ ///
+ /// Clears the window of all controls
+ ///
+ ///
+ ///
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);
diff --git a/Saviour Backup System/databaseTools.cs b/Saviour Backup System/databaseTools.cs
index 8947d23..253af83 100644
--- a/Saviour Backup System/databaseTools.cs
+++ b/Saviour Backup System/databaseTools.cs
@@ -18,7 +18,9 @@ namespace Saviour_Backup_System
private static void copyDatabase() { File.WriteAllBytes(@"" + databaseName, Resources.saviour); } //copy the file from resources
-
+ ///
+ /// Checks if the database exists, and then pings the connection
+ ///
public static void init() {
if (!File.Exists(databaseName)) { //if the database doesnt exists (program hasnt been run before)
copyDatabase();
@@ -27,6 +29,11 @@ namespace Saviour_Backup_System
conn.Close();
}
+ ///
+ /// Returns the drive name from an ID
+ ///
+ /// ID of the drive to search for
+ ///
public static string getDriveName(string id) {
string name = "NONE";
conn.Open();
@@ -41,6 +48,11 @@ namespace Saviour_Backup_System
return name;
}
+ ///
+ /// Returns the backup directory for a drive
+ ///
+ /// ID of the drive to search for
+ ///
public static string getBackupDirectory(string id) {
string directory = "NONE";
conn.Open();
@@ -57,6 +69,11 @@ namespace Saviour_Backup_System
return directory;
}
+ ///
+ /// Returns the creation date for a backup directory
+ ///
+ /// ID of the drive to search for
+ ///
public static Int64 getBackupCreationDate(string id)
{
Int64 date = 0;
@@ -76,7 +93,10 @@ namespace Saviour_Backup_System
return date;
}
-
+ ///
+ /// Returns what drives are set to back up automatically
+ ///
+ ///
public static string[] getAutomaticBackups()
{
conn.Open();
@@ -93,6 +113,11 @@ namespace Saviour_Backup_System
return IDs.ToArray();
}
+ ///
+ /// Returns the name of the backup
+ ///
+ /// Drive object to search for
+ ///
public static string getBackupName(DriveInfo drive)
{
string name = "";
@@ -111,6 +136,13 @@ namespace Saviour_Backup_System
return name;
}
+ ///
+ /// Create a backup record in the database
+ ///
+ /// Drive info object for backup drive
+ /// Date the backup started (as UNIX timestamp)
+ /// How long the backup took to run (in seconds)
+ /// New hash of the drive
public static void createBackupRecord(DriveInfo drive, Int64 startDate, Int64 duration, string hash)
{
string id = USBTools.calculateDriveID(drive);
@@ -133,7 +165,11 @@ namespace Saviour_Backup_System
conn.Close();
}
-
+ ///
+ /// Returns the most recent hash of a drive
+ ///
+ /// ID of drive to search for
+ ///
public static string getHashofRecentBackup(string id)
{
conn.Open();
@@ -151,6 +187,12 @@ namespace Saviour_Backup_System
return hash;
}
+
+ ///
+ /// Returns if the drive is compressed
+ ///
+ /// ID of the drive to search for
+ ///
public static bool isCompression(string id)
{
conn.Open();
@@ -168,6 +210,10 @@ namespace Saviour_Backup_System
return compression;
}
+ ///
+ /// Returns all the drives that have backup records
+ ///
+ ///
public static DataTable getAllDriveBackups()
{
DataTable table = new DataTable();
@@ -181,6 +227,10 @@ namespace Saviour_Backup_System
}
}
+ ///
+ /// Deletes a drive record from the database
+ ///
+ /// Date of drive creation as UNIX timestamp
public static void deleteDriveRecord(Int64 creationDate) {
conn.Open();
cmd.CommandText = "DELETE FROM RecordSet, Drive WHERE Creation_Date=? AND Recordset.Drive_ID = Drive.ID;";
@@ -191,6 +241,15 @@ namespace Saviour_Backup_System
conn.Close();
}
+ ///
+ /// Update a drive record in the database
+ ///
+ /// Name of the backup record
+ /// Location to store backup
+ /// is the backup automatic on insert?
+ /// Will the backup be compressed
+ /// How many previous backups will be stored
+ /// Creation date of record
public static void updateDriveRecord(string backupName, string backupLocation, bool automatic, bool compression, int previousBackups, Int64 creationDate)
{
conn.Open();
diff --git a/Saviour Backup System/mainWindow.cs b/Saviour Backup System/mainWindow.cs
index c9e1d9a..f67b0f0 100644
--- a/Saviour Backup System/mainWindow.cs
+++ b/Saviour Backup System/mainWindow.cs
@@ -24,6 +24,9 @@ namespace Saviour_Backup_System
catch { this.showDisplay(); }
}
+ ///
+ /// Stop displaying the window
+ ///
public void removeDisplay() {
formatDriveCapacityTimer.Stop();
driveRefreshTimer.Stop();
@@ -33,6 +36,9 @@ namespace Saviour_Backup_System
setup.icon.notifyIcon.Visible = true;
}
+ ///
+ /// Display the window
+ ///
public void showDisplay() {
refreshDriveList();
connectedDrivesList.Update();
@@ -44,6 +50,9 @@ namespace Saviour_Backup_System
this.Show();
}
+ ///
+ /// Refresh the list of drives in window
+ ///
public void refreshDriveList() {
DriveInfo[] drives = USBTools.getConnectedDrives();
if (connectedDrivesList.Items.Count == USBTools.countDrives()) { return; } //if there is no change in the numer
@@ -66,7 +75,11 @@ namespace Saviour_Backup_System
connectedDrivesList.Sort();
}
-
+ ///
+ /// Refresh drive button
+ ///
+ ///
+ ///
private void connectedDrivesListRefresh_Click(object sender, EventArgs e)
{
toolStripProgress.Visible = true;
@@ -76,7 +89,11 @@ namespace Saviour_Backup_System
toolStripProgress.Visible = false;
}
-
+ ///
+ /// When an item in the connected drives list is selected
+ ///
+ ///
+ ///
private void connectedDrivesList_Selection(object sender, ListViewItemSelectionChangedEventArgs e) {
toolStripProgress.Visible = true;
if (!e.IsSelected) {
@@ -92,6 +109,10 @@ namespace Saviour_Backup_System
toolStripProgress.Visible = false;
}
+ ///
+ /// Show the details of of the selected drive
+ ///
+ ///
private void displayDriveDetails(DriveInfo drive) {
toolStripProgress.Visible = true;
selectedDrive = drive;
@@ -118,6 +139,9 @@ namespace Saviour_Backup_System
toolStripProgress.Visible = false;
}
+ ///
+ /// Change value of drive capacity bar, and change format of value
+ ///
private void formatDriveCapacity()
{
DriveInfo drive = selectedDrive;
@@ -137,7 +161,9 @@ namespace Saviour_Backup_System
}
-
+ ///
+ /// Remove the details of onscreen details panel
+ ///
private void clearDriveDetails() {
string blankText = "";
selectedDrive = null;
@@ -154,11 +180,19 @@ namespace Saviour_Backup_System
private void formatDriveCapacityTimer_Tick(object sender, EventArgs e) { try { formatDriveCapacity(); } catch { } } //Because background workers cant interact with the GUI (very quickly), so a timer has to
+ ///
+ /// Display elements on device tab
+ ///
private void populateDeviceTab() {
- // put stuff in here for changing labels of buttons etc.
deviceTab.Visible = true;
deviceTab.Select();
}
+
+ ///
+ /// Catch event for form closing
+ ///
+ ///
+ ///
private void mainWindow_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true;
switch (e.CloseReason) {
@@ -179,6 +213,11 @@ namespace Saviour_Backup_System
}
}
+ ///
+ /// Display the add backup rules window
+ ///
+ ///
+ ///
private void addBackupRuleButton_Click(object sender, EventArgs e)
{
setup.ABW = new addBackupWizard();
@@ -187,17 +226,32 @@ namespace Saviour_Backup_System
private void exitButton_Click(object sender, EventArgs e) { setup.closeProgram(); }
+ ///
+ /// Display current transfer window
+ ///
+ ///
+ ///
private void currentTransfersButton_Click(object sender, EventArgs e)
{
setup.CT.Show();
}
+ ///
+ /// Show all backup drives
+ ///
+ ///
+ ///
private void viewAllRulesButton_Click(object sender, EventArgs e)
{
setup.BV = new backupViewer();
setup.BV.Show();
}
+ ///
+ /// Run a backup of selected divce
+ ///
+ ///
+ ///
private void backupDeviceButton_Click(object sender, EventArgs e)
{
if (backupDirectoryDisplay.Text != "NONE") {
diff --git a/Saviour Backup System/notificationIcon.cs b/Saviour Backup System/notificationIcon.cs
index a8e6653..4537f43 100644
--- a/Saviour Backup System/notificationIcon.cs
+++ b/Saviour Backup System/notificationIcon.cs
@@ -11,7 +11,9 @@ namespace Saviour_Backup_System
{
public NotifyIcon notifyIcon = new NotifyIcon() ;
public ContextMenu contextMenu = new ContextMenu();
-
+ ///
+ /// Constructor for notification icon
+ ///
public notificationIcon()
{
notifyIcon.Text = "Saviour Backup System";
@@ -20,18 +22,27 @@ namespace Saviour_Backup_System
notifyIcon.ContextMenu = contextMenu;
notifyIcon.Visible = true; //finally displays the tray icon
}
-
+ ///
+ /// Creates the menu entries for notification icon
+ ///
private void populateList() {
contextMenu.MenuItems.Add("Show Interface", displayWindow);
contextMenu.MenuItems.Add("Copy Progress", showProgress);
contextMenu.MenuItems.Add("Exit", closeProgram);
}
+
+ ///
+ /// Set right click menu events for notification icon
+ ///
private void displayWindow(object sender, EventArgs e) { setup.MW.showDisplay(); }
private void showProgress(object sender, EventArgs e) { return; } //nothing yet!
private void closeProgram(object sender, EventArgs e) { setup.closeProgram(); }
- public void displayStillRunning() {
+ ///
+ /// Set display message when program main window is closed.
+ ///
+ public void displayStillRunning() {
string title = "I'm Still Here!";
string message = "Saviour Backup System is still running in the background";
notifyIcon.ShowBalloonTip(2000, title, message, ToolTipIcon.Info);