public PassengerViewModel(string path) { RootPath = path; PhotoPath = Path.Combine(RootPath, "photos"); VideoPath = Path.Combine(RootPath, "video"); PhotoFolderExist = Directory.Exists(PhotoPath); VideoFolderExist = Directory.Exists(VideoPath); var folderNameinfos = Path.GetFileName(path).Split('-').Select(s => s.Trim()).ToList(); Date = new DateTime(int.Parse(folderNameinfos[0]), int.Parse(folderNameinfos[1]), int.Parse(folderNameinfos[2])); FullName = folderNameinfos[5]; IsCEP = folderNameinfos[3].ToLower().Contains("cep"); IsPhoto = folderNameinfos[6].ToLower().Contains("photos"); IsVideo = folderNameinfos[6].ToLower().Contains("video"); OpenPhotoFolderCommand = new MyCommand(null, () => Process.Start(PhotoPath)); if (!IsVideo) { TandemType = TandemType.Photo; } else if (!IsPhoto) { TandemType = TandemType.Video; } else { TandemType = TandemType.VideoPhoto; } PhotoCount = IOExtensions.PhotoExtensions.Select(e => IOExtensions.GetFilesRecursiv(RootPath, e).Count) .Sum(); VideoCount = IOExtensions.VideoExtensions.Select(e => IOExtensions.GetFilesRecursiv(RootPath, e).Count) .Sum(); }
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"); }
static void Main(string[] args) { if (args == null || args.Length != 1) { return; } var path = args.First(); FileAttributes attr = File.GetAttributes(path); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { //It's a directory var videos = IOExtensions.VideoExtensions.SelectMany(f => IOExtensions.GetFilesRecursiv(path, f)).Where(p => !p.StartsWith(".")).Distinct(); foreach (var v in videos) { AnalyseVideo(v).ContinueWith(t => { var video = t.Result; var output = Path.Combine(@"C:\Users\Marc\Desktop\Analyse", Path.GetFileNameWithoutExtension(video.Name) + ".json"); File.Open(output, FileMode.Create).Dispose(); File.WriteAllText(output, JsonConvert.SerializeObject(video), Encoding.UTF8); }).Wait(); } } else { AnalyseVideo(path).ContinueWith(t => { var video = t.Result; var output = Path.Combine(@"C:\Users\Marc\Desktop\Analyse", Path.GetFileNameWithoutExtension(video.Name) + ".json"); File.Open(output, FileMode.Create).Dispose(); File.WriteAllText(output, JsonConvert.SerializeObject(video), Encoding.UTF8); }); } Console.ReadLine(); }
private void SelectedDriveChanged() { var videos = IOExtensions.VideoExtensions.SelectMany(f => IOExtensions.GetFilesRecursiv(SelectedDrive, f)).Where(p => !p.StartsWith(".")).Distinct().Select(p => new Video(p)); var tmpDirectoryPath = Path.Combine(_rootDirectory, "temp"); if (Directory.Exists(tmpDirectoryPath)) { Directory.Delete(tmpDirectoryPath, true); } Directory.CreateDirectory(tmpDirectoryPath); foreach (var video in videos) { _videoService.Copy(video, Path.Combine(tmpDirectoryPath)).ContinueWith(async t => { var startTime = await _videoService.GetStartFrame(video); if (startTime.HasValue) { await _videoService.Cut(video, startTime.Value - 3, _rootDirectory); } }); } }