Merge pull request #1534 from Mbucari/master

Improve LocateAudiobooksDialog and fix Classic upgrade dialog
This commit is contained in:
rmcrackan
2026-01-06 07:26:08 -05:00
committed by GitHub
7 changed files with 232 additions and 191 deletions

View File

@@ -3,6 +3,9 @@
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="600" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450"
xmlns:uibase="clr-namespace:LibationUiBase;assembly=LibationUiBase"
x:DataType="uibase:LocatedAudiobooksViewModel"
x:CompileBindings="True"
Width="600" Height="450" Width="600" Height="450"
x:Class="LibationAvalonia.Dialogs.LocateAudiobooksDialog" x:Class="LibationAvalonia.Dialogs.LocateAudiobooksDialog"
Title="Locate Audiobooks" Title="Locate Audiobooks"
@@ -13,17 +16,34 @@
<StackPanel Grid.Column="1" Orientation="Horizontal"> <StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Text="IDs Found: " /> <TextBlock Text="IDs Found: " />
<TextBlock Text="{Binding FoundAsins}" /> <TextBlock Text="{Binding FoundAsinCount}" />
</StackPanel> </StackPanel>
<ListBox Margin="0,5,0,0" Grid.Row="1" Grid.ColumnSpan="2" Name="foundAudiobooksLB" ItemsSource="{Binding FoundFiles}" AutoScrollToSelectedItem="true"> <DataGrid
<ListBox.ItemTemplate> Margin="0,5,0,0"
<DataTemplate> Grid.Row="1"
<Grid ColumnDefinitions="Auto,*"> Grid.ColumnSpan="2"
<TextBlock Grid.Column="0" Margin="0,0,10,0" Text="{Binding Item1}" /> IsReadOnly="True"
<TextBlock Grid.Column="1" Text="{Binding Item2}" /> CanUserSortColumns="True"
</Grid> CanUserResizeColumns="True"
</DataTemplate> GridLinesVisibility="All"
</ListBox.ItemTemplate> DoubleTapped="foundFilesDataGrid_DoubleTapped"
</ListBox> Name="foundFilesDataGrid"
ItemsSource="{Binding FoundFiles}">
<DataGrid.Styles>
<Style Selector="DataGridCell TextBlock">
<Setter Property="ToolTip.Tip" Value="Double-click to open containing folder."/>
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTextColumn
Header="Found ID"
Width="Auto"
Binding="{Binding ID}" />
<DataGridTextColumn
Header="Found File"
Width="*"
Binding="{Binding FileName}" />
</DataGrid.Columns>
</DataGrid>
</Grid> </Grid>
</Window> </Window>

View File

@@ -1,41 +1,39 @@
using ApplicationServices;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using DataLayer; using DataLayer;
using LibationAvalonia.ViewModels; using Dinah.Core;
using LibationFileManager; using LibationFileManager;
using ReactiveUI; using LibationUiBase;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reactive.Linq;
using System.Threading; using System.Threading;
namespace LibationAvalonia.Dialogs namespace LibationAvalonia.Dialogs
{ {
public partial class LocateAudiobooksDialog : DialogWindow public partial class LocateAudiobooksDialog : DialogWindow
{ {
private event EventHandler<FilePathCache.CacheEntry>? FileFound;
private readonly CancellationTokenSource tokenSource = new(); private readonly CancellationTokenSource tokenSource = new();
private readonly List<string> foundAsins = new();
private readonly LocatedAudiobooksViewModel _viewModel; private readonly LocatedAudiobooksViewModel _viewModel;
public LocateAudiobooksDialog() public LocateAudiobooksDialog()
{ {
InitializeComponent(); InitializeComponent();
DataContext = _viewModel = new(); var list = new AvaloniaList<FoundAudiobook>();
DataContext = _viewModel = new(list);
list.CollectionChanged += (_, _) => foundFilesDataGrid.ScrollIntoView(list[^1], foundFilesDataGrid.Columns[0]);
this.RestoreSizeAndLocation(Configuration.Instance); this.RestoreSizeAndLocation(Configuration.Instance);
if (Design.IsDesignMode) if (Design.IsDesignMode)
{ {
_viewModel.FoundFiles.Add(new("[0000001]", "Filename 1.m4b")); _viewModel.AddFoundFile(new("0000000001", FileType.Audio, "Filename 1.m4b"));
_viewModel.FoundFiles.Add(new("[0000002]", "Filename 2.m4b")); _viewModel.AddFoundFile(new("0000000002", FileType.Audio, "Filename 2.m4b"));
} }
else else
{ {
Opened += LocateAudiobooksDialog_Opened; Opened += LocateAudiobooksDialog_Opened;
FileFound += LocateAudiobooks_FileFound;
Closing += LocateAudiobooksDialog_Closing; Closing += LocateAudiobooksDialog_Closing;
} }
} }
@@ -49,19 +47,6 @@ namespace LibationAvalonia.Dialogs
this.SaveSizeAndLocation(Configuration.Instance); this.SaveSizeAndLocation(Configuration.Instance);
} }
private void LocateAudiobooks_FileFound(object? sender, FilePathCache.CacheEntry e)
{
var newItem = new Tuple<string, string>($"[{e.Id}]", Path.GetFileName(e.Path));
_viewModel.FoundFiles.Add(newItem);
foundAudiobooksLB.SelectedItem = newItem;
if (!foundAsins.Any(asin => asin == e.Id))
{
foundAsins.Add(e.Id);
_viewModel.FoundAsins = foundAsins.Count;
}
}
private async void LocateAudiobooksDialog_Opened(object? sender, EventArgs e) private async void LocateAudiobooksDialog_Opened(object? sender, EventArgs e)
{ {
var folderPicker = new FolderPickerOpenOptions var folderPicker = new FolderPickerOpenOptions
@@ -76,37 +61,18 @@ namespace LibationAvalonia.Dialogs
if (selectedFolder is null || !Directory.Exists(selectedFolder)) if (selectedFolder is null || !Directory.Exists(selectedFolder))
{ {
await CancelAndCloseAsync(); await CancelAndCloseAsync();
return;
} }
else
await foreach (var book in AudioFileStorage.FindAudiobooksAsync(selectedFolder, tokenSource.Token))
{ {
try await _viewModel.FindAndAddBooksAsync(selectedFolder, tokenSource.Token);
{ await MessageBox.Show(this, $"Libation has found {_viewModel.FoundAsinCount} unique audiobooks and added them to its database. ", $"Found {_viewModel.FoundAsinCount} Audiobooks");
FilePathCache.Insert(book);
var lb = DbContexts.GetLibraryBook_Flat_NoTracking(book.Id);
if (lb is not null && lb.Book?.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
await lb.UpdateBookStatusAsync(LiberatedStatus.Liberated);
tokenSource.Token.ThrowIfCancellationRequested();
FileFound?.Invoke(this, book);
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
Serilog.Log.Error(ex, "Error adding found audiobook file to Libation. {@audioFile}", book);
}
} }
}
await MessageBox.Show(this, $"Libation has found {foundAsins.Count} unique audiobooks and added them to its database. ", $"Found {foundAsins.Count} Audiobooks"); private void foundFilesDataGrid_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
await SaveAndCloseAsync(); {
if (sender is DataGrid dg && dg.SelectedItem is FoundAudiobook foundAudiobook)
Go.To.File(foundAudiobook.Entry.Path);
} }
} }
public class LocatedAudiobooksViewModel : ViewModelBase
{
public AvaloniaList<Tuple<string, string>> FoundFiles { get; } = new();
public int FoundAsins { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
}
} }

View File

@@ -0,0 +1,71 @@
using ApplicationServices;
using DataLayer;
using LibationFileManager;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace LibationUiBase;
public class FoundAudiobook
{
public string ID => Entry.Id;
public string FileName { get; }
public FilePathCache.CacheEntry Entry { get; }
public FoundAudiobook(FilePathCache.CacheEntry entry)
{
Entry = entry;
FileName = Path.GetFileName(entry.Path);
}
}
public class LocatedAudiobooksViewModel : ReactiveObject
{
public IList<FoundAudiobook> FoundFiles { get; }
public int FoundAsinCount { get => field; private set => RaiseAndSetIfChanged(ref field, value); }
private readonly HashSet<string> foundAsinsSet = [];
public LocatedAudiobooksViewModel(IList<FoundAudiobook> fileList)
{
FoundFiles = fileList;
}
public void AddFoundFile(FilePathCache.CacheEntry entry)
{
FoundAudiobook foundFile = new(entry);
Invoke(() => FoundFiles?.Add(foundFile));
if (!foundAsinsSet.Contains(entry.Id))
{
foundAsinsSet.Add(entry.Id);
FoundAsinCount = foundAsinsSet.Count;
}
}
public async Task FindAndAddBooksAsync(string searchdir, CancellationToken cancellation)
{
await Task.Run(() => FindAndAddBooksInternal(searchdir, cancellation), cancellation).ConfigureAwait(false);
}
private async Task FindAndAddBooksInternal(string searchdir, CancellationToken cancellation)
{
await foreach (var book in AudioFileStorage.FindAudiobooksAsync(searchdir, cancellation))
{
try
{
FilePathCache.Insert(book);
var lb = DbContexts.GetLibraryBook_Flat_NoTracking(book.Id);
if (lb is not null && lb.Book?.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
await lb.UpdateBookStatusAsync(LiberatedStatus.Liberated);
cancellation.ThrowIfCancellationRequested();
AddFoundFile(book);
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
Serilog.Log.Error(ex, "Error adding found audiobook file to Libation. {@audioFile}", book);
}
}
}
}

View File

@@ -28,80 +28,111 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); components = new System.ComponentModel.Container();
this.foundAudiobooksLV = new System.Windows.Forms.ListView(); label1 = new System.Windows.Forms.Label();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); booksFoundLbl = new System.Windows.Forms.Label();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); dataGridView1 = new System.Windows.Forms.DataGridView();
this.booksFoundLbl = new System.Windows.Forms.Label(); foundAudiobookBindingSource = new System.Windows.Forms.BindingSource(components);
this.SuspendLayout(); iDDataGridViewTextBoxColumn = new AccessibleDataGridViewColumn();
fileNameDataGridViewTextBoxColumn = new AccessibleDataGridViewColumn();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
((System.ComponentModel.ISupportInitialize)foundAudiobookBindingSource).BeginInit();
SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9); label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(108, 15); label1.Size = new System.Drawing.Size(108, 15);
this.label1.TabIndex = 1; label1.TabIndex = 1;
this.label1.Text = "Found Audiobooks"; label1.Text = "Found Audiobooks";
//
// foundAudiobooksLV
//
this.foundAudiobooksLV.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.foundAudiobooksLV.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.foundAudiobooksLV.FullRowSelect = true;
this.foundAudiobooksLV.Location = new System.Drawing.Point(12, 33);
this.foundAudiobooksLV.Name = "foundAudiobooksLV";
this.foundAudiobooksLV.Size = new System.Drawing.Size(321, 261);
this.foundAudiobooksLV.TabIndex = 2;
this.foundAudiobooksLV.UseCompatibleStateImageBehavior = false;
this.foundAudiobooksLV.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Book ID";
this.columnHeader1.Width = 85;
//
// columnHeader2
//
this.columnHeader2.Text = "Title";
// //
// booksFoundLbl // booksFoundLbl
// //
this.booksFoundLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); booksFoundLbl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
this.booksFoundLbl.AutoSize = true; booksFoundLbl.AutoSize = true;
this.booksFoundLbl.Location = new System.Drawing.Point(253, 9); booksFoundLbl.Location = new System.Drawing.Point(253, 9);
this.booksFoundLbl.Name = "booksFoundLbl"; booksFoundLbl.Name = "booksFoundLbl";
this.booksFoundLbl.Size = new System.Drawing.Size(80, 15); booksFoundLbl.Size = new System.Drawing.Size(72, 15);
this.booksFoundLbl.TabIndex = 3; booksFoundLbl.TabIndex = 3;
this.booksFoundLbl.Text = "IDs Found: {0}"; booksFoundLbl.Text = "IDs Found: 0";
this.booksFoundLbl.TextAlign = System.Drawing.ContentAlignment.TopRight; booksFoundLbl.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
dataGridView1.AutoGenerateColumns = false;
dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { iDDataGridViewTextBoxColumn, fileNameDataGridViewTextBoxColumn });
dataGridView1.DataSource = foundAudiobookBindingSource;
dataGridView1.Location = new System.Drawing.Point(12, 27);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersVisible = false;
dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
dataGridView1.Size = new System.Drawing.Size(321, 267);
dataGridView1.TabIndex = 4;
dataGridView1.CellDoubleClick += dataGridView1_CellDoubleClick;
//
// foundAudiobookBindingSource
//
foundAudiobookBindingSource.DataSource = typeof(LibationUiBase.FoundAudiobook);
//
// iDDataGridViewTextBoxColumn
//
iDDataGridViewTextBoxColumn.AccessibilityDescription = "Audiobook's Audible product ID forund by the scan.";
iDDataGridViewTextBoxColumn.AccessibilityName = "Found ASIN";
iDDataGridViewTextBoxColumn.DataPropertyName = "ID";
iDDataGridViewTextBoxColumn.HeaderText = "Found ID";
iDDataGridViewTextBoxColumn.Name = "iDDataGridViewTextBoxColumn";
iDDataGridViewTextBoxColumn.ReadOnly = true;
iDDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
iDDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
iDDataGridViewTextBoxColumn.Width = 80;
//
// fileNameDataGridViewTextBoxColumn
//
fileNameDataGridViewTextBoxColumn.AccessibilityDescription = "Audiobook file found. Double-click to open containing folder.";
fileNameDataGridViewTextBoxColumn.AccessibilityName = "Found File";
fileNameDataGridViewTextBoxColumn.DataPropertyName = "FileName";
fileNameDataGridViewTextBoxColumn.HeaderText = "Found File";
fileNameDataGridViewTextBoxColumn.Name = "fileNameDataGridViewTextBoxColumn";
fileNameDataGridViewTextBoxColumn.ReadOnly = true;
fileNameDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
fileNameDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
fileNameDataGridViewTextBoxColumn.Width = 87;
// //
// LocateAudiobooksDialog // LocateAudiobooksDialog
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(345, 306); ClientSize = new System.Drawing.Size(345, 306);
this.Controls.Add(this.booksFoundLbl); Controls.Add(dataGridView1);
this.Controls.Add(this.foundAudiobooksLV); Controls.Add(booksFoundLbl);
this.Controls.Add(this.label1); Controls.Add(label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Name = "LocateAudiobooksDialog"; Name = "LocateAudiobooksDialog";
this.Text = "Locate Audiobooks"; Text = "Locate Audiobooks";
this.ResumeLayout(false); FormClosing += LocateAudiobooks_FormClosing;
this.PerformLayout(); Shown += LocateAudiobooks_Shown;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
((System.ComponentModel.ISupportInitialize)foundAudiobookBindingSource).EndInit();
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListView foundAudiobooksLV;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Label booksFoundLbl; private System.Windows.Forms.Label booksFoundLbl;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.BindingSource foundAudiobookBindingSource;
private AccessibleDataGridViewColumn iDDataGridViewTextBoxColumn;
private AccessibleDataGridViewColumn fileNameDataGridViewTextBoxColumn;
} }
} }

View File

@@ -1,53 +1,35 @@
using ApplicationServices; using DataLayer;
using DataLayer; using Dinah.Core;
using LibationFileManager; using LibationFileManager;
using LibationUiBase;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace LibationWinForms.Dialogs namespace LibationWinForms.Dialogs
{ {
public partial class LocateAudiobooksDialog : Form public partial class LocateAudiobooksDialog : Form
{ {
private event EventHandler<FilePathCache.CacheEntry> FileFound;
private readonly CancellationTokenSource tokenSource = new(); private readonly CancellationTokenSource tokenSource = new();
private readonly List<string> foundAsins = new(); private readonly LocatedAudiobooksViewModel _viewModel;
private readonly string labelFormatText;
public LocateAudiobooksDialog() public LocateAudiobooksDialog()
{ {
InitializeComponent(); InitializeComponent();
labelFormatText = booksFoundLbl.Text;
setFoundBookCount(0);
this.SetLibationIcon(); this.SetLibationIcon();
this.RestoreSizeAndLocation(Configuration.Instance); this.RestoreSizeAndLocation(Configuration.Instance);
Shown += LocateAudiobooks_Shown; _viewModel = new LocatedAudiobooksViewModel(new SortBindingList<FoundAudiobook>());
FileFound += LocateAudiobooks_FileFound; dataGridView1.EnableHeadersVisualStyles = !Application.IsDarkModeEnabled;
FormClosing += LocateAudiobooks_FormClosing; dataGridView1.RowsAdded += DataGridView1_RowsAdded;
foundAudiobookBindingSource.DataSource = _viewModel.FoundFiles;
booksFoundLbl.DataBindings.Add(new Binding(nameof(booksFoundLbl.Text), _viewModel, nameof(_viewModel.FoundAsinCount), true, DataSourceUpdateMode.OnPropertyChanged, 0, booksFoundLbl.Text));
} }
private void setFoundBookCount(int count) private void DataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
=> booksFoundLbl.Text = string.Format(labelFormatText, count);
private void LocateAudiobooks_FileFound(object sender, FilePathCache.CacheEntry e)
{ {
foundAudiobooksLV.Items dataGridView1.FirstDisplayedScrollingRowIndex = e.RowIndex;
.Add(new ListViewItem(new string[] { $"[{e.Id}]", Path.GetFileName(e.Path) }))
.EnsureVisible();
foundAudiobooksLV.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
if (!foundAsins.Any(asin => asin == e.Id))
{
foundAsins.Add(e.Id);
setFoundBookCount(foundAsins.Count);
}
} }
private void LocateAudiobooks_FormClosing(object sender, FormClosingEventArgs e) private void LocateAudiobooks_FormClosing(object sender, FormClosingEventArgs e)
@@ -65,34 +47,22 @@ namespace LibationWinForms.Dialogs
InitialDirectory = Configuration.Instance.Books InitialDirectory = Configuration.Instance.Books
}; };
if (fbd.ShowDialog() != DialogResult.OK || !Directory.Exists(fbd.SelectedPath)) var result = fbd.ShowDialog(this);
if (result != DialogResult.OK || !Directory.Exists(fbd.SelectedPath))
{ {
Close(); DialogResult = result;
return;
} }
else
await foreach (var book in AudioFileStorage.FindAudiobooksAsync(fbd.SelectedPath, tokenSource.Token))
{ {
try await _viewModel.FindAndAddBooksAsync(fbd.SelectedPath, tokenSource.Token);
{ MessageBox.Show(this, $"Libation has found {_viewModel.FoundAsinCount} unique audiobooks and added them to its database. ", $"Found {_viewModel.FoundAsinCount} Audiobooks");
FilePathCache.Insert(book);
var lb = DbContexts.GetLibraryBook_Flat_NoTracking(book.Id);
if (lb.Book.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
await lb.UpdateBookStatusAsync(LiberatedStatus.Liberated);
tokenSource.Token.ThrowIfCancellationRequested();
this.Invoke(FileFound, this, book);
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
Serilog.Log.Error(ex, "Error adding found audiobook file to Libation. {@audioFile}", book);
}
} }
}
MessageBox.Show(this, $"Libation has found {foundAsins.Count} unique audiobooks and added them to its database. ", $"Found {foundAsins.Count} Audiobooks"); private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
Close(); {
if (e.RowIndex >= 0 && e.RowIndex < _viewModel.FoundFiles.Count)
Go.To.File(_viewModel.FoundFiles[e.RowIndex].Entry.Path);
} }
} }
} }

View File

@@ -24,21 +24,6 @@ namespace LibationWinForms.Dialogs
releaseNotesTbox.Text = upgradeProperties.Notes; releaseNotesTbox.Text = upgradeProperties.Notes;
Shown += (_, _) => yesBtn.Focus(); Shown += (_, _) => yesBtn.Focus();
Load += UpgradeNotificationDialog_Load;
}
private void UpgradeNotificationDialog_Load(object sender, EventArgs e)
{
//This dialog starts before Form1, soposition it at the center of where Form1 will be.
var savedState = Configuration.Instance.GetNonString<FormSizeAndPosition>(defaultValue: null, nameof(Form1));
if (savedState is null) return;
int x = savedState.X + (savedState.Width - Width) / 2;
int y = savedState.Y + (savedState.Height - Height) / 2;
Location = new(x, y);
TopMost = true;
} }
private void PackageDlLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void PackageDlLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

View File

@@ -11,14 +11,12 @@ namespace LibationWinForms
{ {
setProgressVisible(false); setProgressVisible(false);
#pragma warning disable CS8321 // Local function is declared but never used #pragma warning disable CS8321 // Local function is declared but never used
Task upgradeAvailable(UpgradeEventArgs e) async Task upgradeAvailable(UpgradeEventArgs e)
{ {
var notificationResult = new UpgradeNotificationDialog(e.UpgradeProperties).ShowDialog(this); var notificationResult = await new UpgradeNotificationDialog(e.UpgradeProperties).ShowDialogAsync(this);
e.Ignore = notificationResult == DialogResult.Ignore; e.Ignore = notificationResult == DialogResult.Ignore;
e.InstallUpgrade = notificationResult == DialogResult.Yes; e.InstallUpgrade = notificationResult == DialogResult.Yes;
return Task.CompletedTask;
} }
#pragma warning restore CS8321 // Local function is declared but never used #pragma warning restore CS8321 // Local function is declared but never used