public void Confirm()
        {
            var format = SelectedDownloadOption.Format;

            // Prompt user for output file path
            var filter          = $"{format.ToUpperInvariant()} file|*.{format}";
            var defaultFileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, Video, format);
            var filePath        = _dialogManager.PromptSaveFilePath(filter, defaultFileName);

            // If canceled - return
            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = format;

            // Create download view model
            var download = _viewModelFactory.CreateDownloadViewModel(Video, filePath, format, SelectedDownloadOption);

            // Create empty file to "lock in" the file path
            FileEx.CreateDirectoriesForFile(filePath);
            FileEx.CreateEmptyFile(filePath);

            // Close dialog
            Close(download);
        }
        public void Confirm()
        {
            var format = SelectedDownloadOption.Format;


            var filter          = $"{format.ToUpperInvariant()} file|*.{format}";
            var defaultFileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, Video, format);
            var filePath        = _dialogManager.PromptSaveFilePath(filter, defaultFileName);


            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }


            _settingsService.LastFormat = format;


            var download = _viewModelFactory.CreateDownloadViewModel(Video, filePath, format, SelectedDownloadOption);


            FileEx.CreateDirectoriesForFile(filePath);
            FileEx.CreateEmptyFile(filePath);


            Close(download);
        }
Ejemplo n.º 3
0
        public void Confirm()
        {
            // Prompt user for output directory path
            var dirPath = _dialogManager.PromptDirectoryPath();

            // If canceled - return
            if (string.IsNullOrWhiteSpace(dirPath))
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = SelectedFormat;

            // Make sure selected videos are ordered in the same way as available videos
            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            // Create download view models
            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                // Generate file path
                var number   = (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0');
                var fileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, video, SelectedFormat, number);
                var filePath = Path.Combine(dirPath, fileName);

                // If file exists - either skip it or generate a unique file path, depending on user settings
                if (File.Exists(filePath))
                {
                    if (_settingsService.ShouldSkipExistingFiles && new FileInfo(filePath).Length > 0)
                    {
                        continue;
                    }

                    filePath = FileEx.MakeUniqueFilePath(filePath);
                }

                // Create empty file to "lock in" the file path
                FileEx.CreateDirectoriesForFile(filePath);
                FileEx.CreateEmptyFile(filePath);

                // Create download view model
                var download = _viewModelFactory.CreateDownloadViewModel(video, filePath, SelectedFormat);

                // Add to list
                downloads.Add(download);
            }

            // Close dialog
            Close(downloads);
        }
Ejemplo n.º 4
0
        public void Confirm()
        {
            var dirPath = _dialogManager.PromptDirectoryPath();


            if (string.IsNullOrWhiteSpace(dirPath))
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = SelectedFormat;


            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            // Create download view models
            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                // Generate file path
                var number   = (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0');
                var fileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, video, SelectedFormat, number);
                var filePath = Path.Combine(dirPath, fileName);


                if (File.Exists(filePath))
                {
                    if (_settingsService.ShouldSkipExistingFiles && new FileInfo(filePath).Length > 0)
                    {
                        continue;
                    }

                    filePath = FileEx.MakeUniqueFilePath(filePath);
                }


                FileEx.CreateDirectoriesForFile(filePath);
                FileEx.CreateEmptyFile(filePath);

                // Create dwnloda view model
                var download = _viewModelFactory.CreateDownloadViewModel(video, filePath, SelectedFormat);

                // adaugare la lista
                downloads.Add(download);
            }

            // Close dialog
            Close(downloads);
        }