Refine dialog layouts and presentation

This commit is contained in:
Mbucari 2023-04-04 14:09:40 -06:00 committed by MBucari
parent d737cd2199
commit 5e99cb6f02
34 changed files with 369 additions and 420 deletions

View file

@ -40,7 +40,7 @@
</Path>
</Canvas>
<controls:GroupBox Grid.Row="3" BorderWidth="2" Label="Acknowledgements" Grid.ColumnSpan="2">
<controls:GroupBox Grid.Row="3" Label="Acknowledgements" Grid.ColumnSpan="2">
<StackPanel>
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto">

View file

@ -81,7 +81,7 @@
HorizontalContentAlignment = "Stretch"
HorizontalAlignment = "Stretch"
SelectedItem="{Binding SelectedLocale, Mode=TwoWay}"
Items="{Binding Locales}">
ItemsSource="{Binding Locales}">
<ComboBox.ItemTemplate>
<DataTemplate>
@ -113,14 +113,12 @@
<Button
Grid.Column="0"
Height="30"
Content="Import from audible-cli"
Click="ImportButton_Clicked" />
<Button
Grid.Column="1"
Height="30"
Padding="30,3,30,3"
Padding="30,5"
Content="Save"
Click="SaveButton_Clicked" />
</Grid>

View file

@ -45,7 +45,6 @@
<controls:GroupBox
Label="Edit Tags"
Grid.Row="1"
BorderWidth="1"
Margin="10,0,10,0">
<StackPanel Orientation="Vertical">
@ -63,7 +62,6 @@
<controls:GroupBox
Label="Liberated status: Whether the book/pdf has been downloaded"
Grid.Row="2"
BorderWidth="1"
Margin="10,10,10,10">
<StackPanel Orientation="Vertical">
@ -95,7 +93,7 @@
Height="25"
VerticalAlignment="Center"
SelectedItem="{Binding BookLiberatedSelectedItem, Mode=TwoWay}"
Items="{Binding BookLiberatedItems}">
ItemsSource="{Binding BookLiberatedItems}">
<ComboBox.ItemTemplate>
<DataTemplate>
@ -116,8 +114,8 @@
Height="25"
Width="150"
VerticalAlignment="Center"
SelectedItem="{Binding PdfLiberatedSelectedItem, Mode=TwoWay}"
Items="{Binding PdfLiberatedItems}">
SelectedItem="{Binding PdfLiberatedSelectedItem, Mode=TwoWay}"
ItemsSource="{Binding PdfLiberatedItems}">
<ComboBox.ItemTemplate>
<DataTemplate>

View file

@ -101,13 +101,13 @@
Grid.Column="0"
Grid.Row="0"
Content="Check All"
Click="CheckAll_Click"/>
Command="{Binding CheckAll}"/>
<Button
Grid.Column="0"
Grid.Row="1"
Content="Uncheck All"
Click="UncheckAll_Click"/>
Command="{Binding UncheckAll}"/>
<Button
Grid.Column="1"

View file

@ -77,12 +77,12 @@ namespace LibationAvalonia.Dialogs
await setControlEnabled(sender, true);
}
public void CheckAll_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public void CheckAll()
{
foreach (var record in bookRecordEntries)
record.IsChecked = true;
}
public void UncheckAll_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public void UncheckAll()
{
foreach (var record in bookRecordEntries)
record.IsChecked = false;

View file

@ -99,10 +99,10 @@
<Button
Grid.Column="1"
Height="30"
Padding="30,3,30,3"
Padding="30,5"
Name="saveBtn"
Content="Save"
Click="SaveButton_Clicked" />
Command="{Binding SaveAndClose}" />
</Grid>
</Grid>
</Window>

View file

@ -38,7 +38,7 @@ namespace LibationAvalonia.Dialogs
if (!accounts.Any())
return;
ControlToFocusOnShow = this.FindControl<Button>(nameof(SaveButton_Clicked));
ControlToFocusOnShow = this.FindControl<Button>(nameof(saveBtn));
var allFilters = QuickFilters.Filters.Select(f => new Filter { FilterString = f }).ToList();
allFilters.Add(new Filter());
@ -100,10 +100,5 @@ namespace LibationAvalonia.Dialogs
Filters.Insert(index + 1, filter);
}
}
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
SaveAndClose();
}
}
}

View file

@ -23,7 +23,7 @@
IsReadOnly="False"
BeginningEdit="ReplacementGrid_BeginningEdit"
CellEditEnding="ReplacementGrid_CellEditEnding"
KeyDown="ReplacementGrid_KeyDown"
KeyDown="ReplacementGrid_KeyDown"
Items="{Binding replacements}">
<DataGrid.Columns>
@ -62,9 +62,9 @@
Margin="5"
Orientation="Horizontal">
<Button Margin="0,0,10,0" Click="Defaults_Click" Content="Defaults" />
<Button Margin="0,0,10,0" Click="LoFiDefaults_Click" Content="LoFi Defaults" />
<Button Click="Barebones_Click" Content="Barebones" />
<Button Margin="0,0,10,0" Command="{Binding Defaults}" Content="Defaults" />
<Button Margin="0,0,10,0" Command="{Binding LoFiDefaults}" Content="LoFi Defaults" />
<Button Command="{Binding Barebones}" Content="Barebones" />
</StackPanel>
<StackPanel
@ -73,8 +73,8 @@
Margin="5"
Orientation="Horizontal">
<Button Margin="0,0,10,0" Click="Cancel_Click" Content="Cancel" />
<Button Padding="20,5,20,6" Click="Save_Click" Content="Save" />
<Button Margin="0,0,10,0" Command="{Binding Close}" Content="Cancel" />
<Button Padding="20,5,20,6" Command="{Binding SaveAndClose}" Content="Save" />
</StackPanel>
</Grid>

View file

@ -35,16 +35,12 @@ namespace LibationAvalonia.Dialogs
LoadTable(config.ReplacementCharacters.Replacements);
}
public void Defaults_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public void Defaults()
=> LoadTable(ReplacementCharacters.Default.Replacements);
public void LoFiDefaults_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public void LoFiDefaults()
=> LoadTable(ReplacementCharacters.LoFiDefault.Replacements);
public void Barebones_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public void Barebones()
=> LoadTable(ReplacementCharacters.Barebones.Replacements);
public void Save_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> SaveAndClose();
public void Cancel_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> Close();
protected override void SaveAndClose()
{

View file

@ -33,7 +33,7 @@
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
Content="Reset to Default"
Click="ResetButton_Click" />
Command="{Binding ResetToDefault}"/>
</Grid>
<Grid Grid.Row="1" ColumnDefinitions="Auto,*">
@ -69,8 +69,7 @@
</DataGrid.Columns>
</DataGrid>
<Grid
Grid.Column="1"
Margin="5,0,5,0"

View file

@ -19,14 +19,14 @@ namespace LibationAvalonia.Dialogs
public EditTemplateDialog()
{
AvaloniaXamlLoader.Load(this);
userEditTbox = this.FindControl<TextBox>(nameof(userEditTbox));
InitializeComponent();
if (Design.IsDesignMode)
{
_ = Configuration.Instance.LibationFiles;
var editor = TemplateEditor<Templates.FileTemplate>.CreateFilenameEditor(Configuration.Instance.Books, Configuration.Instance.FileTemplate);
_viewModel = new(Configuration.Instance, editor);
_viewModel.resetTextBox(editor.EditingTemplate.TemplateText);
_viewModel.ResetTextBox(editor.EditingTemplate.TemplateText);
Title = $"Edit {editor.TemplateName}";
DataContext = _viewModel;
}
@ -37,7 +37,7 @@ namespace LibationAvalonia.Dialogs
ArgumentValidator.EnsureNotNull(templateEditor, nameof(templateEditor));
_viewModel = new EditTemplateViewModel(Configuration.Instance, templateEditor);
_viewModel.resetTextBox(templateEditor.EditingTemplate.TemplateText);
_viewModel.ResetTextBox(templateEditor.EditingTemplate.TemplateText);
Title = $"Edit {templateEditor.TemplateName}";
DataContext = _viewModel;
}
@ -67,9 +67,6 @@ namespace LibationAvalonia.Dialogs
public async void SaveButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> await SaveAndCloseAsync();
public void ResetButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> _viewModel.resetTextBox(_viewModel.TemplateEditor.DefaultTemplate);
private class EditTemplateViewModel : ViewModels.ViewModelBase
{
private readonly Configuration config;
@ -115,7 +112,8 @@ namespace LibationAvalonia.Dialogs
public AvaloniaList<Tuple<string, string, string>> ListItems { get; set; }
public void resetTextBox(string value) => UserTemplateText = value;
public void ResetTextBox(string value) => UserTemplateText = value;
public void ResetToDefault() => ResetTextBox(TemplateEditor.DefaultTemplate);
public async Task<bool> Validate()
{

View file

@ -27,6 +27,6 @@
Margin="5"
Padding="30,3,30,3"
Content="Save"
Click="SaveButton_Click" />
Command="{Binding SaveButtonAsync}" />
</Grid>
</Window>

View file

@ -1,6 +1,7 @@
using Avalonia.Controls;
using LibationFileManager;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LibationAvalonia.Dialogs
{
@ -27,9 +28,8 @@ namespace LibationAvalonia.Dialogs
DataContext = dirSelectOptions = new();
}
public async void SaveButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
public async Task SaveButtonAsync()
{
var libationDir = dirSelectOptions.Directory;
if (!System.IO.Directory.Exists(libationDir))

View file

@ -2,21 +2,21 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="130"
mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="135"
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchAutoDialog"
Title="Liberated status: Whether the book has been downloaded"
MinHeight="130" MaxHeight="130"
MinHeight="135" MaxHeight="135"
MinWidth="550" MaxWidth="550"
Width="550" Height="130"
Width="550" Height="135"
WindowStartupLocation="CenterOwner"
Icon="/Assets/libation.ico">
<Grid Margin="10" RowDefinitions="Auto,Auto,Auto">
<Grid Margin="10" RowDefinitions="Auto,Auto">
<StackPanel
Grid.Row="0"
Orientation="Horizontal">
Orientation="Vertical">
<CheckBox
Margin="0,0,0,10"
@ -26,12 +26,6 @@
TextWrapping="Wrap"
Text="If the audio file can be found, set download status to 'Downloaded'" />
</CheckBox>
</StackPanel>
<StackPanel
Grid.Row="1"
Orientation="Horizontal">
<CheckBox
Margin="0,0,0,10"
IsChecked="{Binding SetNotDownloaded, Mode=TwoWay}">
@ -43,11 +37,10 @@
</StackPanel>
<Button
Grid.Row="2"
Padding="30,0,30,0"
Grid.Row="1"
Padding="30,5"
HorizontalAlignment="Right"
Height="25"
Content="Save"
Click="SaveButton_Clicked"/>
Command="{Binding SaveAndClose}"/>
</Grid>
</Window>

View file

@ -10,8 +10,5 @@ namespace LibationAvalonia.Dialogs
InitializeComponent();
DataContext = this;
}
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> SaveAndClose();
}
}

View file

@ -2,25 +2,25 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="100"
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchManualDialog"
Title="Liberated status: Whether the book has been downloaded"
MinWidth="400" MinHeight="120"
MaxWidth="400" MaxHeight="120"
Width="400" Height="120"
MinWidth="400" MinHeight="100"
MaxWidth="400" MaxHeight="100"
Width="400" Height="100"
WindowStartupLocation="CenterOwner"
Icon="/Assets/libation.ico">
<Grid RowDefinitions="Auto,Auto,Auto">
<Grid RowDefinitions="Auto,Auto" ColumnDefinitions="*,Auto">
<TextBlock
Grid.Row="0"
Margin="10,10,10,0"
Grid.ColumnSpan="2"
Margin="10"
Text="To download again next time: change to Not Downloaded&#xa;To not download: change to Downloaded"/>
<StackPanel
Margin="10"
Margin="10,0"
Grid.Row="1"
Orientation="Horizontal">
@ -36,7 +36,7 @@
Height="25"
VerticalAlignment="Center"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
Items="{Binding BookStatuses}">
ItemsSource="{Binding BookStatuses}">
<ComboBox.ItemTemplate>
<DataTemplate>
@ -49,14 +49,15 @@
</ComboBox.ItemTemplate>
</controls:WheelComboBox>
</StackPanel>
<Button
Grid.Row="2"
Padding="30,0,30,0"
Margin="10,0,10,10"
Grid.Row="1"
Grid.Column="1"
Margin="10,0"
Padding="30,5"
VerticalAlignment="Stretch"
HorizontalAlignment="Right"
Height="25"
Content="Save"
Click="SaveButton_Clicked"/>
Click="SaveButton_Clicked" />
</Grid>
</Window>

View file

@ -16,7 +16,7 @@
<TextBlock Text="IDs Found: " />
<TextBlock Text="{Binding FoundAsins}" />
</StackPanel>
<ListBox Margin="0,5,0,0" Grid.Row="1" Grid.ColumnSpan="2" Name="foundAudiobooksLB" Items="{Binding FoundFiles}" AutoScrollToSelectedItem="true">
<ListBox Margin="0,5,0,0" Grid.Row="1" Grid.ColumnSpan="2" Name="foundAudiobooksLB" ItemsSource="{Binding FoundFiles}" AutoScrollToSelectedItem="true">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="Auto,*">

View file

@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="185"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="200"
x:Class="LibationAvalonia.Dialogs.ScanAccountsDialog"
MinWidth="500" MinHeight="160"
Width="500" Height="200"
@ -10,7 +10,7 @@
WindowStartupLocation="CenterOwner"
Icon="/Assets/libation.ico">
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto">
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,*,Auto">
<Grid.Styles>
<Style Selector="Button:focus">
@ -23,20 +23,19 @@
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="10,10,10,0"
Margin="10"
Text="Check the accounts to scan and import.&#xa;To change default selections, go to: Settings > Accounts"/>
<ScrollViewer
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="10,0"
VerticalAlignment="Stretch"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
Margin="10"
MinHeight="90"
MaxHeight="90">
VerticalScrollBarVisibility="Auto">
<ListBox Items="{Binding Accounts}">
<ListBox ItemsSource="{Binding Accounts}">
<ListBox.ItemTemplate>
<DataTemplate>
@ -62,21 +61,19 @@
<Button
Grid.Row="2"
Grid.Column="0"
Padding="20,0,20,0"
Margin="10,0,10,10"
Height="25"
Padding="20,5"
Margin="10"
Content="Edit Accounts"
Click="EditAccountsButton_Clicked"/>
Command="{Binding EditAccountsAsync}"/>
<Button
Grid.Row="2"
Grid.Column="1"
Padding="30,0,30,0"
Margin="10,0,10,10"
Padding="30,5"
Margin="10"
HorizontalAlignment="Right"
Height="25"
Content="Import"
Name="ImportButton"
Click="ImportButton_Clicked"/>
Command="{Binding SaveAndClose}"/>
</Grid>
</Window>

View file

@ -4,6 +4,7 @@ using Avalonia.Interactivity;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LibationAvalonia.Dialogs
{
@ -25,7 +26,7 @@ namespace LibationAvalonia.Dialogs
InitializeComponent();
this.HideMinMaxBtns();
this.Opened += ScanAccountsDialog_Opened;
ControlToFocusOnShow = this.FindControl<Button>(nameof(ImportButton));
LoadAccounts();
}
@ -46,12 +47,7 @@ namespace LibationAvalonia.Dialogs
DataContext = this;
}
private void ScanAccountsDialog_Opened(object sender, System.EventArgs e)
{
this.FindControl<Button>(nameof(ImportButton)).Focus();
}
public async void EditAccountsButton_Clicked(object sender, RoutedEventArgs e)
public async Task EditAccountsAsync()
{
if (await new AccountsDialog().ShowDialog<DialogResult>(this) == DialogResult.OK)
{
@ -67,7 +63,5 @@ namespace LibationAvalonia.Dialogs
base.SaveAndClose();
}
public void ImportButton_Clicked(object sender, RoutedEventArgs e) => SaveAndClose();
}
}

View file

@ -31,21 +31,18 @@
<Setter Property="Height" Value="30"/>
</Style>
<Style Selector="TabControl /template/ ContentPresenter#PART_SelectedContentHost">
<Setter Property="BorderBrush" Value="{DynamicResource DataGridGridLinesBrush}" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="{DynamicResource SystemBaseLowColor}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style Selector="TabItem">
<Setter Property="MinHeight" Value="40"/>
<Setter Property="Height" Value="40"/>
<Setter Property="MinHeight" Value="45"/>
<Setter Property="Height" Value="45"/>
<Setter Property="Padding" Value="8,2,8,10"/>
<Style Selector="^ > TextBlock" >
<Setter Property="FontSize" Value="14" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Style>
<Style Selector="Button">
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</TabControl.Styles>
<TabItem>

View file

@ -2,33 +2,32 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="630" d:DesignHeight="110"
mc:Ignorable="d" d:DesignWidth="630" d:DesignHeight="90"
x:Class="LibationAvalonia.Dialogs.TagsBatchDialog"
MinWidth="630" MinHeight="110"
MaxWidth="630" MaxHeight="110"
MinWidth="630" MinHeight="90"
MaxWidth="630" MaxHeight="90"
Width="630" Height="110"
Title="Replace Tags"
WindowStartupLocation="CenterOwner"
Icon="/Assets/libation.ico">
<Grid RowDefinitions="Auto,Auto,Auto">
<Grid RowDefinitions="Auto,Auto" ColumnDefinitions="*,Auto" Margin="10">
<TextBlock
Grid.Row="0"
Margin="10,10,10,0"
Grid.ColumnSpan="2"
Margin="0,0,0,10"
Text="Tags are separated by a space. Each tag can contain letters, numbers, and underscores"/>
<TextBox
Grid.Row="1"
Margin="10"
MinHeight="25"
Name="EditTagsTb"
Text="{Binding NewTags, Mode=TwoWay}" />
<Button
Grid.Row="2"
Padding="30,0,30,0"
Margin="10,0,10,10"
HorizontalAlignment="Right"
Height="25"
Grid.Row="1"
Grid.Column="1"
Margin="10,0,0,0"
Padding="20,3"
VerticalAlignment="Stretch"
Content="Save"
Click="SaveButton_Clicked"/>
Command="{Binding SaveAndClose}"/>
</Grid>
</Window>

View file

@ -12,8 +12,5 @@ namespace LibationAvalonia.Dialogs
DataContext = this;
}
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> SaveAndClose();
}
}

View file

@ -52,12 +52,12 @@
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
Content="Restore"
Click="Restore_Click" />
Command="{Binding RestoreCheckedAsync}"/>
<Button
IsEnabled="{Binding ControlsEnabled}"
Grid.Column="3"
Click="EmptyTrash_Click" >
Command="{Binding PermanentlyDeleteCheckedAsync}" >
<TextBlock
TextAlignment="Center"
Text="Permanently Delete&#xa;from Libation" />

View file

@ -16,26 +16,19 @@ namespace LibationAvalonia.Dialogs
{
public partial class TrashBinDialog : Window
{
TrashBinViewModel _viewModel;
public TrashBinDialog()
{
InitializeComponent();
this.RestoreSizeAndLocation(Configuration.Instance);
DataContext = _viewModel = new();
DataContext = new TrashBinViewModel();
this.Closing += (_, _) => this.SaveSizeAndLocation(Configuration.Instance);
this.KeyDown += TrashBinDialog_KeyDown;
}
public async void EmptyTrash_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> await _viewModel.PermanentlyDeleteCheckedAsync();
public async void Restore_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> await _viewModel.RestoreCheckedAsync();
private void TrashBinDialog_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
{
if (e.Key == Avalonia.Input.Key.Escape)
Close();
KeyBindings.Add(new Avalonia.Input.KeyBinding
{
Gesture = new Avalonia.Input.KeyGesture(Avalonia.Input.Key.Escape),
Command = ReactiveCommand.Create(Close)
});
}
}

View file

@ -21,7 +21,6 @@
<controls:GroupBox
Grid.Row="1"
BorderWidth="2"
Label="Release Information"
Margin="0,10,0,10">