// Workers' event handlers private void DirScanner_OnProgressChanged(DirScanner sender, string message) { base.Invoke((Action) delegate { appStatus.Text = message; }); }
private void ScanButton_Click(object sender, EventArgs e) { if (!Directory.Exists(rootDirectoryTextBox.Text)) { appStatus.Text = "Root directory doesn't exist."; return; } scanButton.Enabled = false; pauseButton.Enabled = true; cancelButton.Enabled = true; hashButton.Enabled = false; diffButton.Enabled = false; dirScanner = new DirScanner(); dirScanner.RootDir = rootDirectoryTextBox.Text; dirScanner.OnFinished += DirScanner_OnFinished; dirScanner.OnProgressChanged += DirScanner_OnProgressChanged; dirScanner.Start(); }
private void DirScanner_OnFinished(DirScanner sender, string message) { appStatus.Text = message; scanButton.Enabled = true; pauseButton.Enabled = false; resumeButton.Enabled = false; cancelButton.Enabled = false; diffButton.Enabled = true; if (sender.Finished) { hashButton.Enabled = true; } if (windowClosing) { Close(); } }
private static DirectoryInfo[] GetSourceDirectories(IList <string> list) { if (list.IndexOf("--scan-dir") < 0) { throw new Exception("No --source-dir provided!"); } var scanDir = list[list.IndexOf("--scan-dir") + 1]; var packagesDirs = new DirectoryInfo(scanDir); var excludeRootPackageDirectories = list.IndexOf("--ignore-root-package-directories") != -1; var scanner = new DirScanner(packagesDirs, excludeRootPackageDirectories); var scanDirTask = Task.Run(() => { scanner.Work(); return(scanner.Result); }); var sources = scanDirTask.Result.ToArray(); return(sources); }