1
Fork 0

edited code to make it more resource friendly

This commit is contained in:
Jake Howard 2014-11-10 14:50:31 +00:00
parent fa06c0ead1
commit efebf64068

View file

@ -26,24 +26,26 @@ namespace Saviour_Backup_System
internal void removeDisplay() { internal void removeDisplay() {
formatDriveCapacityTimer.Stop(); formatDriveCapacityTimer.Stop();
driveRefreshTimer.Stop(); driveRefreshTimer.Stop();
connectedDrivesList.Update();
clearDriveDetails(); clearDriveDetails();
this.Hide(); this.Hide();
setup.icon.notifyIcon.Visible = true; setup.icon.notifyIcon.Visible = true;
} }
internal void showDisplay() { internal void showDisplay() {
this.Show();
refreshDriveList(); refreshDriveList();
connectedDrivesList.Update();
connectedDrivesList.Items[0].Selected = true; connectedDrivesList.Items[0].Selected = true;
displayDriveDetails(connectedDrivesList.SelectedItems[0].Text.Substring(0, 3)); displayDriveDetails(connectedDrivesList.SelectedItems[0].Text.Substring(0, 3));
formatDriveCapacityTimer.Start(); formatDriveCapacityTimer.Start();
driveRefreshTimer.Start(); driveRefreshTimer.Start();
setup.icon.notifyIcon.Visible = false; setup.icon.notifyIcon.Visible = false;
this.Show();
} }
internal void refreshDriveList() { internal void refreshDriveList() {
DriveInfo[] drives = USBTools.getConnectedDrives(); DriveInfo[] drives = USBTools.getConnectedDrives();
if (connectedDrivesList.Items.Count == USBTools.countDrives()) { return; } //f there is no change in the numer if (connectedDrivesList.Items.Count == USBTools.countDrives()) { return; } //if there is no change in the numer
connectedDrivesList.Items.Clear(); connectedDrivesList.Items.Clear();
bool deviceStillConnected = false; bool deviceStillConnected = false;
foreach (DriveInfo drive in drives){ foreach (DriveInfo drive in drives){
@ -78,6 +80,7 @@ namespace Saviour_Backup_System
backupRestoreTab.Select(); backupRestoreTab.Select();
return; return;
} }
formatDriveCapacityTimer.Start();
ribbonControl.RecalcLayout(); ribbonControl.RecalcLayout();
populateDeviceTab(); populateDeviceTab();
string selectedDevice = connectedDrivesList.SelectedItems[0].Text; string selectedDevice = connectedDrivesList.SelectedItems[0].Text;
@ -125,6 +128,7 @@ namespace Saviour_Backup_System
else if (driveCapacityDisplay.Value > 6800 && driveCapacityDisplay.Value < 9000) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Paused; } else if (driveCapacityDisplay.Value > 6800 && driveCapacityDisplay.Value < 9000) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Paused; }
else if (driveCapacityDisplay.Value >= 9000) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Error; } else if (driveCapacityDisplay.Value >= 9000) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Error; }
} }
formatDriveCapacityTimer.Stop();
} }
@ -151,9 +155,10 @@ namespace Saviour_Backup_System
deviceTab.Select(); deviceTab.Select();
} }
private void mainWindow_FormClosing(object sender, FormClosingEventArgs e) { private void mainWindow_FormClosing(object sender, FormClosingEventArgs e) {
switch (e.CloseReason) e.Cancel = true;
{ switch (e.CloseReason) {
case(CloseReason.ApplicationExitCall): case(CloseReason.ApplicationExitCall):
case(CloseReason.WindowsShutDown):
formatDriveCapacityTimer.Stop(); formatDriveCapacityTimer.Stop();
driveRefreshTimer.Stop(); driveRefreshTimer.Stop();
this.Close(); this.Close();