public virtual void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null) { cancelled = false; this.viewModel = viewModel; viewModel.ParitySet.ErrorMessage += HandleErrorMessage; viewModel.StartProgress(); startTime = DateTime.Now; inProgress = true; drive = selectedDrive; errorMessages.Clear(); if (ScanFirst && viewModel.Drives.Count > 0) { scanning = true; viewModel.Status = "Scanning drives..."; runningScans = 0; scanProgress = new double[viewModel.Drives.Count]; foreach (DataDriveViewModel vm in viewModel.Drives) { if ((scanDrive != null && vm == scanDrive) || (scanDrive == null && vm != skipDrive)) { Interlocked.Increment(ref runningScans); vm.PropertyChanged += HandleDataDrivePropertyChanged; vm.DataDrive.ScanCompleted += HandleScanCompleted; vm.Scan(auto); // runs in a separate Task } } } else { Run(); } }
private DataDriveViewModel AddDrive(DataDrive drive) { DataDriveViewModel vm = new DataDriveViewModel(drive, config); drives.Add(vm); drive.PropertyChanged += HandleDateDrivePropertyChanged; drive.ScanCompleted += HandleScanCompleted; return(vm); }
/// <summary> /// Callback from RemoveDriveOperation when a drive has been removed /// </summary> public void DriveRemoved(DataDriveViewModel drive) { drive.DataDrive.PropertyChanged -= HandleDateDrivePropertyChanged; drive.DataDrive.ScanCompleted -= HandleScanCompleted; // Can only modify the drives collection on the main thread Application.Current.Dispatcher.Invoke(new Action(() => { drives.Remove(drive); })); }
/// <summary> /// Removes a drive from the parity set which has already been confirmed to be empty /// </summary> private void RemoveEmptyDrive(DataDriveViewModel vm) { try { viewModel.ParitySet.RemoveEmptyDrive(vm.DataDrive); } catch (Exception e) { App.LogCrash(e); MessageWindow.ShowError(viewModel.Owner, "Error removing drive", e.Message); return; } viewModel.DriveRemoved(vm); Status = vm.DataDrive.Root + " removed"; }
public void Begin(CancellableOperation operation, DataDriveViewModel drive = null) { try { Debug.Assert(!Busy); operation.Finished += HandleOperationFinished; operationInProgress = operation; operation.Begin(vm, drive); } catch (Exception e) { App.LogCrash(e); LogFile.Log("Exception trying to begin {0}: {1} ", operation.Name, e.Message); } }
/// <summary> /// Adds a new drive with the given path to the parity set /// </summary> public void AddDrive(string path) { bool warned = false; if (Utils.PathsAreOnSameDrive(path, Config.ParityDir)) { bool?result = MessageWindow.Show(owner, "Duplicate drives detected!", "The path you selected appears to be on same drive as your parity.\n\n" + "This is not recommended. If the drive fails, disParity will not be able to recover any of your data.\n\n" + "Are you sure you want to add this drive?", MessageWindowIcon.Error, MessageWindowButton.YesNo); if (result == false) { return; } warned = true; } if (!warned) // so we don't warn twice if the data and parity drives are already on the same drive as this one { foreach (DataDrive d in paritySet.Drives) { if (Utils.PathsAreOnSameDrive(path, d.Root)) { bool?result = MessageWindow.Show(owner, "Duplicate drives detected!", "The path you selected appears to be on a drive that is already part of the array.\n\n" + "This is not recommended. If the drive fails, disParity will not be able to recover any of your data.\n\n" + "Are you sure you want to add this drive?", MessageWindowIcon.Error, MessageWindowButton.YesNo); if (result == false) { return; } else if (result == true) { break; } } } } DataDriveViewModel vm = AddDrive(paritySet.AddDrive(path)); ScanDrive(vm); UpdateStartupMessage(); }
public void ScanDrive(DataDriveViewModel drive) { operationManager.Begin(new ScanOperation(), drive); }
public virtual void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null) { cancelled = false; this.viewModel = viewModel; viewModel.ParitySet.ErrorMessage += HandleErrorMessage; viewModel.StartProgress(); startTime = DateTime.Now; inProgress = true; drive = selectedDrive; errorMessages.Clear(); if (ScanFirst && viewModel.Drives.Count > 0) { scanning = true; viewModel.Status = "Scanning drives..."; runningScans = 0; scanProgress = new double[viewModel.Drives.Count]; foreach (DataDriveViewModel vm in viewModel.Drives) if ((scanDrive != null && vm == scanDrive) || (scanDrive == null && vm != skipDrive)) { Interlocked.Increment(ref runningScans); vm.PropertyChanged += HandleDataDrivePropertyChanged; vm.DataDrive.ScanCompleted += HandleScanCompleted; vm.Scan(auto); // runs in a separate Task } } else Run(); }
private DataDriveViewModel AddDrive(DataDrive drive) { DataDriveViewModel vm = new DataDriveViewModel(drive, config); drives.Add(vm); drive.PropertyChanged += HandleDateDrivePropertyChanged; drive.ScanCompleted += HandleScanCompleted; return vm; }
public void RemoveDrive(DataDriveViewModel drive) { operationManager.Begin(new RemoveDriveOperation(), drive); }
public void Undelete(DataDriveViewModel drive) { operationManager.Begin(new UndeleteOperation(), drive); }
public void Hashcheck(DataDriveViewModel drive = null) { operationManager.Begin(new HashcheckOperation(), drive); }
public override void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null) { skipDrive = selectedDrive; base.Begin(viewModel, selectedDrive); }