Redesign file picker in ExportSetupDialog

pull/17/head
Alexey Golub 7 years ago
parent d251e8ecf6
commit 77d0956f5d

@ -6,31 +6,13 @@ UserControl "DiscordChatExporter.Views.ExportSetupDialog" {
StackPanel {
// File path
Grid {
#TwoColumns("*", "Auto")
TextBox {
Grid.Column: 0
Margin: "16 16 4 8"
HintAssist.Hint: "Output file"
HintAssist.IsFloating: true
Text: bind FilePath
set [ UpdateSourceTrigger: PropertyChanged ]
}
Button "LocateFilePathButton" {
Grid.Column: 1
Margin: "4 16 16 8"
Padding: 4
Click: LocateFilePathButton_Click
Style: resource dyn "MaterialDesignFlatButton"
PackIcon {
Kind: PackIconKind.DotsHorizontal
Width: 24
Height: 24
}
}
TextBox {
Margin: "16 16 16 8"
HintAssist.Hint: "Output file"
HintAssist.IsFloating: true
IsReadOnly: true
Text: bind FilePath
set [ UpdateSourceTrigger: PropertyChanged ]
}
// Date range
@ -67,6 +49,14 @@ UserControl "DiscordChatExporter.Views.ExportSetupDialog" {
Style: resource dyn "MaterialDesignFlatButton"
}
// Browse
Button "BrowseButton" {
Click: BrowseButton_Click
Content: "BROWSE"
Margin: 8
Style: resource dyn "MaterialDesignFlatButton"
}
// Cancel
Button {
Command: DialogHost.CloseDialogCommand

@ -10,14 +10,14 @@ namespace DiscordChatExporter.Views
{
public partial class ExportSetupDialog
{
private IExportSetupViewModel ViewModel => (IExportSetupViewModel) DataContext;
public ExportSetupDialog()
{
InitializeComponent();
}
private IExportSetupViewModel ViewModel => (IExportSetupViewModel) DataContext;
private string GetOutputFileFilter()
private string GetFilter()
{
var filters = new List<string>();
foreach (var format in ViewModel.AvailableFormats)
@ -29,12 +29,17 @@ namespace DiscordChatExporter.Views
return filters.JoinToString("|");
}
public void LocateFilePathButton_Click(object sender, RoutedEventArgs args)
public void ExportButton_Click(object sender, RoutedEventArgs args)
{
DialogHost.CloseDialogCommand.Execute(null, null);
}
public void BrowseButton_Click(object sender, RoutedEventArgs args)
{
var sfd = new SaveFileDialog
{
FileName = ViewModel.FilePath,
Filter = GetOutputFileFilter(),
Filter = GetFilter(),
FilterIndex = ViewModel.AvailableFormats.IndexOf(ViewModel.SelectedFormat) + 1,
AddExtension = true,
Title = "Select output file"
@ -46,10 +51,5 @@ namespace DiscordChatExporter.Views
ViewModel.SelectedFormat = ViewModel.AvailableFormats[sfd.FilterIndex - 1];
}
}
public void ExportButton_Click(object sender, RoutedEventArgs args)
{
DialogHost.CloseDialogCommand.Execute(null, null);
}
}
}
Loading…
Cancel
Save