Fixes and changes for issue #142

This commit is contained in:
Michael J. Seiferling
2018-07-30 08:44:39 -06:00
parent 72e3ccb661
commit daa5f928bf
3 changed files with 39 additions and 12 deletions
+27 -12
View File
@@ -577,12 +577,34 @@ Public Class frmMain
End If
End Sub
Private Sub SetGameIcon()
Dim ic As Icon
Dim sIconFile As String
Dim oBitmap As Bitmap
Try
'Grab icon from the executable
ic = System.Drawing.Icon.ExtractAssociatedIcon(oProcess.FoundProcess.MainModule.FileName)
'Save a copy
sIconFile = mgrPath.SettingsRoot & Path.DirectorySeparatorChar & oProcess.GameInfo.ID & ".ico"
ic.ToBitmap.Save(sIconFile, System.Drawing.Imaging.ImageFormat.Icon)
ic.Dispose()
'Set the icon, we need to use an intermediary object to prevent file locking
oBitmap = New Bitmap(sIconFile)
pbIcon.Image = New Bitmap(oBitmap)
oBitmap.Dispose()
Catch ex As Exception
UpdateLog(mgrCommon.FormatString(frmMain_ErrorGameIcon), False, ToolTipIcon.Error)
UpdateLog(mgrCommon.FormatString(App_GenericError, ex.Message), False,, False)
End Try
End Sub
Private Sub SetGameInfo(Optional ByVal bMulti As Boolean = False)
Dim sFileName As String = String.Empty
Dim sFileVersion As String = String.Empty
Dim sCompanyName As String = String.Empty
Dim ic As Icon
Dim sIconFile As String
'Wipe Game Info
lblStatus1.Text = String.Empty
@@ -590,17 +612,10 @@ Public Class frmMain
lblStatus3.Text = String.Empty
pbIcon.Image = Icon_Unknown
'Get Process Information
Try
If Not mgrCommon.IsUnix Then
'Grab icon from the executable and save a copy
ic = System.Drawing.Icon.ExtractAssociatedIcon(oProcess.FoundProcess.MainModule.FileName)
sIconFile = mgrPath.SettingsRoot & Path.DirectorySeparatorChar & oProcess.GameInfo.ID & ".bmp"
ic.ToBitmap.Save(sIconFile)
ic.Dispose()
pbIcon.Image = Image.FromFile(sIconFile)
End If
'Set Game Icon
If Not mgrCommon.IsUnix Then SetGameIcon()
Try
'Set Game Details
sFileName = oProcess.FoundProcess.MainModule.FileName
sFileVersion = oProcess.FoundProcess.MainModule.FileVersionInfo.FileVersion
+9
View File
@@ -3084,6 +3084,15 @@ Namespace My.Resources
End Get
End Property
'''<summary>
''' Looks up a localized string similar to An error occured while extracting the executable icon..
'''</summary>
Friend ReadOnly Property frmMain_ErrorGameIcon() As String
Get
Return ResourceManager.GetString("frmMain_ErrorGameIcon", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to An unexpected error occured while initializing GBM.[BR][BR][PARAM][BR][BR]Do you wish to continue anyway? (Not Recommended).
'''</summary>
+3
View File
@@ -2194,4 +2194,7 @@
<data name="frmMain_ErrorGameDetails" xml:space="preserve">
<value>An error occured while obtaining the details of the detected game.</value>
</data>
<data name="frmMain_ErrorGameIcon" xml:space="preserve">
<value>An error occured while extracting the executable icon.</value>
</data>
</root>