Add multichannel export to GUI

Closes #12
This commit is contained in:
Alexey Golub
2019-02-09 19:03:34 +02:00
parent 65c5df89f4
commit e4b0d60c40
13 changed files with 366 additions and 136 deletions

View File

@@ -17,9 +17,11 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
public GuildViewModel Guild { get; set; }
public ChannelViewModel Channel { get; set; }
public IReadOnlyList<ChannelViewModel> Channels { get; set; }
public string FilePath { get; set; }
public bool IsSingleChannel => Channels.Count == 1;
public string OutputPath { get; set; }
public IReadOnlyList<ExportFormat> AvailableFormats =>
Enum.GetValues(typeof(ExportFormat)).Cast<ExportFormat>().ToArray();
@@ -59,18 +61,33 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
if (To < From)
To = From;
// Generate default file name
var defaultFileName = ExportHelper.GetDefaultExportFileName(SelectedFormat, Guild, Channel, From, To);
// If single channel - prompt file path
if (IsSingleChannel)
{
// Get single channel
var channel = Channels.Single();
// Prompt for output file path
var ext = SelectedFormat.GetFileExtension();
var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";
FilePath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
// Generate default file name
var defaultFileName = ExportHelper.GetDefaultExportFileName(SelectedFormat, Guild, channel, From, To);
// Generate filter
var ext = SelectedFormat.GetFileExtension();
var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";
// Prompt user
OutputPath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
}
// If multiple channels - prompt dir path
else
{
// Prompt user
OutputPath = _dialogManager.PromptDirectoryPath();
}
// If canceled - return
if (FilePath.IsBlank())
if (OutputPath.IsBlank())
return;
// Close dialog
Close(true);
}