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"
AutoGenerateColumns="False"
IsReadOnly="False"
BeginningEdit="ReplacementGrid_BeginningEdit"
CellEditEnding="ReplacementGrid_CellEditEnding"
KeyDown="ReplacementGrid_KeyDown"
Items="{Binding replacements}">
<DataGrid.Columns>

View File

@ -20,7 +20,6 @@ namespace LibationAvalonia.Dialogs
{
InitializeComponent();
replacements = new(SOURCE);
if (Design.IsDesignMode)
@ -29,12 +28,6 @@ namespace LibationAvalonia.Dialogs
}
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()
@ -49,11 +42,11 @@ namespace LibationAvalonia.Dialogs
=> LoadTable(ReplacementCharacters.LoFiDefault.Replacements);
public void Barebones_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
=> 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()
{
var replacements = SOURCE
@ -65,6 +58,7 @@ namespace LibationAvalonia.Dialogs
config.ReplacementCharacters = new ReplacementCharacters { Replacements = replacements };
base.SaveAndClose();
}
private void LoadTable(IReadOnlyList<Replacement> replacements)
{
SOURCE.Clear();
@ -73,7 +67,7 @@ namespace LibationAvalonia.Dialogs
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
&& 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 colBinding = columnBindingPath(e.Column);
@ -111,7 +105,7 @@ namespace LibationAvalonia.Dialogs
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;

View File

@ -37,10 +37,13 @@ Find books that you haven't rated:
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields());
IdFields = @"
Alice's Adventures in Wonderland (ID: B015D78L0U)
Alice's Adventures in
Wonderland (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());

View File

@ -2,17 +2,17 @@
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="330"
MinWidth="500" MinHeight="330"
MaxWidth="500" MaxHeight="330"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="350"
MinWidth="500" MinHeight="350"
MaxWidth="500" MaxHeight="350"
x:Class="LibationAvalonia.Dialogs.SetupDialog"
WindowStartupLocation="CenterScreen"
Icon="/Assets/libation.ico"
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;Please fill in a few settings. You can also change these settings later.
&#xa;
@ -24,9 +24,8 @@
<Button
Grid.Row="1"
Margin="0,10,0,10"
Padding="0,10,0,10"
HorizontalAlignment="Stretch"
Width="480"
Margin="0,0,0,10"
Click="NewUser_Click">
<TextBlock
@ -37,8 +36,7 @@
<Button
Grid.Row="2"
Padding="0,10,0,10"
HorizontalAlignment="Stretch"
Width="480"
Click="ReturningUser_Click">
<TextBlock

View File

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

View File

@ -14,12 +14,6 @@ namespace LibationAvalonia.ViewModels
public static IEnumerable<SeriesEntry> SeriesEntries(this IEnumerable<GridEntry> gridEntries)
=> 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)
{
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)
{
var dialog = new EditReplacementChars();
await dialog.ShowDialog(this);
#if !DEBUG
//This is temporaty until we have a solution for linux/mac so that
//Libation doesn't download a zip every time it runs.