Try to get the game list showing on load in Application mode

The shortcutform has an issue showing the games list icons in Application mode. It works so well in Games mode, but Application mode starts blank.
This commit is contained in:
Terry MacDonald 2021-12-24 23:30:33 +13:00
parent 7ea6383b38
commit 250898ad8f
2 changed files with 56 additions and 32 deletions

View File

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

View File

@ -982,16 +982,7 @@ namespace DisplayMagician.UIForms
// Restart updating the saved_profiles listview
ilv_saved_profiles.ResumeLayout();
}
// Populate all the Games into the Games ListView
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);
//ilv_saved_profiles.Items.Add(newItem);
ilv_games.Items.Add(newItem, _gameAdaptor);
}
// Populate all the audio devices in the audio devices select box
if (audioController != null)
@ -1130,7 +1121,8 @@ namespace DisplayMagician.UIForms
}
// Select the DisplayProfile tab
tabc_shortcut.SelectedTab = tabp_display;
//tabc_shortcut.SelectedTab = tabp_display;
tabc_shortcut.SelectedTab = tabp_game;
}
private void LoadShortcut()
@ -1155,6 +1147,27 @@ namespace DisplayMagician.UIForms
// Track the shortcut UUID
_uuid = _shortcutToEdit.UUID;
// Populate all the Games into the Games ListView
ilv_games.Enabled = true;
ilv_games.Visible = true;
ilv_games.SuspendLayout();
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);
ilv_games.Items.Add(newItem, _gameAdaptor);
newItem.Update();
}
// Make sure that if the item is selected that it's visible
if (ilv_games.SelectedItems.Count > 0)
{
int selectedIndex = ilv_games.SelectedItems[0].Index;
ilv_games.EnsureVisible(selectedIndex);
}
ilv_games.Update();
ilv_games.ResumeLayout();
// =============================================
// IF THE SHORTCUT IS AN EXISTING SHORTCUT
// =============================================
@ -1437,12 +1450,16 @@ namespace DisplayMagician.UIForms
// =============================================
if (_shortcutToEdit.Category == ShortcutCategory.Application)
{
// If we have a selected image, then we need to set it
if (_shortcutToEdit.SelectedImage.Image != null)
// Check that the executable to run still exists
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.ExecutableNameAndPath) && !File.Exists(_shortcutToEdit.ExecutableNameAndPath))
{
_selectedImage = _shortcutToEdit.SelectedImage;
pb_exe_icon.Image = _shortcutToEdit.SelectedImage.Image;
btn_choose_exe_icon.Enabled = true;
MessageBox.Show(
$"The '{_shortcutToEdit.ExecutableNameAndPath}' application used by this Shortcut no longer exists. Your shortcut won't work unless you reinstall the missing application or choose a different one.",
@"Application doesn't exist",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
// If we don't have any available images, then we need to get some
@ -1479,7 +1496,7 @@ namespace DisplayMagician.UIForms
{
// We've found the original image!
_selectedImage = sc;
pb_game_icon.Image = _selectedImage.Image;
pb_exe_icon.Image = _selectedImage.Image;
matchedImage = true;
}
}
@ -1488,7 +1505,7 @@ namespace DisplayMagician.UIForms
if (!matchedImage)
{
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
pb_game_icon.Image = _selectedImage.Image;
pb_exe_icon.Image = _selectedImage.Image;
}
if (_shortcutToEdit.OriginalLargeBitmap != null)
@ -1497,6 +1514,15 @@ namespace DisplayMagician.UIForms
}
}
// If we have a selected image, then we need to set it
if (_shortcutToEdit.SelectedImage.Image != null)
{
_selectedImage = _shortcutToEdit.SelectedImage;
pb_exe_icon.Image = _shortcutToEdit.SelectedImage.Image;
btn_choose_exe_icon.Enabled = true;
}
// Set the executable items if we have them
txt_executable.Text = _shortcutToEdit.ExecutableNameAndPath;
nud_timeout_executable.Value = _shortcutToEdit.StartTimeout;
@ -1580,9 +1606,7 @@ namespace DisplayMagician.UIForms
}
if (!gameStillInstalled)
{
// Close the splash screen
CloseTheSplashScreen();
{
DialogResult result = MessageBox.Show(
$"This shortcut refers to the '{_shortcutToEdit.GameName}' game that was installed in your {_shortcutToEdit.GameLibrary.ToString("G")} library. This game is no longer installed, so the shortcut won't work. You either need to change the game used in the Shortcut to another installed game, or you need to install the game files on your computer again.",
@"Game no longer exists",
@ -1606,15 +1630,6 @@ namespace DisplayMagician.UIForms
cb_wait_alternative_game.Checked = false;
}
// If we have a selected image, then we need to set it
if (_shortcutToEdit.SelectedImage.Image != null)
{
// Set up the selected Game Image
_selectedImage = _shortcutToEdit.SelectedImage;
pb_game_icon.Image = _shortcutToEdit.SelectedImage.Image;
btn_choose_game_icon.Enabled = true;
}
// If we don't have any available images, then we need to get some
if (_shortcutToEdit.AvailableImages.Count > 0)
{
@ -1711,6 +1726,15 @@ namespace DisplayMagician.UIForms
}
}
// If we have a selected image, then we need to set it
if (_shortcutToEdit.SelectedImage.Image != null)
{
// Set up the selected Game Image
_selectedImage = _shortcutToEdit.SelectedImage;
pb_game_icon.Image = _shortcutToEdit.SelectedImage.Image;
btn_choose_game_icon.Enabled = true;
}
}
// ==================================================
// IF THE EXISTING SHORTCUT IS NO GAME OR APPLICATION