private void GetAllFiles() { // To Avoid re-listing files when Button Tasks from Submenu Clicked. LeftFiles.Clear(); RightFiles.Clear(); List <FileInformation> allLeftFiles = new List <FileInformation>(); List <FileInformation> allRightFiles = new List <FileInformation>(); LeftFiles.Where(l => l.Size != 0).ToList().All(i => LeftFiles.Remove(i)); // Clear LeftFiles. RightFiles.Where(l => l.Size != 0).ToList().All(i => RightFiles.Remove(i)); foreach (KeyValuePair <string, ConfigHub> entry in CoreTask.tasksList) { foreach (Configuration leftConf in entry.Value.LeftSources) { var files = leftConf.GetFiles(); files.All(c => { c.ConfigurationName = entry.Key; return(true); }); allLeftFiles.AddRange(files); } foreach (Configuration rightConf in entry.Value.RightSources) { var files = rightConf.GetFiles(); files.All(c => { c.ConfigurationName = entry.Key; return(true); }); allRightFiles.AddRange(files); } } allLeftFiles.All(c => { c.IsChecked = true; return(true); }); allRightFiles.All(c => { c.IsChecked = true; return(true); }); LeftFiles.AddRange(allLeftFiles); RightFiles.AddRange(allRightFiles); }
private void RightFiles_KeyDown_1(object sender, KeyEventArgs e) { if (e.Key == Key.Right || e.Key == Key.Left) { LeftFiles.Focus(); //TODO: посмотреть как сохранить индекс //Int32 SaveIndex = LeftFiles.SelectedIndex; LeftFiles.Items.Refresh(); //LeftFiles.SelectedIndex = SaveIndex; } KeyDownHandler(sender as ListView, e, RightFiles.SelectedItems, PathRight, PathLeft.Text, FileDescriptionRight); }
private void CompareFiles() { // Lookup foreach entry in LeftFilesDict in RightFilesDict foreach (KeyValuePair <string, FileInformation> entry in leftFilesDictionary) { if (rightFilesDictionary.TryGetValue(entry.Key, out FileInformation outFileInformation)) { if (entry.Value.ModificationTime > outFileInformation.ModificationTime) { var item = LeftFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Newer; } } else if (entry.Value.ModificationTime == outFileInformation.ModificationTime) { var item = LeftFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Equal; } } else { var item = LeftFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Older; } } } else { var item = LeftFiles.First(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Newer; } } } // Similarly for the second set foreach (KeyValuePair <string, FileInformation> entry in rightFilesDictionary) { if (leftFilesDictionary.TryGetValue(entry.Key, out FileInformation outFileInformation)) { if (entry.Value.ModificationTime > outFileInformation.ModificationTime) { var item = RightFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Newer; } } else if (entry.Value.ModificationTime == outFileInformation.ModificationTime) { var item = RightFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Equal; } } else { var item = RightFiles.FirstOrDefault(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Older; } } } else { var item = RightFiles.First(i => i.RelativePath == entry.Key); if (item != null) { item.FileVersion = FileVersion.Newer; } } } }