Example #1
0
        public DriveViewModel(DriveInfo d)
        {
            Stopwatch s = new Stopwatch();

            s.Start();

            var path = d.RootDirectory.FullName;

            var imageFilter = new[] { "*.jpg", "*.JPG", "*.png", "*.PNG" };
            var videoFilter = new[] { "*.avi", "*.AVI", "*.mkv", "*.MKV" };

            var images = imageFilter.SelectMany(f => IOExtensions.GetFilesRecursiv(path, f)).Where(p => !p.StartsWith(".")).Select(p => new PhotoFileViewModel(p)).ToList();
            var videos = videoFilter.SelectMany(f => IOExtensions.GetFilesRecursiv(path, f)).Where(p => !p.StartsWith(".")).Select(p => new VideoFileViewModel(p)).ToList();

            ImageCount = images.Count();
            VideoCount = videos.Count();

            SelectedPassenger = UserSelection.SelectedPassenger;

            List <PhotoCollection> photoCollection = new List <PhotoCollection>();;

            if (IOExtensions.GetDirectoriesRecursiv(path, "*CANON").Any()) //Canon folders
            {
                var grouped = images.GroupBy(i => Path.GetDirectoryName(i.Path)).ToList();
                photoCollection.AddRange(grouped.Select(g => new PhotoCollection(g.ToList())));
            }
            else
            {
                var collection = new PhotoCollection(images);
                photoCollection.Add(collection);
            }
            Videos = new List <VideoCollection> {
                new VideoCollection(videos.ToList())
            };

            Photos = photoCollection;

            Debug.WriteLine("DriveVM Loaded : " + s.ElapsedMilliseconds + " ms");
        }