public RootDirectoryViewModel(ViewModelBase root, FromSoftwareFile fromSoftwareFile)
     : base(root, null, true)
 {
     FromSoftwareFile = fromSoftwareFile;
     CanBeEdited      = false;
     ImagePath        = ImageHelper.BuildImageSourceFromDatabase(fromSoftwareFile.GameName);
 }
Ejemplo n.º 2
0
        public async Task CheckGame2FilesAndDirCountTest()
        {
            var game2       = new FromSoftwareFile(_rootDirectory, "*.sl2", "Game2", true, string.Empty);
            var actualCount = await GetTree(game2);

            Assert.That(7, Is.EqualTo(actualCount));
        }
Ejemplo n.º 3
0
 public FileViewModel(ViewModelBase root, FromSoftwareFile fromSoftwareFile, ITreeViewItemViewModel parent)
     : base(root, parent, fromSoftwareFile.IsDirectory)
 {
     FromSoftwareFile = fromSoftwareFile;
     CanBeEdited      = true;
     _backupFileName  = fromSoftwareFile.FileName;
     FileName         = fromSoftwareFile.FileName;
 }
Ejemplo n.º 4
0
        private static async Task <int> GetTree(FromSoftwareFile fromSoftwareFile)
        {
            int childrenCount = 0;
            var children      = await FileRepository.LoadChildrenAsync(fromSoftwareFile);

            foreach (var child in children)
            {
                childrenCount++;
                int subChildrenCount = await GetTree(child);

                childrenCount += subChildrenCount;
            }

            return(childrenCount);
        }
Ejemplo n.º 5
0
        public static async Task <List <FromSoftwareFile> > LoadChildrenAsync(FromSoftwareFile fromSoftwareFile)
        {
            if (!fromSoftwareFile.IsDirectory)
            {
                return(Empty);
            }

            var filePath = Path.Combine(fromSoftwareFile.Path, fromSoftwareFile.FileName);

            return(await Task.Run(() =>
            {
                return
                FromSoftwareFileSearch.GetGameFiles(fromSoftwareFile.RootDirectory, filePath, fromSoftwareFile.FileSearchPattern)
                .Union(FromSoftwareFileSearch.GetSubDirectories(fromSoftwareFile.RootDirectory, filePath))
                .Select(childrenFile => new FromSoftwareFile(fromSoftwareFile.RootDirectory, fromSoftwareFile.FileSearchPattern, Path.GetFileName(childrenFile), Directory.Exists(childrenFile), filePath))
                .ToList();
            }));
        }