Ejemplo n.º 1
0
 public FileEntryViewModel(FileEntry model, IEnumerable<KeyValuePair<int?, BlockStatus>> blockList, StfsPackage parent)
 {
     Parent = parent;
     _model = model;
     _blocks = new ObservableCollection<FileBlockViewModel>();
     foreach (var block in blockList)
     {
         FileBlockHealthStatus status;
         if (!block.Key.HasValue) status = FileBlockHealthStatus.Missing;
         else
         {
             switch (block.Value)
             {
                 case BlockStatus.Allocated:
                 case BlockStatus.NewlyAllocated:
                     status = FileBlockHealthStatus.Ok;
                     break;
                 default:
                     status = FileBlockHealthStatus.Unallocated;
                     break;
             }
         }
         var vm = new FileBlockViewModel(block.Key, status);
         _blocks.Add(vm);
     }
 }
Ejemplo n.º 2
0
 private FileSystemItem CreateModel(FileEntry f, string path)
 {
     return new FileSystemItem
     {
         Name = f.Name,
         Type = f.IsDirectory ? ItemType.Directory : ItemType.File,
         Path = path,
         FullPath = string.Format(@"{0}:\{1}", _stfs.DisplayName, path),
         Date = DateTimeExtensions.FromFatFileTime(f.AccessTimeStamp),
         Size = f.FileSize
     };
 }
Ejemplo n.º 3
0
 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;
 }