Removed try blocks, added length check to drive label display, added percentage to capacity bar, and changed access modifiers
This commit is contained in:
parent
c726c09d76
commit
281fdd87f0
1 changed files with 13 additions and 14 deletions
|
@ -12,7 +12,7 @@ namespace Saviour_Backup_System
|
||||||
{
|
{
|
||||||
public partial class mainWindow : Form
|
public partial class mainWindow : Form
|
||||||
{
|
{
|
||||||
private DriveInfo selectedDrive = null;
|
private DriveInfo selectedDrive;
|
||||||
|
|
||||||
public mainWindow()
|
public mainWindow()
|
||||||
{
|
{
|
||||||
|
@ -22,27 +22,25 @@ namespace Saviour_Backup_System
|
||||||
clearDriveDetails();
|
clearDriveDetails();
|
||||||
formatDriveCapacityTimer.Start();
|
formatDriveCapacityTimer.Start();
|
||||||
|
|
||||||
|
|
||||||
//Starts the timer for refreshing drive list
|
//Starts the timer for refreshing drive list
|
||||||
driveRefreshTimer.Start();
|
driveRefreshTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void refreshDriveList(){
|
internal void refreshDriveList(){
|
||||||
DriveInfo[] drives = USBTools.getConnectedDrives();
|
DriveInfo[] drives = USBTools.getConnectedDrives();
|
||||||
if (connectedDrivesList.Items.Count == USBTools.countDrives()) { return; }
|
if (connectedDrivesList.Items.Count == USBTools.countDrives()) { return; }
|
||||||
connectedDrivesList.Items.Clear();
|
connectedDrivesList.Items.Clear();
|
||||||
bool deviceStillConnected = false;
|
bool deviceStillConnected = false;
|
||||||
foreach (DriveInfo drive in drives){
|
foreach (DriveInfo drive in drives){
|
||||||
try {
|
ListViewItem driveItem = new ListViewItem(drive.Name + " " + tools.Trim(drive.VolumeLabel, 24));
|
||||||
ListViewItem driveItem = new ListViewItem(drive.Name + " " + drive.VolumeLabel);
|
driveItem.SubItems.Add("X");
|
||||||
driveItem.SubItems.Add("X");
|
connectedDrivesList.Items.Add(driveItem);
|
||||||
connectedDrivesList.Items.Add(driveItem);
|
if (drive.VolumeLabel == driveNameDisplay.Text)
|
||||||
if (drive.VolumeLabel == driveNameDisplay.Text){
|
{
|
||||||
deviceStillConnected = true;
|
deviceStillConnected = true;
|
||||||
driveItem.Selected = true;
|
driveItem.Selected = true;
|
||||||
}
|
}
|
||||||
} catch { continue; }
|
|
||||||
}
|
}
|
||||||
if (!deviceStillConnected) { clearDriveDetails(); }
|
if (!deviceStillConnected) { clearDriveDetails(); }
|
||||||
connectedDrivesList.Sort();
|
connectedDrivesList.Sort();
|
||||||
|
@ -74,7 +72,7 @@ namespace Saviour_Backup_System
|
||||||
foreach (DriveInfo drive in USBTools.getConnectedDrives()) {
|
foreach (DriveInfo drive in USBTools.getConnectedDrives()) {
|
||||||
if (drive.Name == driveName) { selectedDrive = drive; break; }
|
if (drive.Name == driveName) { selectedDrive = drive; break; }
|
||||||
}
|
}
|
||||||
driveNameDisplay.Text = tools.Trim(selectedDrive.VolumeLabel, 15);
|
driveNameDisplay.Text = tools.Trim(selectedDrive.VolumeLabel, 16);
|
||||||
driveLetterDisplay.Text = selectedDrive.Name;
|
driveLetterDisplay.Text = selectedDrive.Name;
|
||||||
driveSystemDisplay.Text = selectedDrive.DriveFormat;
|
driveSystemDisplay.Text = selectedDrive.DriveFormat;
|
||||||
driveTypeDisplay.Text = USBTools.getDriveType(selectedDrive);
|
driveTypeDisplay.Text = USBTools.getDriveType(selectedDrive);
|
||||||
|
@ -101,13 +99,14 @@ namespace Saviour_Backup_System
|
||||||
while (driveCapacityPerc != driveCapacityDisplay.Value) {
|
while (driveCapacityPerc != driveCapacityDisplay.Value) {
|
||||||
if (driveCapacityPerc < driveCapacityDisplay.Value) { driveCapacityDisplay.Value -= 1; }
|
if (driveCapacityPerc < driveCapacityDisplay.Value) { driveCapacityDisplay.Value -= 1; }
|
||||||
if (driveCapacityPerc > driveCapacityDisplay.Value) { driveCapacityDisplay.Value += 1; }
|
if (driveCapacityPerc > driveCapacityDisplay.Value) { driveCapacityDisplay.Value += 1; }
|
||||||
|
driveCapacityDisplay.Text = "Drive Capacity: " + (driveCapacityDisplay.Value / 100).ToString() + "%";
|
||||||
|
|
||||||
//adjust the colour of the progressbar depending on capacity of the drive
|
//adjust the colour of the progressbar depending on capacity of the drive
|
||||||
if (driveCapacityDisplay.Value <= 6800) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Normal; }
|
if (driveCapacityDisplay.Value <= 6800) { driveCapacityDisplay.ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Normal; }
|
||||||
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; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue