From 77d0956f5d34f6889fdae506f605706aa2f13106 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 1 Oct 2017 00:32:10 +0300 Subject: [PATCH] Redesign file picker in ExportSetupDialog --- .../Views/ExportSetupDialog.ammy | 40 +++++++------------ .../Views/ExportSetupDialog.ammy.cs | 20 +++++----- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/DiscordChatExporter/Views/ExportSetupDialog.ammy b/DiscordChatExporter/Views/ExportSetupDialog.ammy index a44a567a..b5390565 100644 --- a/DiscordChatExporter/Views/ExportSetupDialog.ammy +++ b/DiscordChatExporter/Views/ExportSetupDialog.ammy @@ -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 diff --git a/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs b/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs index f732b953..53065c80 100644 --- a/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs +++ b/DiscordChatExporter/Views/ExportSetupDialog.ammy.cs @@ -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(); 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); - } } } \ No newline at end of file