1
Fork 0

So many god damn comments!! Summaries for all functions in files done!

This commit is contained in:
Jake Howard 2015-02-02 00:40:30 +00:00
parent af2f75e1cd
commit fd5af99db6
5 changed files with 195 additions and 12 deletions

View file

@ -22,6 +22,9 @@ namespace Saviour_Backup_System
this.Size = new Size(583, 269);
}
/// <summary>
/// Add the tooltips to controls
/// </summary>
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.");
}
/// <summary>
/// Browse through window directory to select backup directory
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void directoryBrowseButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
@ -50,6 +58,9 @@ namespace Saviour_Backup_System
folderBrowserDialog.Dispose(); //memory management
}
/// <summary>
/// Fill dropdown with available drives
/// </summary>
private void populateDropdown()
{
DriveInfo[] drives = USBTools.getConnectedDrives();
@ -58,6 +69,10 @@ namespace Saviour_Backup_System
drivesDropdown.Items.Add(drive.Name + " " + drive.VolumeLabel);
}
}
/// <summary>
/// Remove all content from inputs
/// </summary>
private void clearControls()
{
backupNameInput.Text = "";
@ -67,6 +82,11 @@ namespace Saviour_Backup_System
previousBackupInput.Value = 0;
folderPath.Text = "";
}
/// <summary>
/// Mark all controls as read only, or unmark
/// </summary>
/// <param name="state"></param>
private void lockControls(bool state)
{
backupNameInput.ReadOnly = state;
@ -76,6 +96,12 @@ namespace Saviour_Backup_System
previousBackupInput.Enabled = !state;
folderPath.ReadOnly = state;
}
/// <summary>
/// Create the backup record from given information
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
}
}
/// <summary>
/// Create record for drive
/// </summary>
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; }
/// <summary>
/// Display warning for compression time
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void unifiedFileSwitch_Click(object sender, EventArgs e) {
compressionSwitch.Value = !compressionSwitch.Value;
if(compressionSwitch.Value) {

View file

@ -21,7 +21,12 @@ namespace Saviour_Backup_System
InitializeComponent();
}
/// <summary>
/// Starts a backup for a drive
/// </summary>
/// <param name="drive">Drive object of backup drive</param>
/// <param name="endDirectory">Directory to store files</param>
/// <param name="visible">Will the progress window be displayed?</param>
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)
/// <summary>
/// Run a backup of a drive
/// </summary>
/// <param name="driveLetter">Windows drive letter for drive</param>
/// <param name="endDirectory">Directory to store backed up files</param>
/// <param name="display">Will the progress window be displayed</param>
/// <param name="drive">Drive object for backup drive</param>
/// <param name="hash">Current hash of drive</param>
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.
}
/// <summary>
/// Label for displaying backup information
/// </summary>
private class copyProgressLabel : Label {
public copyProgressLabel()
{
@ -78,6 +94,9 @@ namespace Saviour_Backup_System
}
}
/// <summary>
/// Progressbar for displaying backup progress
/// </summary>
private class copyProgressBar : DevComponents.DotNetBar.Controls.ProgressBarX
{
public copyProgressBar()
@ -101,6 +120,11 @@ namespace Saviour_Backup_System
this.Hide();
}
/// <summary>
/// Clears the window of all controls
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);

View file

@ -18,7 +18,9 @@ namespace Saviour_Backup_System
private static void copyDatabase() { File.WriteAllBytes(@"" + databaseName, Resources.saviour); } //copy the file from resources
/// <summary>
/// Checks if the database exists, and then pings the connection
/// </summary>
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();
}
/// <summary>
/// Returns the drive name from an ID
/// </summary>
/// <param name="id">ID of the drive to search for</param>
/// <returns></returns>
public static string getDriveName(string id) {
string name = "NONE";
conn.Open();
@ -41,6 +48,11 @@ namespace Saviour_Backup_System
return name;
}
/// <summary>
/// Returns the backup directory for a drive
/// </summary>
/// <param name="id">ID of the drive to search for</param>
/// <returns></returns>
public static string getBackupDirectory(string id) {
string directory = "NONE";
conn.Open();
@ -57,6 +69,11 @@ namespace Saviour_Backup_System
return directory;
}
/// <summary>
/// Returns the creation date for a backup directory
/// </summary>
/// <param name="id">ID of the drive to search for</param>
/// <returns></returns>
public static Int64 getBackupCreationDate(string id)
{
Int64 date = 0;
@ -76,7 +93,10 @@ namespace Saviour_Backup_System
return date;
}
/// <summary>
/// Returns what drives are set to back up automatically
/// </summary>
/// <returns></returns>
public static string[] getAutomaticBackups()
{
conn.Open();
@ -93,6 +113,11 @@ namespace Saviour_Backup_System
return IDs.ToArray();
}
/// <summary>
/// Returns the name of the backup
/// </summary>
/// <param name="drive">Drive object to search for</param>
/// <returns></returns>
public static string getBackupName(DriveInfo drive)
{
string name = "";
@ -111,6 +136,13 @@ namespace Saviour_Backup_System
return name;
}
/// <summary>
/// Create a backup record in the database
/// </summary>
/// <param name="drive">Drive info object for backup drive</param>
/// <param name="startDate">Date the backup started (as UNIX timestamp)</param>
/// <param name="duration">How long the backup took to run (in seconds)</param>
/// <param name="hash">New hash of the drive</param>
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();
}
/// <summary>
/// Returns the most recent hash of a drive
/// </summary>
/// <param name="id">ID of drive to search for</param>
/// <returns></returns>
public static string getHashofRecentBackup(string id)
{
conn.Open();
@ -151,6 +187,12 @@ namespace Saviour_Backup_System
return hash;
}
/// <summary>
/// Returns if the drive is compressed
/// </summary>
/// <param name="id">ID of the drive to search for</param>
/// <returns></returns>
public static bool isCompression(string id)
{
conn.Open();
@ -168,6 +210,10 @@ namespace Saviour_Backup_System
return compression;
}
/// <summary>
/// Returns all the drives that have backup records
/// </summary>
/// <returns></returns>
public static DataTable getAllDriveBackups()
{
DataTable table = new DataTable();
@ -181,6 +227,10 @@ namespace Saviour_Backup_System
}
}
/// <summary>
/// Deletes a drive record from the database
/// </summary>
/// <param name="creationDate">Date of drive creation as UNIX timestamp</param>
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();
}
/// <summary>
/// Update a drive record in the database
/// </summary>
/// <param name="backupName">Name of the backup record</param>
/// <param name="backupLocation">Location to store backup</param>
/// <param name="automatic">is the backup automatic on insert?</param>
/// <param name="compression">Will the backup be compressed</param>
/// <param name="previousBackups">How many previous backups will be stored</param>
/// <param name="creationDate">Creation date of record</param>
public static void updateDriveRecord(string backupName, string backupLocation, bool automatic, bool compression, int previousBackups, Int64 creationDate)
{
conn.Open();

View file

@ -24,6 +24,9 @@ namespace Saviour_Backup_System
catch { this.showDisplay(); }
}
/// <summary>
/// Stop displaying the window
/// </summary>
public void removeDisplay() {
formatDriveCapacityTimer.Stop();
driveRefreshTimer.Stop();
@ -33,6 +36,9 @@ namespace Saviour_Backup_System
setup.icon.notifyIcon.Visible = true;
}
/// <summary>
/// Display the window
/// </summary>
public void showDisplay() {
refreshDriveList();
connectedDrivesList.Update();
@ -44,6 +50,9 @@ namespace Saviour_Backup_System
this.Show();
}
/// <summary>
/// Refresh the list of drives in window
/// </summary>
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();
}
/// <summary>
/// Refresh drive button
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void connectedDrivesListRefresh_Click(object sender, EventArgs e)
{
toolStripProgress.Visible = true;
@ -76,7 +89,11 @@ namespace Saviour_Backup_System
toolStripProgress.Visible = false;
}
/// <summary>
/// When an item in the connected drives list is selected
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
/// <summary>
/// Show the details of of the selected drive
/// </summary>
/// <param name="drive"></param>
private void displayDriveDetails(DriveInfo drive) {
toolStripProgress.Visible = true;
selectedDrive = drive;
@ -118,6 +139,9 @@ namespace Saviour_Backup_System
toolStripProgress.Visible = false;
}
/// <summary>
/// Change value of drive capacity bar, and change format of value
/// </summary>
private void formatDriveCapacity()
{
DriveInfo drive = selectedDrive;
@ -137,7 +161,9 @@ namespace Saviour_Backup_System
}
/// <summary>
/// Remove the details of onscreen details panel
/// </summary>
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
/// <summary>
/// Display elements on device tab
/// </summary>
private void populateDeviceTab() {
// put stuff in here for changing labels of buttons etc.
deviceTab.Visible = true;
deviceTab.Select();
}
/// <summary>
/// Catch event for form closing
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mainWindow_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true;
switch (e.CloseReason) {
@ -179,6 +213,11 @@ namespace Saviour_Backup_System
}
}
/// <summary>
/// Display the add backup rules window
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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(); }
/// <summary>
/// Display current transfer window
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void currentTransfersButton_Click(object sender, EventArgs e)
{
setup.CT.Show();
}
/// <summary>
/// Show all backup drives
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void viewAllRulesButton_Click(object sender, EventArgs e)
{
setup.BV = new backupViewer();
setup.BV.Show();
}
/// <summary>
/// Run a backup of selected divce
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void backupDeviceButton_Click(object sender, EventArgs e)
{
if (backupDirectoryDisplay.Text != "NONE") {

View file

@ -11,7 +11,9 @@ namespace Saviour_Backup_System
{
public NotifyIcon notifyIcon = new NotifyIcon() ;
public ContextMenu contextMenu = new ContextMenu();
/// <summary>
/// Constructor for notification icon
/// </summary>
public notificationIcon()
{
notifyIcon.Text = "Saviour Backup System";
@ -20,17 +22,26 @@ namespace Saviour_Backup_System
notifyIcon.ContextMenu = contextMenu;
notifyIcon.Visible = true; //finally displays the tray icon
}
/// <summary>
/// Creates the menu entries for notification icon
/// </summary>
private void populateList() {
contextMenu.MenuItems.Add("Show Interface", displayWindow);
contextMenu.MenuItems.Add("Copy Progress", showProgress);
contextMenu.MenuItems.Add("Exit", closeProgram);
}
/// <summary>
/// Set right click menu events for notification icon
/// </summary>
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(); }
/// <summary>
/// Set display message when program main window is closed.
/// </summary>
public void displayStillRunning() {
string title = "I'm Still Here!";
string message = "Saviour Backup System is still running in the background";