Added common message box function

This commit is contained in:
Michael J. Seiferling
2015-12-18 12:16:09 -06:00
parent 50cb987e9a
commit 8930f6d6cc
17 changed files with 114 additions and 108 deletions
+2 -2
View File
@@ -109,7 +109,7 @@ Public Class mgrBackup
RaiseEvent UpdateBackupInfo(oGame)
If mgrRestore.CheckManifest(oGame.Name) Then
If MsgBox("The manifest shows the backup folder contains a backup for " & oGame.Name & " that has not been restored on this computer." & vbCrLf & vbCrLf & "Do you want to overwrite this file anyway?", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.No Then
If mgrCommon.ShowMessage("The manifest shows the backup folder contains a backup for " & oGame.Name & " that has not been restored on this computer." & vbCrLf & vbCrLf & "Do you want to overwrite this file anyway?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
RaiseEvent UpdateLog("Backup aborted by user due to manifest conflict.", False, ToolTipIcon.Error, True)
bDoBackup = False
End If
@@ -134,7 +134,7 @@ Public Class mgrBackup
End If
If oSettings.ShowOverwriteWarning And File.Exists(sBackupFile) Then
If MsgBox("A file with the same name already exists in the backup folder." & vbCrLf & vbCrLf & "Do you want to overwrite this file?", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.No Then
If mgrCommon.ShowMessage("A file with the same name already exists in the backup folder." & vbCrLf & vbCrLf & "Do you want to overwrite this file?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
RaiseEvent UpdateLog(oGame.Name & " backup aborted by user due to overwrite.", False, ToolTipIcon.Error, True)
bDoBackup = False
End If
+6
View File
@@ -125,4 +125,10 @@ Public Class mgrCommon
oProcess.Start()
End Sub
Public Shared Function ShowMessage(ByVal sMsg As String, ByVal oType As MsgBoxStyle) As MsgBoxResult
Dim oResult As MsgBoxResult
oResult = MsgBox(sMsg, oType, "Game Backup Monitor")
Return oResult
End Function
End Class
+10 -10
View File
@@ -23,9 +23,9 @@ Public Class mgrMonitorList
'If the remote database actually contains a list, then ask what to do
If iGameCount > 0 Then
If MsgBox("GBM data already exists in the backup folder." & vbCrLf & vbCrLf & _
If mgrCommon.ShowMessage("GBM data already exists in the backup folder." & vbCrLf & vbCrLf & _
"Do you want to make your local game list the new master game list in this folder? (Recommended)" & vbCrLf & vbCrLf & _
"Choosing No will sync your local game list to the current master game list in this folder.", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
"Choosing No will sync your local game list to the current master game list in this folder.", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
mgrMonitorList.SyncMonitorLists()
Else
mgrMonitorList.SyncMonitorLists(False)
@@ -45,7 +45,7 @@ Public Class mgrMonitorList
Dim oStringFilters As New Hashtable
Dim eCurrentFilter As frmFilter.eFilterType = frmFilter.eFilterType.NoFilter
If MsgBox("Would you like to apply a filter to your export?", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage("Would you like to apply a filter to your export?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Dim frm As New frmFilter
frm.ShowDialog()
oTagFilters = frm.TagFilters
@@ -56,9 +56,9 @@ Public Class mgrMonitorList
oList = ReadListForExport(oTagFilters, oStringFilters, eCurrentFilter)
bSuccess = mgrXML.SerializeAndExport(oList, sLocation)
If bSuccess Then
MsgBox("Export Complete. " & oList.Count & " item(s) have been exported.", MsgBoxStyle.Information, "Game Backup Monitor")
mgrCommon.ShowMessage("Export Complete. " & oList.Count & " item(s) have been exported.", MsgBoxStyle.Information)
End If
End Sub
@@ -157,7 +157,7 @@ Public Class mgrMonitorList
If bToRemote Then
DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Remote)
Else
DoListAddUpdateSync(hshSyncItems, mgrSQLite.Database.Local)
End If
@@ -233,10 +233,10 @@ Public Class mgrMonitorList
mgrTags.DoTagAddImport(frm.ImportData)
Cursor.Current = Cursors.Default
MsgBox("Import Complete.", MsgBoxStyle.Information, "Game Backup Monitor")
mgrCommon.ShowMessage("Import Complete.", MsgBoxStyle.Information)
End If
Else
MsgBox("This list does not contain any new games to import.", MsgBoxStyle.Information, "Game Backup Monitor")
mgrCommon.ShowMessage("This list does not contain any new games to import.", MsgBoxStyle.Information)
End If
Application.DoEvents()
@@ -249,7 +249,7 @@ Public Class mgrMonitorList
ImportMonitorList(sPath, True)
Return True
Else
MsgBox("There's no response from:" & vbCrLf & vbCrLf & sPath & vbCrLf & vbCrLf & "Either the server is not responding or the URL is invalid.")
mgrCommon.ShowMessage("There's no response from:" & vbCrLf & vbCrLf & sPath & vbCrLf & vbCrLf & "Either the server is not responding or the URL is invalid.", MsgBoxStyle.Exclamation)
Return False
End If
Else
@@ -257,7 +257,7 @@ Public Class mgrMonitorList
ImportMonitorList(sPath)
Return True
Else
MsgBox("The file:" & vbCrLf & sPath & vbCrLf & "cannot be found.")
mgrCommon.ShowMessage("The file:" & vbCrLf & sPath & vbCrLf & "cannot be found.", MsgBoxStyle.Exclamation)
Return False
End If
End If
+6 -6
View File
@@ -347,7 +347,7 @@ Public Class mgrPath
If bNoAuto Then
sMessage = sSearchReason & vbCrLf & vbCrLf & "Do you wish to manually set the game path? (Path will be saved)"
If MsgBox(sMessage, MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
sFolder = SetManualgamePath()
End If
@@ -356,14 +356,14 @@ Public Class mgrPath
sMessage = sSearchReason & vbCrLf & vbCrLf & "Do you wish to automatically search for the game path? (Path will be saved)"
If MsgBox(sMessage, MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
frmFind.ShowDialog()
If frmFind.FoundItem <> String.Empty Then
sFolder = IO.Path.GetDirectoryName(frmFind.FoundItem)
sMessage = sGameName & " was located in the following folder:" & vbCrLf & vbCrLf & _
sFolder & vbCrLf & vbCrLf & "Is this correct?"
If MsgBox(sMessage, MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Return sFolder
Else
sFolder = String.Empty
@@ -379,7 +379,7 @@ Public Class mgrPath
sMessage = "Do you wish to manually set the game path? (Path will be saved)"
End If
If MsgBox(sMessage, MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
sFolder = SetManualgamePath()
End If
End If
@@ -391,9 +391,9 @@ Public Class mgrPath
Dim dBrowser As FolderBrowserDialog
If Not Directory.Exists(sBackupPath) Then
If MsgBox("The backup location " & sBackupPath & " is not available." & vbCrLf & _
If mgrCommon.ShowMessage("The backup location " & sBackupPath & " is not available." & vbCrLf & _
"It may be on an external or network drive that isn't connected." & vbCrLf & vbCrLf & _
"Do you want to select another backup location and continue?", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
"Do you want to select another backup location and continue?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
dBrowser = New FolderBrowserDialog
dBrowser.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
If dBrowser.ShowDialog = DialogResult.OK Then
+7 -7
View File
@@ -31,15 +31,15 @@ Public Class mgrRestore
Dim oResult As MsgBoxResult
If oCheckBackup.RestorePath <> oCheckGame.Path Then
oResult = MsgBox("The restore path for " & oCheckBackup.CroppedName & " does not match it's current save path." & vbCrLf & vbCrLf & _
"Do you want to restore to the current save path instead? (Recommended)", MsgBoxStyle.YesNoCancel, "Game Backup Monitor")
oResult = mgrCommon.ShowMessage("The restore path for " & oCheckBackup.CroppedName & " does not match it's current save path." & vbCrLf & vbCrLf & _
"Do you want to restore to the current save path instead? (Recommended)", MsgBoxStyle.YesNoCancel)
If oResult = MsgBoxResult.Yes Then
If Path.IsPathRooted(oCheckGame.Path) Then
oCheckBackup.AbsolutePath = True
oCheckBackup.RestorePath = oCheckGame.Path
Else
oCheckBackup.RestorePath = oCheckGame.Path
End If
End If
ElseIf oResult = MsgBoxResult.Cancel Then
Return False
End If
@@ -198,8 +198,8 @@ Public Class mgrRestore
'Check if restore location exists, prompt to create if it doesn't.
If Not Directory.Exists(sExtractPath) Then
If MsgBox("The restore path " & sExtractPath & " does not exist." & vbCrLf & vbCrLf & _
"Do you want to create the folder and continue?", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.Yes Then
If mgrCommon.ShowMessage("The restore path " & sExtractPath & " does not exist." & vbCrLf & vbCrLf & _
"Do you want to create the folder and continue?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Try
Directory.CreateDirectory(sExtractPath)
Catch ex As Exception
@@ -218,8 +218,8 @@ Public Class mgrRestore
sHash = mgrHash.Generate_SHA256_Hash(sBackupFile)
If sHash <> oBackupInfo.CheckSum Then
RaiseEvent UpdateLog("The backup file for " & oBackupInfo.Name & " has failed the file integrity check.", False, ToolTipIcon.Info, True)
If MsgBox("The backup file for " & oBackupInfo.Name & " has failed the file intergity check. It may be corrupted, not exist or been modified by another application." & vbCrLf & vbCrLf & _
"Do you still want to restore this backup? (Not Recommended)", MsgBoxStyle.YesNo, "Game Backup Monitor") = MsgBoxResult.No Then
If mgrCommon.ShowMessage("The backup file for " & oBackupInfo.Name & " has failed the file intergity check. It may be corrupted, not exist or been modified by another application." & vbCrLf & vbCrLf & _
"Do you still want to restore this backup? (Not Recommended)", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
RaiseEvent UpdateLog("Restored Aborted by user due to a failed file integrity check.", False, ToolTipIcon.Info, True)
bDoRestore = False
End If
+9 -9
View File
@@ -39,7 +39,7 @@ Public Class mgrSQLite
File.Copy(mgrPath.RemoteDatabaseLocation, sNewFile, False)
End Select
Catch ex As Exception
MsgBox("An error occured creating a backup of the database file at " & sNewFile & vbCrLf & vbCrLf & ex.Message)
mgrCommon.ShowMessage("An error occured creating a backup of the database file at " & sNewFile & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
@@ -99,7 +99,7 @@ Public Class mgrSQLite
RunParamQuery(sSql, New Hashtable)
Return True
Catch e As Exception
MsgBox("An error has occured attempting to create the local application database: " & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting to create the local application database: " & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
@@ -133,7 +133,7 @@ Public Class mgrSQLite
RunParamQuery(sSql, New Hashtable)
Return True
Catch e As Exception
MsgBox("An error has occured attempting to create the remote application database: " & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting to create the remote application database: " & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
@@ -180,12 +180,12 @@ Public Class mgrSQLite
BuildParams(command, hshParams)
trans = db.BeginTransaction()
Try
Try
command.ExecuteNonQuery()
trans.Commit()
Catch e As Exception
trans.Rollback()
MsgBox("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Exclamation)
Return False
Finally
command.Dispose()
@@ -211,7 +211,7 @@ Public Class mgrSQLite
trans.Commit()
Catch e As Exception
trans.Rollback()
MsgBox("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Exclamation)
Return False
Finally
command.Dispose()
@@ -234,7 +234,7 @@ Public Class mgrSQLite
adapter = New SQLiteDataAdapter(command)
adapter.Fill(oData)
Catch e As Exception
MsgBox("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Exclamation)
Finally
command.Dispose()
Disconnect()
@@ -396,7 +396,7 @@ Public Class mgrSQLite
RunParamQuery(sSQL, New Hashtable)
'Upgrade IDs to GUIDs
UpgradeToGUID("monitorlist", "MonitorID")
UpgradeToGUID("monitorlist", "MonitorID")
UpgradeToGUID("manifest", "ManifestID")
'Run a compact due to the large operations
@@ -524,7 +524,7 @@ Public Class mgrSQLite
Try
command.ExecuteNonQuery()
Catch e As Exception
MsgBox("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message)
mgrCommon.ShowMessage("An error has occured attempting run the query." & vbCrLf & vbCrLf & sSQL & vbCrLf & vbCrLf & e.Message, MsgBoxStyle.Exclamation)
Finally
command.Dispose()
Disconnect()
+3 -3
View File
@@ -60,7 +60,7 @@ Public Class mgrXML
oList = oSerializer.Deserialize(oReader)
oReader.Close()
Catch ex As Exception
MsgBox("The XML file cannot be read, it may be an invalid format or corrupted." & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "Game Backup Monitor")
mgrCommon.ShowMessage("The XML file cannot be read, it may be an invalid format or corrupted." & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Exclamation)
End Try
Return oList
@@ -75,10 +75,10 @@ Public Class mgrXML
oWriter = New StreamWriter(sLocation)
oSerializer.Serialize(oWriter.BaseStream, oList)
oWriter.Flush()
oWriter.Close()
oWriter.Close()
Return True
Catch ex As Exception
MsgBox("An error occured exporting the XML data." & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "Game Backup Monitor")
mgrCommon.ShowMessage("An error occured exporting the XML data." & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Exclamation)
Return False
End Try
End Function