Zooflow: Fix messageboxes without title
This commit is contained in:
47
GUIs.Common/FormHelper.vb
Normal file
47
GUIs.Common/FormHelper.vb
Normal file
@@ -0,0 +1,47 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Public Class FormHelper
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
Private ReadOnly Form As Form
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pForm As Form)
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
Form = pForm
|
||||
End Sub
|
||||
|
||||
Public Function ShowInfoMessage(pMessage As String, pTitle As String) As DialogResult
|
||||
Logger.Info(pMessage)
|
||||
|
||||
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Info)
|
||||
Return oForm.ShowDialog()
|
||||
End Function
|
||||
|
||||
Public Function ShowErrorMessage(pMessage As String, pTitle As String) As DialogResult
|
||||
Return ShowErrorMessage(New ApplicationException(pMessage), pTitle)
|
||||
End Function
|
||||
|
||||
Public Function ShowErrorMessage(pException As Exception, pTitle As String) As DialogResult
|
||||
Logger.Error(pException)
|
||||
|
||||
Dim oMessage = String.Format("In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}", pTitle, vbNewLine & vbNewLine & pException.Message)
|
||||
|
||||
If LogConfig.Debug Then
|
||||
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
|
||||
oMessage &= vbNewLine & vbNewLine & "Stacktrace:"
|
||||
oMessage &= vbNewLine & pException.StackTrace
|
||||
End If
|
||||
|
||||
Dim oForm As New frmDialog(oMessage, pTitle, frmDialog.DialogType.Error)
|
||||
Return oForm.ShowDialog()
|
||||
End Function
|
||||
|
||||
Public Function ShowWarningMessage(pMessage As String, pTitle As String) As DialogResult
|
||||
Logger.Warn(pMessage)
|
||||
|
||||
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Error)
|
||||
Return oForm.ShowDialog()
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user