private static TreeItemViewModel BuildTree(FileEntry parent)
 {
     var treeItem = new TreeItemViewModel
                        {
                            Name = parent.Name, 
                            Children = new ObservableCollection<TreeItemViewModel>(),
                            IsDirectory = parent.IsDirectory
                        };
     foreach (var folder in parent.Folders)
     {
         treeItem.Children.Add(BuildTree(folder));
     }
     foreach (var file in parent.Files)
     {
         treeItem.Children.Add(new TreeItemViewModel { Name = file.Name });
     }
     return treeItem;
 }
 public TreeItemViewModel(TreeItemViewModel parent) : this()
 {
     Parent = parent;
 }
Exemple #3
0
 public TreeItemViewModel(TreeItemViewModel parent) : this()
 {
     Parent = parent;
 }
 private void WrapTreeIntoViewModels(TreeItem<FileSystemItem> tree, ObservableCollection<TreeItemViewModel> children, TreeItemViewModel parent)
 {
     foreach (var treeItem in tree.Children.Values)
     {
         var icon = treeItem.Content.Type == ItemType.Directory ? "/Resources/folder.png" : "/Resources/file.png";
         var vm = new TreeItemViewModel(parent)
                      {
                          Name = treeItem.Name,
                          Title = treeItem.Content.Title,
                          Content = treeItem.Content,
                          Thumbnail = StfsPackageExtensions.GetBitmapFromByteArray(treeItem.Content.Thumbnail ?? ResourceManager.GetContentByteArray(icon)),
                          IsChecked = true,
                          IsDirectory = treeItem.Content.Type == ItemType.Directory
                      };
         children.Add(vm);
         WrapTreeIntoViewModels(treeItem, vm.Children, vm);
     }
 }