private void OnSelectedTabChanged(TabChangedDetails obj)
{
if(obj.To is LibraryView)
{
Application.Idle -= ManageButtonsAtIdleTime;
Application.Idle += ManageButtonsAtIdleTime;
Book.Book book = SelectedBook;
if (book != null && SelectedButton != null)
{
var bestTitle = book.TitleBestForUserDisplay;
SelectedButton.Text = ShortenTitleIfNeeded(bestTitle, SelectedButton);
toolTip1.SetToolTip(SelectedButton, bestTitle);
if (_thumbnailRefreshPending)
{
_thumbnailRefreshPending = false;
ScheduleRefreshOfOneThumbnail(book);
}
}
if (_primaryCollectionReloadPending)
{
LoadPrimaryCollectionButtons();
// One reason to reload is that we created a new book. We need to go through the steps of selecting it
// so that e.g. its menu options are properly configured.
if (SelectedBook != null)
{
SelectBook(SelectedBook.BookInfo);
ScheduleRefreshOfOneThumbnail(book);
}
}
}
else
{
Application.Idle -= ManageButtonsAtIdleTime;
}
}