Fixed small bug with game imagelistview selection.

The game imagelistview wasn't showing the correct selected item when loading an existing shortcut into the shortcutform after creating a new shortcut. This is now fixed and displays correctly.
This commit is contained in:
Terry MacDonald 2021-11-20 09:33:25 +13:00
parent 9c82352411
commit d7db9d6007
2 changed files with 15 additions and 8 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.1.1.255")]
[assembly: AssemblyFileVersion("2.1.1.255")]
[assembly: AssemblyVersion("2.1.0.263")]
[assembly: AssemblyFileVersion("2.1.0.263")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -1221,6 +1221,7 @@ namespace DisplayMagician.UIForms
// Load all the Games into the Games ListView
ilv_games.ClearSelection();
foreach (var game in DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.OrderBy(game => game.Name))
{
// Add the game to the game array
@ -1234,7 +1235,7 @@ namespace DisplayMagician.UIForms
}
if (_shortcutToEdit.Category == ShortcutCategory.Game && _shortcutToEdit.GameAppId != null)
if (_editingExistingShortcut && _shortcutToEdit.Category == ShortcutCategory.Game && _shortcutToEdit.GameAppId != null)
{
bool gameStillInstalled = false;
foreach (ImageListViewItem gameItem in ilv_games.Items)
@ -1242,6 +1243,7 @@ namespace DisplayMagician.UIForms
if (gameItem.Text.Equals(_shortcutToEdit.GameName))
{
gameStillInstalled = true;
gameItem.Selected = true;
break;
}
@ -1957,11 +1959,7 @@ namespace DisplayMagician.UIForms
bool thisLoadedProfileIsAlreadyHere = (from item in ilv_saved_profiles.Items where item.Text == loadedProfile.Name orderby item.Text select item.Text).Any();
if (!thisLoadedProfileIsAlreadyHere)
{
//loadedProfile.SaveProfileImageToCache();
//newItem = new ImageListViewItem(loadedProfile.SavedProfileCacheFilename, loadedProfile.Name);
//newItem = new ImageListViewItem(loadedProfile, loadedProfile.Name);
newItem = new ImageListViewItem(loadedProfile, loadedProfile.Name);
//ilv_saved_profiles.Items.Add(newItem);
ilv_saved_profiles.Items.Add(newItem, _profileAdaptor);
}
@ -2902,12 +2900,21 @@ namespace DisplayMagician.UIForms
// Parse the libraries
GameLibraries.GameLibrary.RefreshGameBitmaps();
// Load all the Games into the Games ListView
ImageListViewItem previouslySelectedItem = null;
if (ilv_games.SelectedItems.Count > 0)
{
previouslySelectedItem = ilv_games.SelectedItems[0];
}
ilv_games.Items.Clear();
foreach (var game in DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.OrderBy(game => game.Name))
{
// Add the game to the game array
ImageListViewItem newItem = new ImageListViewItem(game, game.Name);
if (_editingExistingShortcut && game.Name.Equals(_shortcutToEdit.GameName))
if (previouslySelectedItem != null && newItem.Text.Equals(previouslySelectedItem.Text))
{
newItem.Selected = true;
}
else if (_editingExistingShortcut && game.Name.Equals(_shortcutToEdit.GameName))
{
newItem.Selected = true;
}