private void Add_Click(object sender, RoutedEventArgs e) { using (var dialog = new System.Windows.Forms.FolderBrowserDialog()) { if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var entry = new AnnotatedPathEntry(PathEntry.FromFilePath(dialog.SelectedPath)); UserPath.Add(entry); } } }
private void Scan_Click(object sender, RoutedEventArgs e) { var currentPaths = CompletePath.Select(_ => _.Path); var search = new SearchOperation("C:\\", 4, new ScanningWindow()); Task <IEnumerable <string> > .Factory.StartNew(search.Run).ContinueWith(task => { if (task.IsFaulted) { return; // Too bad } var binDirectories = task.Result; binDirectories .Select(PathEntry.FromFilePath) .Where(path => !currentPaths.Contains(path)) .Each(path => UserPath.Add(new AnnotatedPathEntry(path))); }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void Scan_Click(object sender, RoutedEventArgs e) { var currentPaths = CompletePath.Select(_ => _.Path); var window = new ScanningWindow(); var search = new SearchOperation("C:\\", 4, window); Task <IEnumerable <string> > .Factory.StartNew(search.Run); if (window.ShowDialog() == true) { UserPath.SupressNotification = true; search.Result .Select(PathEntry.FromFilePath) .Where(path => !currentPaths.Contains(path)) .Each(path => UserPath.Add(new AnnotatedPathEntry(path))); UserPath.SupressNotification = false; } }