Refactor Classic process queue

The queue is now more MVVM-like.
This commit is contained in:
MBucari
2025-07-16 22:58:03 -06:00
parent 7e79e98771
commit 747451d243
5 changed files with 108 additions and 211 deletions

View File

@@ -22,6 +22,49 @@ namespace LibationWinForms.ProcessQueue
public static Color QueuedColor = SystemColors.Control;
public static Color SuccessColor = Color.PaleGreen;
private ProcessBookViewModelBase m_Context;
public ProcessBookViewModelBase Context
{
get => m_Context;
set
{
if (m_Context != value)
{
OnContextChanging();
m_Context = value;
OnContextChanged();
}
}
}
private void OnContextChanging()
{
if (Context is not null)
Context.PropertyChanged -= Context_PropertyChanged;
}
private void OnContextChanged()
{
Context.PropertyChanged += Context_PropertyChanged;
Context_PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(null));
}
private void Context_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
SuspendLayout();
if (e.PropertyName is null or nameof(Context.Cover))
SetCover(Context.Cover as Image);
if (e.PropertyName is null or nameof(Context.Title) or nameof(Context.Author) or nameof(Context.Narrator))
SetBookInfo($"{Context.Title}\r\nBy {Context.Author}\r\nNarrated by {Context.Narrator}");
if (e.PropertyName is null or nameof(Context.Status) or nameof(Context.StatusText))
SetStatus(Context.Status, Context.StatusText);
if (e.PropertyName is null or nameof(Context.Progress))
SetProgress(Context.Progress);
if (e.PropertyName is null or nameof(Context.TimeRemaining))
SetRemainingTime(Context.TimeRemaining);
ResumeLayout();
}
public ProcessBookControl()
{
InitializeComponent();