This commit is contained in:
Michael Bucari-Tovo 2022-12-11 16:58:51 -07:00
parent 8e13aa7513
commit 58a0468728
7 changed files with 26 additions and 39 deletions

View File

@ -20,6 +20,9 @@
Name="replacementGrid" Name="replacementGrid"
AutoGenerateColumns="False" AutoGenerateColumns="False"
IsReadOnly="False" IsReadOnly="False"
BeginningEdit="ReplacementGrid_BeginningEdit"
CellEditEnding="ReplacementGrid_CellEditEnding"
KeyDown="ReplacementGrid_KeyDown"
Items="{Binding replacements}"> Items="{Binding replacements}">
<DataGrid.Columns> <DataGrid.Columns>

View File

@ -20,7 +20,6 @@ namespace LibationAvalonia.Dialogs
{ {
InitializeComponent(); InitializeComponent();
replacements = new(SOURCE); replacements = new(SOURCE);
if (Design.IsDesignMode) if (Design.IsDesignMode)
@ -29,12 +28,6 @@ namespace LibationAvalonia.Dialogs
} }
DataContext = this; DataContext = this;
replacementGrid = this.FindControl<DataGrid>(nameof(replacementGrid));
replacementGrid.BeginningEdit += ReplacementGrid_BeginningEdit;
replacementGrid.CellEditEnding += ReplacementGrid_CellEditEnding;
replacementGrid.KeyDown += ReplacementGrid_KeyDown;
} }
public EditReplacementChars(Configuration config) : this() public EditReplacementChars(Configuration config) : this()
@ -49,11 +42,11 @@ namespace LibationAvalonia.Dialogs
=> LoadTable(ReplacementCharacters.LoFiDefault.Replacements); => LoadTable(ReplacementCharacters.LoFiDefault.Replacements);
public void Barebones_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) public void Barebones_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> LoadTable(ReplacementCharacters.Barebones.Replacements); => LoadTable(ReplacementCharacters.Barebones.Replacements);
public void Save_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) public void Save_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> SaveAndClose(); => SaveAndClose();
public void Cancel_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) public void Cancel_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> Close(); => Close();
protected override void SaveAndClose() protected override void SaveAndClose()
{ {
var replacements = SOURCE var replacements = SOURCE
@ -65,6 +58,7 @@ namespace LibationAvalonia.Dialogs
config.ReplacementCharacters = new ReplacementCharacters { Replacements = replacements }; config.ReplacementCharacters = new ReplacementCharacters { Replacements = replacements };
base.SaveAndClose(); base.SaveAndClose();
} }
private void LoadTable(IReadOnlyList<Replacement> replacements) private void LoadTable(IReadOnlyList<Replacement> replacements)
{ {
SOURCE.Clear(); SOURCE.Clear();
@ -73,7 +67,7 @@ namespace LibationAvalonia.Dialogs
this.replacements.Refresh(); this.replacements.Refresh();
} }
private void ReplacementGrid_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) public void ReplacementGrid_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
{ {
if (e.Key == Avalonia.Input.Key.Delete if (e.Key == Avalonia.Input.Key.Delete
&& replacementGrid.SelectedItem is ReplacementsExt repl && replacementGrid.SelectedItem is ReplacementsExt repl
@ -84,7 +78,7 @@ namespace LibationAvalonia.Dialogs
} }
} }
private void ReplacementGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) public void ReplacementGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{ {
var replacement = e.Row.DataContext as ReplacementsExt; var replacement = e.Row.DataContext as ReplacementsExt;
var colBinding = columnBindingPath(e.Column); var colBinding = columnBindingPath(e.Column);
@ -111,7 +105,7 @@ namespace LibationAvalonia.Dialogs
replacement.PropertyChanged += Replacement_PropertyChanged; replacement.PropertyChanged += Replacement_PropertyChanged;
} }
private void ReplacementGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) public void ReplacementGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{ {
var replacement = e.Row.DataContext as ReplacementsExt; var replacement = e.Row.DataContext as ReplacementsExt;

View File

@ -37,10 +37,13 @@ Find books that you haven't rated:
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields()); " + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields());
IdFields = @" IdFields = @"
Alice's Adventures in Wonderland (ID: B015D78L0U) Alice's Adventures in
Wonderland (ID: B015D78L0U)
id:B015D78L0U id:B015D78L0U
All of these are synonyms for the ID field All of these are synonyms
for the ID field
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchIdFields()); " + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchIdFields());

View File

@ -2,17 +2,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="330" mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="350"
MinWidth="500" MinHeight="330" MinWidth="500" MinHeight="350"
MaxWidth="500" MaxHeight="330" MaxWidth="500" MaxHeight="350"
x:Class="LibationAvalonia.Dialogs.SetupDialog" x:Class="LibationAvalonia.Dialogs.SetupDialog"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Icon="/Assets/libation.ico" Icon="/Assets/libation.ico"
Title="Welcome to Libation"> Title="Welcome to Libation">
<Grid Margin="10" RowDefinitions="*,Auto,Auto"> <Grid Margin="10" ColumnDefinitions="*" RowDefinitions="*,Auto,Auto">
<TextBlock Grid.Row="0" Text="This appears to be your first time using Libation or a previous setup was incomplete. <TextBlock Grid.Row="0" TextWrapping="Wrap" Text="This appears to be your first time using Libation or a previous setup was incomplete.
&#xa; &#xa;
&#xa;Please fill in a few settings. You can also change these settings later. &#xa;Please fill in a few settings. You can also change these settings later.
&#xa; &#xa;
@ -24,9 +24,8 @@
<Button <Button
Grid.Row="1" Grid.Row="1"
Margin="0,10,0,10" Width="480"
Padding="0,10,0,10" Margin="0,0,0,10"
HorizontalAlignment="Stretch"
Click="NewUser_Click"> Click="NewUser_Click">
<TextBlock <TextBlock
@ -37,8 +36,7 @@
<Button <Button
Grid.Row="2" Grid.Row="2"
Padding="0,10,0,10" Width="480"
HorizontalAlignment="Stretch"
Click="ReturningUser_Click"> Click="ReturningUser_Click">
<TextBlock <TextBlock

View File

@ -31,8 +31,7 @@ namespace LibationAvalonia.ViewModels
public List<LibraryBook> GetVisibleBookEntries() public List<LibraryBook> GetVisibleBookEntries()
=> GridEntries => GridEntries
.Cast<GridEntry>() .OfType<LibraryBookEntry>()
.BookEntries()
.Select(lbe => lbe.LibraryBook) .Select(lbe => lbe.LibraryBook)
.ToList(); .ToList();
@ -94,9 +93,7 @@ namespace LibationAvalonia.ViewModels
var episodes = dbBooks.Where(lb => lb.Book.IsEpisodeChild()); var episodes = dbBooks.Where(lb => lb.Book.IsEpisodeChild());
var seriesBooks = dbBooks.Where(lb => lb.Book.IsEpisodeParent()).ToList(); foreach (var parent in dbBooks.Where(lb => lb.Book.IsEpisodeParent()))
foreach (var parent in seriesBooks)
{ {
var seriesEpisodes = episodes.FindChildren(parent); var seriesEpisodes = episodes.FindChildren(parent);

View File

@ -14,12 +14,6 @@ namespace LibationAvalonia.ViewModels
public static IEnumerable<SeriesEntry> SeriesEntries(this IEnumerable<GridEntry> gridEntries) public static IEnumerable<SeriesEntry> SeriesEntries(this IEnumerable<GridEntry> gridEntries)
=> gridEntries.OfType<SeriesEntry>(); => gridEntries.OfType<SeriesEntry>();
public static T? FindByAsin<T>(this IEnumerable<T> gridEntries, string audibleProductID) where T : GridEntry
=> gridEntries.FirstOrDefault(i => i.AudibleProductId == audibleProductID);
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
=> gridEntries.SeriesEntries().Where(i => i.Children.Count == 0);
public static SeriesEntry? FindSeriesParent(this IEnumerable<GridEntry> gridEntries, LibraryBook seriesEpisode) public static SeriesEntry? FindSeriesParent(this IEnumerable<GridEntry> gridEntries, LibraryBook seriesEpisode)
{ {
if (seriesEpisode.Book.SeriesLink is null) return null; if (seriesEpisode.Book.SeriesLink is null) return null;

View File

@ -68,8 +68,6 @@ namespace LibationAvalonia.Views
private async void MainWindow_Opened(object sender, EventArgs e) private async void MainWindow_Opened(object sender, EventArgs e)
{ {
var dialog = new EditReplacementChars();
await dialog.ShowDialog(this);
#if !DEBUG #if !DEBUG
//This is temporaty until we have a solution for linux/mac so that //This is temporaty until we have a solution for linux/mac so that
//Libation doesn't download a zip every time it runs. //Libation doesn't download a zip every time it runs.