Пример #1
0
        private void rootCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            file_tree = new FileTreeViewItem(null);
            file_tree.PropertyChanged += new PropertyChangedEventHandler(file_tree_PropertyChanged);

            List<DetectedFile> saves = game.Saves.Flatten();

            // This gets every detected save file
            foreach (DetectedFile save in saves) {
                // This tests if the save is from the currently selected root folder
                if (save.AbsoluteRoot == game.DetectedLocations[rootCombo.SelectedItem.ToString()].FullDirPath) {
                    string path = Path.Combine(save.Path, save.Name);
                    file_tree.addFile(new List<string>(path.Split(Path.DirectorySeparatorChar)), save);
                    // Splits the path into folders
                }
            }

            if (file_tree.Children.Count == 0) {
                CheckedTreeViewItem nofiles = new CheckedTreeViewItem(null);
                nofiles.Name = Strings.GetLabelString("NoFilesFound");
                file_tree.Children.Add(nofiles);
                fileTree.IsEnabled = false;
                saveButton.IsEnabled = false;
            } else {
                fileTree.IsEnabled = true;
                saveButton.IsEnabled = true;
            }
            fileTree.DataContext = file_tree;
        }
Пример #2
0
        private void rootCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            file_tree = new FileTreeViewItem(null);
            file_tree.PropertyChanged += new PropertyChangedEventHandler(file_tree_PropertyChanged);

            List <DetectedFile> saves = game.Saves.Flatten();

            // This gets every detected save file
            foreach (DetectedFile save in saves)
            {
                // This tests if the save is from the currently selected root folder
                if (save.AbsoluteRoot == game.DetectedLocations[rootCombo.SelectedItem.ToString()].FullDirPath)
                {
                    string path = Path.Combine(save.Path, save.Name);
                    file_tree.addFile(new List <string>(path.Split(Path.DirectorySeparatorChar)), save);
                    // Splits the path into folders
                }
            }


            if (file_tree.Children.Count == 0)
            {
                CheckedTreeViewItem nofiles = new CheckedTreeViewItem(null);
                nofiles.Name = Strings.GetLabelString("NoFilesFound");
                file_tree.Children.Add(nofiles);
                fileTree.IsEnabled   = false;
                saveButton.IsEnabled = false;
            }
            else
            {
                fileTree.IsEnabled   = true;
                saveButton.IsEnabled = true;
            }
            fileTree.DataContext = file_tree;
        }
Пример #3
0
        public void addFile(List <string> file_path, DetectedFile file)
        {
            foreach (FileTreeViewItem item in _children)
            {
                if (file_path[0] == item.Name)
                {
                    file_path.RemoveAt(0);
                    item.addFile(file_path, file);
                    return;
                }
            }

            FileTreeViewItem new_item = new FileTreeViewItem(this);

            if (file_path.Count > 0)
            {
                new_item.Name = file_path[0];
                if (file_path.Count > 1)
                {
                    file_path.RemoveAt(0);
                    new_item.addFile(file_path, file);
                }
                else
                {
                    new_item.file = file;
                }
                _children.Add(new_item);
            }
        }
Пример #4
0
        private List <DetectedFile> traverseTree(FileTreeViewItem item)
        {
            List <DetectedFile> return_me = new List <DetectedFile>();

            foreach (FileTreeViewItem sub_item in item.Children)
            {
                if (sub_item.IsChecked != null && sub_item.IsChecked == true && sub_item.file != null)
                {
                    return_me.Add(sub_item.file);
                }
                if (sub_item.Children.Count > 0)
                {
                    return_me.AddRange(traverseTree(sub_item));
                }
            }
            return(return_me);
        }
Пример #5
0
        public void addFile(List<string> file_path, DetectedFile file)
        {
            foreach (FileTreeViewItem item in _children) {
                if (file_path[0] == item.Name) {
                    file_path.RemoveAt(0);
                    item.addFile(file_path, file);
                    return;
                }
            }

            FileTreeViewItem new_item = new FileTreeViewItem(this);

            if (file_path.Count > 0) {
                new_item.Name = file_path[0];
                if (file_path.Count > 1) {
                    file_path.RemoveAt(0);
                    new_item.addFile(file_path, file);
                } else {
                    new_item.file = file;
                }
                _children.Add(new_item);
            }
        }
Пример #6
0
 private List<DetectedFile> traverseTree(FileTreeViewItem item)
 {
     List<DetectedFile> return_me = new List<DetectedFile>();
     foreach (FileTreeViewItem sub_item in item.Children) {
         if (sub_item.IsChecked != null && sub_item.IsChecked == true && sub_item.file != null) {
             return_me.Add(sub_item.file);
         }
         if (sub_item.Children.Count > 0) {
             return_me.AddRange(traverseTree(sub_item));
         }
     }
     return return_me;
 }