Initially working iconextrator code

This code now will cope with incorrectly
formatted icons, and will simply ignore
them and move on to the next one.

This also fixes a game ILV adaptor error
which was causing argumentnullexceptions
This commit is contained in:
Terry MacDonald 2021-05-18 21:24:36 +12:00
parent 8e46178bbe
commit 36c085d918
9 changed files with 173 additions and 1290 deletions

View File

@ -41,7 +41,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>true</UseVSHostingProcess> <UseVSHostingProcess>true</UseVSHostingProcess>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -280,9 +280,6 @@
<PackageReference Include="HtmlAgilityPack"> <PackageReference Include="HtmlAgilityPack">
<Version>1.11.33</Version> <Version>1.11.33</Version>
</PackageReference> </PackageReference>
<PackageReference Include="IconExtractor.dll">
<Version>1.0.2.1-beta</Version>
</PackageReference>
<PackageReference Include="IconLib.Unofficial"> <PackageReference Include="IconLib.Unofficial">
<Version>0.73.0</Version> <Version>0.73.0</Version>
</PackageReference> </PackageReference>
@ -319,6 +316,9 @@
<PackageReference Include="ValveKeyValue"> <PackageReference Include="ValveKeyValue">
<Version>0.3.1.152</Version> <Version>0.3.1.152</Version>
</PackageReference> </PackageReference>
<PackageReference Include="WinCopies.IconExtractor">
<Version>1.0.3-rc</Version>
</PackageReference>
<PackageReference Include="WindowsDisplayAPI"> <PackageReference Include="WindowsDisplayAPI">
<Version>1.3.0.13</Version> <Version>1.3.0.13</Version>
</PackageReference> </PackageReference>

View File

@ -21,6 +21,11 @@ namespace DisplayMagician
public static Image RoundCorners(Image StartImage, int CornerRadius) public static Image RoundCorners(Image StartImage, int CornerRadius)
{ {
if (StartImage == null)
{
throw new ArgumentNullException("StartImage");
}
CornerRadius *= 2; CornerRadius *= 2;
Bitmap RoundedImage = new Bitmap(StartImage.Width, StartImage.Height); Bitmap RoundedImage = new Bitmap(StartImage.Width, StartImage.Height);
using (Graphics g = Graphics.FromImage(RoundedImage)) using (Graphics g = Graphics.FromImage(RoundedImage))
@ -98,6 +103,11 @@ namespace DisplayMagician
public static Image MakeGrayscale(Image original) public static Image MakeGrayscale(Image original)
{ {
if (original == null)
{
throw new ArgumentNullException("original");
}
//create a blank bitmap the same size as original //create a blank bitmap the same size as original
Image newBitmap = new Bitmap(original.Width, original.Height); Image newBitmap = new Bitmap(original.Width, original.Height);
@ -132,101 +142,6 @@ namespace DisplayMagician
return newBitmap; return newBitmap;
} }
/* public static Bitmap ToLargeBitmap(string fileNameAndPath)
{
Bitmap bmToReturn = null;
try
{
if (String.IsNullOrWhiteSpace(fileNameAndPath))
{
logger.Warn($"ShortcutItem/ToLargeBitmap: Bitmap fileNameAndPath is empty! Unable to get the large icon from the file (256px x 256px).");
return null;
}
if (fileNameAndPath.EndsWith(".ico"))
{
logger.Trace($"ShortcutItem/ToLargeBitmap: The file we want to get the image from is an icon file. Attempting to extract the icon file from {fileNameAndPath}.");
Icon myIcon = new Icon(fileNameAndPath,128,128);
bmToReturn = myIcon.ToBitmap();
MultiIcon myMultiIcon = new MultiIcon();
SingleIcon mySingleIcon = myMultiIcon.Add("Icon1");
//mySingleIcon.CreateFrom(fileNameAndPath,IconOutputFormat.Vista);
mySingleIcon.Load(fileNameAndPath);
Bitmap bm = null;
foreach (IconImage myIconImage in mySingleIcon)
{
bm = myIconImage.Image;
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{
bmToReturn = bm;
logger.Trace($"ShortcutItem/ToLargeBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead.");
}
}
}
else
{
Icon myIcon = Icon.ExtractAssociatedIcon(fileNameAndPath);
bmToReturn = myIcon.ToBitmap();
logger.Trace($"ShortcutItem/ToLargeBitmap: The file {fileNameAndPath} isn't an Icon file, so trying to use GetLargeBitmapFromFile to extract the image.");
Bitmap bm = null;
bm = IconFromFile.GetLargeBitmapFromFile(fileNameAndPath, false, false);
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{
bmToReturn = bm;
logger.Trace($"ShortcutItem/ToLargeBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead.");
}
}
return bmToReturn;
}
catch (Exception ex)
{
logger.Warn(ex, $"ShortcutItem/ToLargeBitmap: Exception while trying to save the Shortcut icon initially. Trying again with GetLargeBitmapFromFile.");
try
{
logger.Trace($"ShortcutItem/ToLargeBitmap: Attempt2. The file {fileNameAndPath} isn't an Icon file, so trying to use GetLargeBitmapFromFile to extract the image.");
bmToReturn = IconFromFile.GetLargeBitmapFromFile(fileNameAndPath, true, false);
return bmToReturn;
}
catch (Exception innerex)
{
logger.Warn(innerex, $"ShortcutItem/ToLargeBitmap: Exception while trying to save the Shortcut icon a second time. Giving up.");
return null;
}
}
}
public static Bitmap ToLargeBitmap(ArrayList fileNamesAndPaths)
{
Bitmap bmToReturn = null;
if (fileNamesAndPaths.Count == 0)
{
logger.Warn($"ShortcutItem/ToLargeBitmap2: The fileNamesAndPaths list is empty! Can't get the large bitmap.");
return null;
}
foreach (string fileNameAndPath in fileNamesAndPaths)
{
Bitmap bm = ToLargeBitmap(fileNameAndPath);
if (bmToReturn == null)
{
bmToReturn = bm;
}
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{
bmToReturn = bm;
}
}
return bmToReturn;
}*/
public static Bitmap GetMeABitmapFromFile(string fileNameAndPath) public static Bitmap GetMeABitmapFromFile(string fileNameAndPath)
{ {
if (String.IsNullOrWhiteSpace(fileNameAndPath)) if (String.IsNullOrWhiteSpace(fileNameAndPath))
@ -238,14 +153,23 @@ namespace DisplayMagician
Icon myIcon = null; Icon myIcon = null;
Bitmap bm = null; Bitmap bm = null;
Bitmap bmToReturn = new Bitmap(1, 1); Bitmap bmToReturn = new Bitmap(1, 1);
try
{ try {
List<Icon> myExtractedIcons = MintPlayer.IconUtils.IconExtractor.Split(fileNameAndPath); List<Icon> myExtractedIcons = MintPlayer.IconUtils.IconExtractor.Split(fileNameAndPath);
Size largeSize = new Size(256, 256);
foreach (Icon myExtractedIcon in myExtractedIcons) foreach (Icon myExtractedIcon in myExtractedIcons)
{ {
Size largeSize = new Size(256, 256);
myIcon = myExtractedIcon.TryGetIcon(largeSize, 32, true, true); 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) if (myIcon != null)
{ {
@ -254,22 +178,25 @@ namespace DisplayMagician
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height) if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{ {
bmToReturn = bm; bmToReturn = bm;
logger.Trace($"ShortcutItem/ToSmallBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead."); 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) catch (Exception ex)
{ {
logger.Warn(ex, $"ShortcutItem/GetMeABitmapFromFile: Exception while trying to Split the icon using MintPlayer IconExtractor! "); logger.Warn(ex, $"ShortcutItem/GetMeABitmapFromFile: Exception while trying to Split the icon using MintPlayer IconExtractor! ");
} }
if (fileNameAndPath.EndsWith(".ico")) if (fileNameAndPath.EndsWith(".ico"))
{ {
try try
{ {
logger.Trace($"ShortcutItem/ToSmallBitmap: The file we want to get the image from is an icon file. Attempting to extract the icon file from {fileNameAndPath}."); logger.Trace($"ShortcutItem/GetMeABitmapFromFile: The file we want to get the image from is an icon file. Attempting to extract the icon file from {fileNameAndPath}.");
myIcon = new Icon(fileNameAndPath, 256, 256); myIcon = new Icon(fileNameAndPath, 256, 256);
@ -283,7 +210,7 @@ namespace DisplayMagician
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height) if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{ {
bmToReturn = bm; bmToReturn = bm;
logger.Trace($"ShortcutItem/ToSmallBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead."); 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) catch (Exception ex)
@ -305,7 +232,7 @@ namespace DisplayMagician
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height) if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{ {
bmToReturn = bm; bmToReturn = bm;
logger.Trace($"ShortcutItem/ToSmallBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead."); 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.");
} }
} }
} }
@ -316,6 +243,7 @@ namespace DisplayMagician
} }
else else
{ {
try try
{ {
List<Icon> myIcons = ImageUtils.ExtractIconsFromExe(fileNameAndPath, true); List<Icon> myIcons = ImageUtils.ExtractIconsFromExe(fileNameAndPath, true);
@ -328,7 +256,7 @@ namespace DisplayMagician
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height) if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{ {
bmToReturn = bm; bmToReturn = bm;
logger.Trace($"ShortcutItem/ToSmallBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead."); 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.");
} }
} }
} }
@ -349,7 +277,7 @@ namespace DisplayMagician
if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height) if (bm.Width > bmToReturn.Width && bm.Height > bmToReturn.Height)
{ {
bmToReturn = bm; bmToReturn = bm;
logger.Trace($"ShortcutItem/ToSmallBitmap: This new bitmap from the icon file {fileNameAndPath} is larger than the previous one at {bm.Width} x {bm.Height}, so using that instead."); 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.");
} }
} }
} }
@ -386,7 +314,7 @@ namespace DisplayMagician
if (fileNamesAndPaths.Count == 0) if (fileNamesAndPaths.Count == 0)
{ {
logger.Warn($"ShortcutItem/ToSmallBitmap2: The fileNamesAndPaths list is empty! Can't get the large bitmap."); logger.Warn($"ShortcutItem/GetMeABitmapFromFile2: The fileNamesAndPaths list is empty! Can't get the bitmap from the files.");
return null; return null;
} }
foreach (string fileNameAndPath in fileNamesAndPaths) foreach (string fileNameAndPath in fileNamesAndPaths)
@ -540,14 +468,12 @@ namespace DisplayMagician
} }
[DllImport("Shell32", CharSet = CharSet.Auto)] [DllImport("Shell32", CharSet = CharSet.Auto)]
private static unsafe extern int ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phIconLarge, IntPtr[] phIconSmall, int nIcons); private static extern int ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phIconLarge, IntPtr[] phIconSmall, int nIcons);
[DllImport("user32.dll", EntryPoint = "DestroyIcon", SetLastError = true)] [DllImport("user32.dll", EntryPoint = "DestroyIcon", SetLastError = true)]
private static unsafe extern int DestroyIcon(IntPtr hIcon); private static extern int DestroyIcon(IntPtr hIcon);
public static List<Icon> ExtractIconsFromExe(string file, bool large) public static List<Icon> ExtractIconsFromExe(string file, bool large)
{
unsafe
{ {
int readIconCount = 0; int readIconCount = 0;
IntPtr[] hLargeIconEx = new IntPtr[] { IntPtr.Zero }; IntPtr[] hLargeIconEx = new IntPtr[] { IntPtr.Zero };
@ -585,10 +511,17 @@ namespace DisplayMagician
Icon extractedIcon = (Icon)Icon.FromHandle(hSmallIconEx[0]).Clone(); Icon extractedIcon = (Icon)Icon.FromHandle(hSmallIconEx[0]).Clone();
extractedIcons.Add(extractedIcon); extractedIcons.Add(extractedIcon);
} }
// GET FIRST EXTRACTED ICON
return extractedIcons;
} }
} }
/*foreach (IntPtr ptr in hLargeIconEx)
if (ptr != IntPtr.Zero)
DestroyIcon(ptr);
foreach (IntPtr ptr in hSmallIconEx)
if (ptr != IntPtr.Zero)
DestroyIcon(ptr);*/
return extractedIcons; return extractedIcons;
} }
else else
@ -613,7 +546,7 @@ namespace DisplayMagician
if (ptr != IntPtr.Zero) if (ptr != IntPtr.Zero)
DestroyIcon(ptr); DestroyIcon(ptr);
} }
}
} }
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
@ -647,7 +580,7 @@ namespace DisplayMagician
/// <param name="size">Size of the icon to load. If there is no such size available, a larger or smaller /// <param name="size">Size of the icon to load. If there is no such size available, a larger or smaller
/// sized-icon is scaled.</param> /// sized-icon is scaled.</param>
/// <returns>List of all icons.</returns> /// <returns>List of all icons.</returns>
public static Icon GetIconFromExe(string path = null, string resId = "#32512", int size = 32) public static Icon GetIconFromExe(string path = null, int size = 256, string resId = "#32512")
{ {
// load module // load module
IntPtr h; IntPtr h;

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,9 @@ namespace DisplayMagician.UIForms
Game game = (Game)key; Game game = (Game)key;
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; }); Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
return game.GameBitmap.GetThumbnailImage(256, 256, myCallback, IntPtr.Zero); return game.GameBitmap.GetThumbnailImage(256, 256, myCallback, IntPtr.Zero);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -99,8 +101,8 @@ namespace DisplayMagician.UIForms
try try
{ {
string gameName = (string)key; Game game = (Game)key;
return gameName; return game.Name;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -126,10 +128,10 @@ namespace DisplayMagician.UIForms
try try
{ {
ShortcutItem shortcut = (ShortcutItem)key; Game game = (Game)key;
// Get file info // Get file info
if (shortcut.ShortcutBitmap is Bitmap) if (game.GameBitmap is Bitmap)
{ {
// Have to do some gymnastics to get rid of the // Have to do some gymnastics to get rid of the
// System.Drawing.Image exception created while accessing the Size // System.Drawing.Image exception created while accessing the Size
@ -139,13 +141,13 @@ namespace DisplayMagician.UIForms
{ {
try try
{ {
mySize = shortcut.ShortcutBitmap.Size; mySize = game.GameBitmap.Size;
gotSize = true; gotSize = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
// catch the System.Drawing.Image exception created while accessing the Size // catch the System.Drawing.Image exception created while accessing the Size
logger.Warn(ex, "ShortcutAdaptor/GetDetails: System.Drawing.Image exception caused while trying to get the ProfileBitmap Size as an Integer."); logger.Warn(ex, "GameAdapter/GetDetails: System.Drawing.Image exception caused while trying to get the GameBitmap Size as an Integer.");
} }
} }
@ -157,26 +159,28 @@ namespace DisplayMagician.UIForms
{ {
try try
{ {
mySizeF = shortcut.ShortcutBitmap.PhysicalDimension; mySizeF = game.GameBitmap.PhysicalDimension;
gotSizeF = true; gotSizeF = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
// catch the System.Drawing.Image exception created while accessing the Size // catch the System.Drawing.Image exception created while accessing the Size
logger.Warn(ex, "ShortcutAdaptor/GetDetails: System.Drawing.Image exception caused while trying to get the ProfileBitmap Size as a Float."); logger.Warn(ex, "GameAdapter/GetDetails: System.Drawing.Image exception caused while trying to get the GameBitmap Size as a Float.");
} }
} }
string name = shortcut.Name; string name = game.Name;
string filepath = Path.GetDirectoryName(shortcut.SavedShortcutIconCacheFilename); //string filepath = Path.GetDirectoryName(shortcut.SavedShortcutIconCacheFilename);
string filename = Path.GetFileName(shortcut.SavedShortcutIconCacheFilename); //string filename = Path.GetFileName(shortcut.SavedShortcutIconCacheFilename);
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, now)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateCreated, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, now)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, now)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.DateModified, string.Empty, now));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, (long)0)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FileSize, string.Empty, (long)0));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, filepath ?? "")); //details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, filepath ?? ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FolderName, string.Empty, filepath ?? "")); //details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FolderName, string.Empty, filepath ?? ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FilePath, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.FolderName, string.Empty, ""));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Dimensions, string.Empty, mySize)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Dimensions, string.Empty, mySize));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Resolution, string.Empty, mySizeF)); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.Resolution, string.Empty, mySizeF));
details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ImageDescription, string.Empty, name ?? "")); details.Add(new Utility.Tuple<ColumnType, string, object>(ColumnType.ImageDescription, string.Empty, name ?? ""));
@ -197,7 +201,7 @@ namespace DisplayMagician.UIForms
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.Warn(ex, "ShortcutAdapter/Utility.Tuple: Exception caused while trying to add details to the Game ImageListViewItem."); logger.Warn(ex, "GameAdapter/Utility.Tuple: Exception caused while trying to add details to the Game ImageListViewItem.");
// If we have a problem with converting the submitted key to a profile // If we have a problem with converting the submitted key to a profile
// Then we return null // Then we return null
return null; return null;

View File

@ -421,7 +421,6 @@ namespace DisplayMagician.UIForms
} }
} }
// Draw the image
Image img = ImageUtils.RoundCorners(item.GetCachedImage(CachedImageType.Thumbnail), 20); Image img = ImageUtils.RoundCorners(item.GetCachedImage(CachedImageType.Thumbnail), 20);
if (img != null) if (img != null)
{ {

View File

@ -121,8 +121,8 @@ namespace DisplayMagician.UIForms
try try
{ {
string profileName = (string)key; ProfileItem profile = (ProfileItem)key;
return profileName; return profile.Name;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -49,7 +49,7 @@ namespace DisplayMagician.UIForms
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"ShortcutAdapter/GetThumbnail exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Warn(ex, $"ShortcutAdapter/GetThumbnail exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile // If we have a problem with converting the submitted key to a profile
// Then we return null // Then we return null
@ -81,7 +81,7 @@ namespace DisplayMagician.UIForms
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"ShortcutAdapter/GetUniqueIdentifier exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Warn(ex, $"ShortcutAdapter/GetUniqueIdentifier exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// If we have a problem with converting the submitted key to a Shortcut // If we have a problem with converting the submitted key to a Shortcut
// Then we return null // Then we return null
return null; return null;
@ -100,12 +100,12 @@ namespace DisplayMagician.UIForms
try try
{ {
string shortcutName = (string)key; ShortcutItem shortcut = (ShortcutItem)key;
return shortcutName; return shortcut.Name;
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"ShortcutAdaptor/GetSourceImage exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Warn(ex, $"ShortcutAdaptor/GetSourceImage exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile // If we have a problem with converting the submitted key to a profile
// Then we return null // Then we return null
@ -198,7 +198,7 @@ namespace DisplayMagician.UIForms
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"ShortcutAdapter/Utility.Tuple exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Warn(ex, $"ShortcutAdapter/Utility.Tuple exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile // If we have a problem with converting the submitted key to a profile
// Then we return null // Then we return null
return null; return null;

View File

@ -205,7 +205,7 @@ namespace DisplayMagician.UIForms
this.tabc_shortcut.ShowToolTips = true; this.tabc_shortcut.ShowToolTips = true;
this.tabc_shortcut.Size = new System.Drawing.Size(1090, 654); this.tabc_shortcut.Size = new System.Drawing.Size(1090, 654);
this.tabc_shortcut.TabIndex = 28; this.tabc_shortcut.TabIndex = 28;
this.tabc_shortcut.VisibleChanged += new System.EventHandler(this.tabc_shortcut_VisibleChanged); //this.tabc_shortcut.VisibleChanged += new System.EventHandler(this.tabc_shortcut_VisibleChanged);
// //
// tabp_display // tabp_display
// //

View File

@ -1071,7 +1071,7 @@ namespace DisplayMagician.UIForms
cb_args_game.Checked = true; cb_args_game.Checked = true;
} }
//select the loaded Game item if it is there //select the loaded Game item if it is there
foreach (ImageListViewItem gameItem in ilv_games.Items) /*foreach (ImageListViewItem gameItem in ilv_games.Items)
{ {
if (gameItem.Text.Equals(_shortcutToEdit.GameName)) if (gameItem.Text.Equals(_shortcutToEdit.GameName))
{ {
@ -1080,7 +1080,7 @@ namespace DisplayMagician.UIForms
break; break;
} }
} }
} */ }
cb_autosuggest.Checked = _shortcutToEdit.AutoName; cb_autosuggest.Checked = _shortcutToEdit.AutoName;
@ -2199,11 +2199,11 @@ namespace DisplayMagician.UIForms
EnableSaveButtonIfValid(); EnableSaveButtonIfValid();
} }
private void tabc_shortcut_VisibleChanged(object sender, EventArgs e) /*private void tabc_shortcut_VisibleChanged(object sender, EventArgs e)
{ {
if (tabc_shortcut.Visible == true) if (tabc_shortcut.Visible == true)
SelectGameInImageListView(); SelectGameInImageListView();
} }*/
/*private void ilv_games_VisibleChanged(object sender, EventArgs e) /*private void ilv_games_VisibleChanged(object sender, EventArgs e)
{ {