mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Working Game selection window
Also correctly extracts icons from icon files and game exes as best it can.
This commit is contained in:
parent
36c085d918
commit
5b99c3ac7a
@ -152,43 +152,7 @@ namespace DisplayMagician
|
||||
|
||||
Icon myIcon = null;
|
||||
Bitmap bm = null;
|
||||
Bitmap bmToReturn = new Bitmap(1, 1);
|
||||
|
||||
try {
|
||||
|
||||
List<Icon> myExtractedIcons = MintPlayer.IconUtils.IconExtractor.Split(fileNameAndPath);
|
||||
Size largeSize = new Size(256, 256);
|
||||
foreach (Icon myExtractedIcon in myExtractedIcons)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
myIcon = (Icon)IconUtil.TryGetIcon(myExtractedIcon, largeSize, 32, true, true);
|
||||
}
|
||||
catch (ArgumentNullException nullex)
|
||||
{
|
||||
logger.Debug(nullex, $"ShortcutItem/GetMeABitmapFromFile: There was a faulty icon image within this icon that we couldn't test, so skipping it.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (myIcon != null)
|
||||
{
|
||||
bm = myIcon.ToBitmap();
|
||||
|
||||
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
|
||||
{
|
||||
bmToReturn = bm;
|
||||
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"ShortcutItem/GetMeABitmapFromFile: Exception while trying to Split the icon using MintPlayer IconExtractor! ");
|
||||
}
|
||||
|
||||
Bitmap bmToReturn = new Bitmap(1, 1);
|
||||
|
||||
if (fileNameAndPath.EndsWith(".ico"))
|
||||
{
|
||||
@ -244,7 +208,7 @@ namespace DisplayMagician
|
||||
else
|
||||
{
|
||||
|
||||
try
|
||||
/*try
|
||||
{
|
||||
List<Icon> myIcons = ImageUtils.ExtractIconsFromExe(fileNameAndPath, true);
|
||||
if (myIcons != null && myIcons.Count > 0)
|
||||
@ -264,7 +228,7 @@ namespace DisplayMagician
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"ShortcutItem/GetMeABitmapFromFile: Exception while trying to extract the icon from an *.exe or *.dll using ImageUtils.ExtractIconsFromExe.");
|
||||
}
|
||||
}*/
|
||||
|
||||
try
|
||||
{
|
||||
@ -288,6 +252,43 @@ namespace DisplayMagician
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
List<Icon> myExtractedIcons = MintPlayer.IconUtils.IconExtractor.Split(fileNameAndPath);
|
||||
Size largeSize = new Size(256, 256);
|
||||
foreach (Icon myExtractedIcon in myExtractedIcons)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
myIcon = (Icon)IconUtil.TryGetIcon(myExtractedIcon, largeSize, 32, true, true);
|
||||
}
|
||||
catch (ArgumentNullException nullex)
|
||||
{
|
||||
logger.Debug(nullex, $"ShortcutItem/GetMeABitmapFromFile: There was a faulty icon image within this icon that we couldn't test, so skipping it.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (myIcon != null)
|
||||
{
|
||||
bm = myIcon.ToBitmap();
|
||||
|
||||
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
|
||||
{
|
||||
bmToReturn = bm;
|
||||
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"ShortcutItem/GetMeABitmapFromFile: Exception while trying to Split the icon using MintPlayer IconExtractor! ");
|
||||
}
|
||||
|
||||
|
||||
if (bmToReturn == null)
|
||||
{
|
||||
// If we couldn't get any bitmaps at all
|
||||
|
@ -881,16 +881,17 @@ namespace DisplayMagician {
|
||||
Bitmap bm = null;
|
||||
try
|
||||
{
|
||||
ArrayList filesToSearchForIcon = new ArrayList();
|
||||
/*ArrayList filesToSearchForIcon = new ArrayList();
|
||||
filesToSearchForIcon.Add(game.ExePath);
|
||||
if (game.IconPath != game.ExePath)
|
||||
filesToSearchForIcon.Add(game.IconPath);
|
||||
|
||||
bm = ImageUtils.GetMeABitmapFromFile(filesToSearchForIcon);
|
||||
|
||||
|
||||
//bm = ImageUtils.GetMeABitmapFromFile(game.IconPath);
|
||||
bm = ImageUtils.GetMeABitmapFromFile(filesToSearchForIcon);*/
|
||||
|
||||
// We only want the icon location that the GameLibrary told us to use
|
||||
// Note: This may be an icon file, or an exe file.
|
||||
// This function tries to get a 256x256 Vista sized bitmap from the file
|
||||
bm = ImageUtils.GetMeABitmapFromFile(game.IconPath);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
2
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
2
DisplayMagician/UIForms/ShortcutForm.Designer.cs
generated
@ -205,7 +205,7 @@ namespace DisplayMagician.UIForms
|
||||
this.tabc_shortcut.ShowToolTips = true;
|
||||
this.tabc_shortcut.Size = new System.Drawing.Size(1090, 654);
|
||||
this.tabc_shortcut.TabIndex = 28;
|
||||
//this.tabc_shortcut.VisibleChanged += new System.EventHandler(this.tabc_shortcut_VisibleChanged);
|
||||
this.tabc_shortcut.Click += new System.EventHandler(this.tabc_shortcut_VisibleChanged);
|
||||
//
|
||||
// tabp_display
|
||||
//
|
||||
|
@ -702,7 +702,7 @@ namespace DisplayMagician.UIForms
|
||||
itemToSelect.Focused = true;
|
||||
itemToSelect.Enabled = true;
|
||||
ilv_games.EnsureVisible(itemToSelect.Index);
|
||||
ilv_games.Refresh();
|
||||
//ilv_games.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@ -931,8 +931,6 @@ namespace DisplayMagician.UIForms
|
||||
ilv_games.Items.Add(newItem, _gameAdaptor);
|
||||
}
|
||||
|
||||
SelectGameInImageListView();
|
||||
|
||||
if (_shortcutToEdit != null)
|
||||
{
|
||||
if (ProfileRepository.ContainsProfile(_shortcutToEdit.ProfileUUID))
|
||||
@ -1070,17 +1068,7 @@ namespace DisplayMagician.UIForms
|
||||
{
|
||||
cb_args_game.Checked = true;
|
||||
}
|
||||
//select the loaded Game item if it is there
|
||||
/*foreach (ImageListViewItem gameItem in ilv_games.Items)
|
||||
{
|
||||
if (gameItem.Text.Equals(_shortcutToEdit.GameName))
|
||||
{
|
||||
gameItem.Selected = true;
|
||||
ilv_games.EnsureVisible(gameItem.Index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/ }
|
||||
}
|
||||
|
||||
cb_autosuggest.Checked = _shortcutToEdit.AutoName;
|
||||
|
||||
@ -1375,44 +1363,6 @@ namespace DisplayMagician.UIForms
|
||||
ilv_saved_profiles.ResumeLayout();
|
||||
}
|
||||
|
||||
/*if (DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.Count > 0)
|
||||
{
|
||||
|
||||
// Temporarily stop updating the saved_profiles listview
|
||||
ilv_games.SuspendLayout();
|
||||
|
||||
ImageListViewItem ilvItem = null;
|
||||
foreach (Game loadedGame in DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries)
|
||||
{
|
||||
bool thisLoadedProfileIsAlreadyHere = (from item in ilv_games.Items where item.Text == loadedGame.Name orderby item.Text select item.Text).Any();
|
||||
if (!thisLoadedProfileIsAlreadyHere)
|
||||
{
|
||||
ilvItem = new ImageListViewItem(loadedGame, loadedGame.Name);
|
||||
//ilv_saved_profiles.Items.Add(newItem);
|
||||
ilv_games.Items.Add(ilvItem, _gameAdaptor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If a game has been selected
|
||||
if (!String.IsNullOrEmpty(_shortcutToEdit.GameName))
|
||||
{
|
||||
foreach (ImageListViewItem gameItem in ilv_games.Items)
|
||||
{
|
||||
if (gameItem.Text == _shortcutToEdit.GameName)
|
||||
{
|
||||
gameItem.Selected = true;
|
||||
ilv_games.EnsureVisible(gameItem.Index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Restart updating the saved_profiles listview
|
||||
ilv_games.ResumeLayout();
|
||||
}
|
||||
*/
|
||||
UpdateHotkeyLabel(_shortcutToEdit.Hotkey);
|
||||
EnableSaveButtonIfValid();
|
||||
}
|
||||
@ -2199,16 +2149,10 @@ namespace DisplayMagician.UIForms
|
||||
EnableSaveButtonIfValid();
|
||||
}
|
||||
|
||||
/*private void tabc_shortcut_VisibleChanged(object sender, EventArgs e)
|
||||
private void tabc_shortcut_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (tabc_shortcut.Visible == true)
|
||||
SelectGameInImageListView();
|
||||
}*/
|
||||
|
||||
/*private void ilv_games_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ilv_games.SelectedItems.Count > 0)
|
||||
ilv_games.EnsureVisible(ilv_games.SelectedItems[0].Index);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user