Add error handling to ProductsGrid.DataGridView_CellContentClick
This commit is contained in:
parent
76b5e09f72
commit
b65875386d
@ -165,7 +165,7 @@ namespace FileLiberator
|
||||
LameConfig = GetLameOptions(config)
|
||||
};
|
||||
|
||||
var chapters = getChapters(contentLic.ContentMetadata.ChapterInfo.Chapters).OrderBy(c => c.StartOffsetMs).ToList();
|
||||
var chapters = flattenChapters(contentLic.ContentMetadata.ChapterInfo.Chapters).OrderBy(c => c.StartOffsetMs).ToList();
|
||||
|
||||
if (config.AllowLibationFixup || outputFormat == OutputFormat.Mp3)
|
||||
{
|
||||
@ -192,7 +192,7 @@ namespace FileLiberator
|
||||
return dlOptions;
|
||||
}
|
||||
|
||||
public static List<AudibleApi.Common.Chapter> getChapters(IEnumerable<AudibleApi.Common.Chapter> chapters)
|
||||
public static List<AudibleApi.Common.Chapter> flattenChapters(IEnumerable<AudibleApi.Common.Chapter> chapters, string titleConcat = ": ")
|
||||
{
|
||||
List<AudibleApi.Common.Chapter> chaps = new();
|
||||
|
||||
@ -200,19 +200,14 @@ namespace FileLiberator
|
||||
{
|
||||
if (c.Chapters is not null)
|
||||
{
|
||||
c.Chapters[0] = new AudibleApi.Common.Chapter
|
||||
{
|
||||
Title = c.Chapters[0].Title,
|
||||
StartOffsetMs = c.StartOffsetMs,
|
||||
StartOffsetSec = c.StartOffsetSec,
|
||||
LengthMs = c.LengthMs + c.Chapters[0].LengthMs,
|
||||
Chapters = c.Chapters[0].Chapters
|
||||
};
|
||||
c.Chapters[0].StartOffsetMs = c.StartOffsetMs;
|
||||
c.Chapters[0].StartOffsetSec = c.StartOffsetSec;
|
||||
c.Chapters[0].LengthMs += c.LengthMs;
|
||||
|
||||
var children = getChapters(c.Chapters);
|
||||
var children = flattenChapters(c.Chapters);
|
||||
|
||||
foreach (var child in children)
|
||||
child.Title = string.IsNullOrEmpty(c.Title) ? child.Title : $"{c.Title}: {child.Title}";
|
||||
child.Title = $"{c.Title}{titleConcat}{child.Title}";
|
||||
|
||||
chaps.AddRange(children);
|
||||
}
|
||||
|
||||
@ -49,6 +49,8 @@ namespace LibationWinForms.GridView
|
||||
|
||||
#region Button controls
|
||||
private void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// handle grid button click: https://stackoverflow.com/a/13687844
|
||||
if (e.RowIndex < 0)
|
||||
@ -91,6 +93,11 @@ namespace LibationWinForms.GridView
|
||||
RemovableCountChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, $"An error was encountered while processing a user click in the {nameof(ProductsGrid)}");
|
||||
}
|
||||
}
|
||||
|
||||
private GridEntry getGridEntry(int rowIndex) => gridEntryDataGridView.GetBoundItem<GridEntry>(rowIndex);
|
||||
|
||||
|
||||
@ -185,11 +185,11 @@ namespace FileLiberator.Tests
|
||||
}
|
||||
};
|
||||
|
||||
var flatChapters = DownloadDecryptBook.getChapters(hierarchicalChapters).OrderBy(c => c.StartOffsetMs).ToArray();
|
||||
var flatChapters = DownloadDecryptBook.flattenChapters(hierarchicalChapters);
|
||||
|
||||
flatChapters.Length.Should().Be(flatChapters.Length);
|
||||
flatChapters.Count.Should().Be(expected.Length);
|
||||
|
||||
for (int i = 0; i < flatChapters.Length; i++)
|
||||
for (int i = 0; i < flatChapters.Count; i++)
|
||||
{
|
||||
flatChapters[i].Title.Should().Be(expected[i].Title);
|
||||
flatChapters[i].StartOffsetMs.Should().Be(expected[i].StartOffsetMs);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user