/// <summary> /// Refreshes the list of availalable drives. /// </summary> /// <returns>The status of the drives.</returns> public DriveStatus RefreshDrives() { if (this.driveService == null) { throw new InvalidOperationException("Media type must be selected first."); } // Initialize the drives DriveStatus result = this.driveService.Initialize(); this.logging.Write("Devices initialized", result.ToString()); // Display the next screen switch (this.mediaType) { case MediaType.Usb: this.PopulateUsbDrives(); this.view.DisplayUsbScreen(); this.view.ScreenTitle = Properties.Resources.TitleUsb; break; case MediaType.Dvd: this.view.DisplayDvdScreen(); this.view.ScreenTitle = Properties.Resources.TitleDvd; break; default: throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid media type {0}.", this.mediaType)); } this.view.DriveStatus = result; return(result); }
/// <summary> /// Begins the backup process. /// </summary> /// <param name="drivePath">The path to the selected drive.</param> public void BeginBackup(string drivePath) { // Re-initilize the drive service to get the lastest status before begining. DriveStatus status = this.RefreshDrives(); if (status == DriveStatus.Ready && this.mediaType == MediaType.Usb) { // Don't continue for empty drive path. Happens if the user clicks continue without selecting a drive. if (String.IsNullOrEmpty(drivePath)) { return; } status = this.driveService.SetActiveDrive(drivePath); this.logging.Write("Drive selected", drivePath, status.ToString()); } string driveLabel = GetDriveLabel(this.driveService.ActiveDrive); this.view.SelectedDriveLabel = driveLabel; // Display appropriate prompts for erasing the drive before allowing to continue backup. bool ready = status == DriveStatus.Ready || (status == DriveStatus.DeviceNotBlank && DialogResult.OK == this.view.DisplayMessage( String.Format(CultureInfo.InvariantCulture, Properties.Resources.UsbEraseMessage, driveLabel), Properties.Resources.UsbFreeSpaceCaption, Properties.Resources.UsbFreeSpaceErase, Properties.Resources.UsbFreeSpaceCancel) && DialogResult.Yes == MessageBox.Show( String.Format(CultureInfo.InvariantCulture, Properties.Resources.UsbEraseConfirm, driveLabel), Properties.Resources.UsbFreeSpaceCaption, MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2, 0)); // Begin burning if ready. if (ready) { this.view.DisableStandby = true; // Disable standby during backup. this.canceling = false; this.driveService.BeginBackup(); this.view.DisplayProgressScreen(); this.view.ScreenTitle = this.mediaType == MediaType.Usb ? Properties.Resources.TitleUsbProgress : Properties.Resources.TitleDvdProgress; this.logging.Write("Backup started"); } else { this.view.DriveStatus = status; } }