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 { StackPanel {
// File path // File path
Grid { TextBox {
#TwoColumns("*", "Auto") Margin: "16 16 16 8"
HintAssist.Hint: "Output file"
TextBox { HintAssist.IsFloating: true
Grid.Column: 0 IsReadOnly: true
Margin: "16 16 4 8" Text: bind FilePath
HintAssist.Hint: "Output file" set [ UpdateSourceTrigger: PropertyChanged ]
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
}
}
} }
// Date range // Date range
@ -67,6 +49,14 @@ UserControl "DiscordChatExporter.Views.ExportSetupDialog" {
Style: resource dyn "MaterialDesignFlatButton" Style: resource dyn "MaterialDesignFlatButton"
} }
// Browse
Button "BrowseButton" {
Click: BrowseButton_Click
Content: "BROWSE"
Margin: 8
Style: resource dyn "MaterialDesignFlatButton"
}
// Cancel // Cancel
Button { Button {
Command: DialogHost.CloseDialogCommand Command: DialogHost.CloseDialogCommand

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