Exemple #1
0
        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);
        }
Exemple #2
0
 //Обработка нажатий клавиш
 private void LeftFiles_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Right || e.Key == Key.Left)
     {
         RightFiles.Focus();
         // Int32 SaveIndex = RightFiles.SelectedIndex;
         RightFiles.Items.Refresh();
         // RightFiles.SelectedIndex = SaveIndex;
     }
     KeyDownHandler(sender as ListView, e, LeftFiles.SelectedItems, PathLeft, PathRight.Text, FileDescriptionLeft);
 }
Exemple #3
0
        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;
                    }
                }
            }
        }