private async Task GetFiles(string fileName) { CheckAllFiles.Content = "Go Started"; FileDetailsHolderService fileDetailsHolderService = ServiceLocator.Instance.GetService <FileDetailsHolderService>(); // fileDetailsHolderService.Details.Clear(); string[] files = Directory.GetFiles(fileName, "*.*", SearchOption.AllDirectories); await Task.Run(() => { foreach (string file in files) { if (!fileDetailsHolderService.Details.Any(x => x.FullFilePath == file)) { FileDetails fd = new FileDetails(file); fileDetailsHolderService.Details.Add(fd); ShowDetails.Add(fd); } } }); CheckAllFiles.Content = "Go Done"; }
private async void MatchAllFiles_Click(object sender, RoutedEventArgs e) { FileDetailsHolderService fileDetailsHolderService = ServiceLocator.Instance.GetService <FileDetailsHolderService>(); List <FileDetails> fileDetails = fileDetailsHolderService.Details; List <FileDetails> copy = new List <FileDetails>(); foreach (var fd in fileDetails) { copy.Add(fd); } List <string> exludedList = new List <string>(); foreach (var fd in copy) { if (exludedList.Contains(fd.FullFilePath)) { continue; } foreach (var masterfd in fileDetails) { if (fd == masterfd) { continue; } if (fd.HashCode == masterfd.HashCode) { fd.Matches.Add(masterfd); exludedList.Add(masterfd.FullFilePath); } } foreach (var removed in fd.Matches) { fileDetails.Remove(removed); } } ShowDetails.Clear(); foreach (var f2 in fileDetailsHolderService.Details) { ShowDetails.Add(f2); } this.ItemList.Items.Refresh(); }
private void Drives_SelectionChanged(object sender, SelectionChangedEventArgs e) { string drive = Drives.SelectedItem.ToString(); FileDetailsHolderService fileDetailsHolderService = ServiceLocator.Instance.GetService <FileDetailsHolderService>(); FileDetailsHolderService f = FileDetailsHolderService.Load($@"{drive}Temp\"); fileDetailsHolderService.AddFrom(f); ShowDetails.Clear(); if (f != null) { foreach (var f2 in f.Details) { ShowDetails.Add(f2); } } }
private void DeleteAll_Click(object sender, RoutedEventArgs e) { FileDetailsHolderService fileDetailsHolderService = ServiceLocator.Instance.GetService <FileDetailsHolderService>(); List <MatchItems> itemsToDelete = _matchedItems.Where(x => x.Action == Actions.Delete).ToList(); foreach (var mi in itemsToDelete) { try { File.Delete(mi.FilePathName); FileDetail.Matches.Remove(mi.Store); _matchedItems.Remove(mi); fileDetailsHolderService.Details.Remove(mi.Store); } catch { // just in case we have problems } } fileDetailsHolderService.Details.Remove(FileDetail); }
private void Save_Click(object sender, RoutedEventArgs e) { string drive = Drives.SelectedItem.ToString(); FileDetailsHolderService.Save(Services.ServiceLocator.Instance.GetService <FileDetailsHolderService>(), $@"{drive}Temp\"); }