Typos and small error correction.
This commit is contained in:
parent
3e2d69606b
commit
e37a2ccca9
@ -1,17 +1,14 @@
|
|||||||
using Dinah.Core.Net.Http;
|
using System;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace FileLiberator
|
namespace FileLiberator
|
||||||
{
|
{
|
||||||
public interface IAudioDecodable : IStreamProcessable
|
public interface IAudioDecodable : IStreamProcessable
|
||||||
{
|
{
|
||||||
|
|
||||||
event EventHandler<Action<byte[]>> RequestCoverArt;
|
event EventHandler<Action<byte[]>> RequestCoverArt;
|
||||||
event EventHandler<string> TitleDiscovered;
|
event EventHandler<string> TitleDiscovered;
|
||||||
event EventHandler<string> AuthorsDiscovered;
|
event EventHandler<string> AuthorsDiscovered;
|
||||||
event EventHandler<string> NarratorsDiscovered;
|
event EventHandler<string> NarratorsDiscovered;
|
||||||
event EventHandler<byte[]> CoverImageDiscovered;
|
event EventHandler<byte[]> CoverImageDiscovered;
|
||||||
|
|
||||||
void Cancel();
|
void Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
{
|
{
|
||||||
public abstract class LiberationBaseForm : Form
|
public abstract class LiberationBaseForm : Form
|
||||||
{
|
{
|
||||||
protected IFileLiberator Liberation { get; private set; }
|
protected IFileLiberator FileLiberator { get; private set; }
|
||||||
protected LogMe LogMe { get; private set; }
|
protected LogMe LogMe { get; private set; }
|
||||||
|
|
||||||
private int InstanceThreadId { get; } = Thread.CurrentThread.ManagedThreadId;
|
private int InstanceThreadId { get; } = Thread.CurrentThread.ManagedThreadId;
|
||||||
@ -24,18 +24,19 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
SyncContext = SynchronizationContext.Current;
|
SyncContext = SynchronizationContext.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterLiberation(IFileLiberator liberation, LogMe logMe = null)
|
public void RegisterLiberation(IFileLiberator fileLiberator, LogMe logMe = null)
|
||||||
{
|
{
|
||||||
if (liberation is null) return;
|
//IFileLiberator must at least be IStreamable, otherwise the Form won't ever Show()
|
||||||
|
if (fileLiberator is null || fileLiberator is not IStreamable streamable) return;
|
||||||
|
|
||||||
Liberation = liberation;
|
FileLiberator = fileLiberator;
|
||||||
LogMe = logMe;
|
LogMe = logMe;
|
||||||
|
|
||||||
if (Liberation is IStreamable streamable)
|
|
||||||
Subscribe(streamable);
|
Subscribe(streamable);
|
||||||
if (Liberation is IProcessable processable)
|
|
||||||
|
if (FileLiberator is IProcessable processable)
|
||||||
Subscribe(processable);
|
Subscribe(processable);
|
||||||
if (Liberation is IAudioDecodable audioDecodable)
|
if (FileLiberator is IAudioDecodable audioDecodable)
|
||||||
Subscribe(audioDecodable);
|
Subscribe(audioDecodable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
{
|
{
|
||||||
UnsubscribeStreamable(this, EventArgs.Empty);
|
UnsubscribeStreamable(this, EventArgs.Empty);
|
||||||
|
|
||||||
streamable.StreamingBegin += ShowFormHandler;
|
streamable.StreamingBegin += OnStreamingBeginShow;
|
||||||
streamable.StreamingBegin += OnStreamingBegin;
|
streamable.StreamingBegin += OnStreamingBegin;
|
||||||
streamable.StreamingProgressChanged += OnStreamingProgressChanged;
|
streamable.StreamingProgressChanged += OnStreamingProgressChanged;
|
||||||
streamable.StreamingTimeRemaining += OnStreamingTimeRemaining;
|
streamable.StreamingTimeRemaining += OnStreamingTimeRemaining;
|
||||||
@ -84,12 +85,12 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
}
|
}
|
||||||
private void UnsubscribeStreamable(object sender, EventArgs e)
|
private void UnsubscribeStreamable(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Liberation is not IStreamable streamable)
|
if (FileLiberator is not IStreamable streamable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FormClosed -= UnsubscribeStreamable;
|
FormClosed -= UnsubscribeStreamable;
|
||||||
|
|
||||||
streamable.StreamingBegin -= ShowFormHandler;
|
streamable.StreamingBegin -= OnStreamingBeginShow;
|
||||||
streamable.StreamingBegin -= OnStreamingBegin;
|
streamable.StreamingBegin -= OnStreamingBegin;
|
||||||
streamable.StreamingProgressChanged -= OnStreamingProgressChanged;
|
streamable.StreamingProgressChanged -= OnStreamingProgressChanged;
|
||||||
streamable.StreamingTimeRemaining -= OnStreamingTimeRemaining;
|
streamable.StreamingTimeRemaining -= OnStreamingTimeRemaining;
|
||||||
@ -98,7 +99,7 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
}
|
}
|
||||||
private void UnsubscribeProcessable(object sender, LibraryBook e)
|
private void UnsubscribeProcessable(object sender, LibraryBook e)
|
||||||
{
|
{
|
||||||
if (Liberation is not IProcessable processable)
|
if (FileLiberator is not IProcessable processable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
processable.Completed -= UnsubscribeProcessable;
|
processable.Completed -= UnsubscribeProcessable;
|
||||||
@ -109,7 +110,7 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
}
|
}
|
||||||
private void UnsubscribeAudioDecodable(object sender, EventArgs e)
|
private void UnsubscribeAudioDecodable(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Liberation is not IAudioDecodable audioDecodable)
|
if (FileLiberator is not IAudioDecodable audioDecodable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Disposed -= UnsubscribeAudioDecodable;
|
Disposed -= UnsubscribeAudioDecodable;
|
||||||
@ -135,10 +136,11 @@ namespace LibationWinForms.BookLiberation.BaseForms
|
|||||||
/// If StreamingBegin is fired from a worker thread, the window will be created on
|
/// If StreamingBegin is fired from a worker thread, the window will be created on
|
||||||
/// that UI thread. We need to make certain that we show the window on the same
|
/// that UI thread. We need to make certain that we show the window on the same
|
||||||
/// thread that created form, otherwise the form and the window handle will be on
|
/// thread that created form, otherwise the form and the window handle will be on
|
||||||
/// different threads. Form.BeginInvoke won't work until the form is created
|
/// different threads, and the renderer will be on a worker thread which could cause
|
||||||
/// (ie. shown) because control doesn't get a window handle until it is Shown.
|
/// it to freeze. Form.BeginInvoke won't work until the form is created (ie. shown)
|
||||||
|
/// because control doesn't get a window handle until it is Shown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ShowFormHandler(object sender, string beginString)
|
private void OnStreamingBeginShow(object sender, string beginString)
|
||||||
{
|
{
|
||||||
static void sendCallback(object asyncArgs)
|
static void sendCallback(object asyncArgs)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user