public void SaveClicked(object parameter)
{
if (string.IsNullOrEmpty(OutputPath))
{
ServiceLocator.Instance.GetService <IInteractionService>().ShowError("Output folder must be selected.");
return;
}
if (SelectedChapters.Count == 0)
{
ServiceLocator.Instance.GetService <IInteractionService>().ShowError("Chapter must be selected.");
return;
}
if (!Directory.Exists(OutputPath))
{
if (ServiceLocator.Instance.GetService <IInteractionService>()
.ShowMessageBox("The output folder doesn't exist. Would you like to create it?",
"Output folder",
MessageBoxButton.YesNo,
MessageBoxImage.Question) == MessageBoxResult.Yes)
{
try
{
Directory.CreateDirectory(OutputPath);
}
catch (Exception ex)
{
_log.Error("Unable to create output folder.", ex);
ServiceLocator.Instance.GetService <IInteractionService>().ShowError("Unable to create output folder");
return;
}
}
else
{
// if user don't want us to create the output folder, we will simply don't start the download
return;
}
}
// save output path to recent list
Properties.Settings.Default.RecentFolders.Add(OutputPath);
OnPropertyChanged(() => RecentFolders);
foreach (var selectedChapter in SelectedChapters)
{
_downloadManager.Download(selectedChapter, OutputPath, CurrentDownloadFormatProvider);
}
}