1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
saviour-backup-system/Saviour Backup System/setup.cs

73 lines
2.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2014-08-02 10:48:14 +01:00
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
2014-08-02 10:48:14 +01:00
using System.Windows.Forms;
namespace Saviour_Backup_System
{
class setup
{
public static string[] runtimeArguements = null;
public static mainWindow MW;
public static notificationIcon icon;
public static addBackupWizard ABW;
public static splashScreen SS;
public static currentTransfers CT = new currentTransfers();
public static backupViewer BV;
public static string username = Environment.UserName; //snapshots the username
2014-11-07 00:39:59 +00:00
public static void initProgram(string[] args) {
runtimeArguements = args;
SS = new splashScreen(); //displays the splash screen
SS.description.Text = "From Setup...";
2014-12-04 12:47:25 +00:00
databaseTools.init();
2015-03-29 19:07:53 +01:00
//startupBackups();
SS.Close();
icon = new notificationIcon();
MW = new mainWindow();
Application.Run(MW);
2014-08-02 10:48:14 +01:00
}
private static void startupBackups() {
2014-12-04 12:47:25 +00:00
string[] IDs = databaseTools.getAutomaticBackups();
DriveInfo[] drives = USBTools.getConnectedDrives();
List<string> driveIDs = new List<string>();
List<string> drivesToBackup = new List<string>();
foreach (DriveInfo drive in drives) { driveIDs.Add(USBTools.calculateDriveID(drive)); }
foreach (string id in IDs) { if (driveIDs.Contains(id)) { drivesToBackup.Add(id); } }
foreach (string id in drivesToBackup) {
string directory = databaseTools.getBackupDirectory(id);
string name = databaseTools.getDriveName(id);
foreach (DriveInfo drive in USBTools.getConnectedDrives()) {
if (drive.VolumeLabel == name) {
CT.startCopy(drive, directory, false);
break;
} else { continue; }
}
2014-12-04 12:47:25 +00:00
}
}
2014-08-02 10:48:14 +01:00
public static void closeProgram() {
string exitMessage = "Are you sure you want to close Saviour Backup System?\nAll copying backups and backup scanning will cease.";
2014-11-06 10:22:28 +00:00
DialogResult result = MessageBox.Show(exitMessage, "Saviour Backup System Exiting...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
2014-11-10 14:52:04 +00:00
if (result == System.Windows.Forms.DialogResult.Yes) {
icon.notifyIcon.Dispose();
MW.removeDisplay();
Environment.Exit(0);
}
2014-08-02 10:48:14 +01:00
}
}
}