Esempio n. 1
0
        public async Task <IPictureGridViewModel> LoadAPictureGridViewModel(string folderPath, List <string> searchPatterns)
        {
            // Check if folder is already opened.
            //todo: think about if user opens the same folder but with different search patterns
            var pictureGridViewModel = PictureGridViewModels.ToList().Find(picGrid =>
                                                                           ((PictureGridViewModel)picGrid).AbsolutePath == folderPath);

            if (pictureGridViewModel == null)
            {
                var pictureFileNames = await _fileService.GetFileNamesFromDirectoryAsync(folderPath, searchPatterns);

                pictureGridViewModel = _pictureGridViewModelCreator();
                PictureGridViewModels.Add(pictureGridViewModel);
                if (pictureFileNames.Count > 0)
                {
                    pictureGridViewModel.Load(pictureFileNames);
                }
                else
                {
                    pictureGridViewModel.LoadEmptyFolder(folderPath);
                }
            }

            return(pictureGridViewModel);
        }
Esempio n. 2
0
        public IPictureGridViewModel LoadAPictureGridViewModel(List <string> pictureFileNames)
        {
            // Check if folder is already opened.
            var pictureGridViewModel = PictureGridViewModels.ToList().Find(picGrid =>
                                                                           ((PictureGridViewModel)picGrid).AbsolutePath == pictureFileNames.First().ToParentFolderPath());

            if (pictureGridViewModel == null)
            {
                pictureGridViewModel = _pictureGridViewModelCreator();
                PictureGridViewModels.Add(pictureGridViewModel);
                pictureGridViewModel.Load(pictureFileNames);
            }
            else
            {
                // Remove any duplicates.
                pictureFileNames.RemoveAll(fileName => PictureGridViewModels.ToList()
                                           .Exists(gridViewModel => gridViewModel.Pictures.ToList()
                                                   .Exists(pic => pic.FullFileName == fileName)));

                if (pictureFileNames.Count > 0)
                {
                    pictureGridViewModel.Load(pictureFileNames);
                }
                else
                {
                    pictureGridViewModel = SelectedPictureGridViewModel;
                }
            }

            return(pictureGridViewModel);
        }