This commit is contained in:
Michael Bucari-Tovo 2022-07-23 20:54:02 -06:00
parent 1e4c489983
commit 8dd59cb08a
147 changed files with 259 additions and 269 deletions

View file

@ -0,0 +1,44 @@
using ApplicationServices;
using System;
using System.Linq;
using Avalonia.Threading;
using Dinah.Core;
namespace LibationAvalonia.Views
{
//DONE
public partial class MainWindow
{
private System.ComponentModel.BackgroundWorker updateCountsBw = new();
private void Configure_BackupCounts()
{
Load += setBackupCounts;
LibraryCommands.LibrarySizeChanged += setBackupCounts;
LibraryCommands.BookUserDefinedItemCommitted += setBackupCounts;
updateCountsBw.DoWork += UpdateCountsBw_DoWork;
updateCountsBw.RunWorkerCompleted += updateBottomNumbersAsync;
}
private bool runBackupCountsAgain;
private void setBackupCounts(object _, object __)
{
runBackupCountsAgain = true;
if (!updateCountsBw.IsBusy)
updateCountsBw.RunWorkerAsync();
}
private void UpdateCountsBw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
while (runBackupCountsAgain)
{
runBackupCountsAgain = false;
e.Result = LibraryCommands.GetCounts();
}
}
private void updateBottomNumbersAsync(object _, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
_viewModel.LibraryStats = e.Result as LibraryCommands.LibraryStats;
}
}
}