zooflow: msgbox

This commit is contained in:
Jonathan Jenne
2022-05-24 12:16:23 +02:00
parent 6cefffc2a6
commit ba3b4c7bf5
12 changed files with 117 additions and 90 deletions

View File

@@ -15,18 +15,15 @@ Public Class FormHelper
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)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Info)
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)
Dim oMethodName = GetMethodName()
Dim oBaseMessage = "In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}"
Dim oMessage = String.Format(oBaseMessage, oMethodName, vbNewLine & vbNewLine & pException.Message)
If LogConfig.Debug Then
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
@@ -34,14 +31,32 @@ Public Class FormHelper
oMessage &= vbNewLine & pException.StackTrace
End If
Dim oForm As New frmDialog(oMessage, pTitle, frmDialog.DialogType.Error)
Return oForm.ShowDialog()
Return ShowMessage(oMessage, pTitle, frmDialog.DialogType.Error)
End Function
Public Function ShowWarningMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Warn(pMessage)
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Warning)
End Function
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Error)
Public Function ShowQuestionMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Question)
End Function
Public Function ShowSuccessMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Success)
End Function
Private Function ShowMessage(pMessage As String, pTitle As String, pType As frmDialog.DialogType) As DialogResult
Dim oForm As New frmDialog(pMessage, pTitle, pType)
Return oForm.ShowDialog()
End Function
Private Function GetMethodName() As String
Dim oStackTrace As New StackTrace()
Dim oMethodName As String = oStackTrace.GetFrame(2).GetMethod.Name
Return oMethodName
End Function
End Class

View File

@@ -26,13 +26,13 @@ Partial Class frmDialog
Me.btnPositive = New DevExpress.XtraEditors.SimpleButton()
Me.btnNegative = New DevExpress.XtraEditors.SimpleButton()
Me.pnlContent = New DevExpress.XtraEditors.PanelControl()
Me.txtContent = New DevExpress.XtraEditors.LabelControl()
Me.SvgImageBox1 = New DevExpress.XtraEditors.SvgImageBox()
Me.PanelControl1 = New DevExpress.XtraEditors.PanelControl()
Me.pnlHeader = New DevExpress.XtraEditors.PanelControl()
Me.txtTitle = New DevExpress.XtraEditors.LabelControl()
Me.pnlFooter = New DevExpress.XtraEditors.PanelControl()
Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components)
Me.txtContent2 = New DevExpress.XtraEditors.LabelControl()
CType(Me.pnlContent, System.ComponentModel.ISupportInitialize).BeginInit()
Me.pnlContent.SuspendLayout()
CType(Me.SvgImageBox1, System.ComponentModel.ISupportInitialize).BeginInit()
@@ -70,7 +70,7 @@ Partial Class frmDialog
'
'pnlContent
'
Me.pnlContent.Controls.Add(Me.txtContent)
Me.pnlContent.Controls.Add(Me.txtContent2)
Me.pnlContent.Controls.Add(Me.SvgImageBox1)
Me.pnlContent.Controls.Add(Me.PanelControl1)
Me.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill
@@ -79,24 +79,6 @@ Partial Class frmDialog
Me.pnlContent.Size = New System.Drawing.Size(498, 145)
Me.pnlContent.TabIndex = 3
'
'txtContent
'
Me.txtContent.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtContent.Appearance.Font = New System.Drawing.Font("Segoe UI", 9.75!)
Me.txtContent.Appearance.Options.UseFont = True
Me.txtContent.Appearance.Options.UseTextOptions = True
Me.txtContent.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top
Me.txtContent.AutoEllipsis = True
Me.txtContent.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None
Me.txtContent.Location = New System.Drawing.Point(98, 6)
Me.txtContent.Name = "txtContent"
Me.txtContent.Padding = New System.Windows.Forms.Padding(10)
Me.txtContent.Size = New System.Drawing.Size(388, 133)
Me.txtContent.TabIndex = 1
Me.txtContent.Text = "txtContent"
'
'SvgImageBox1
'
Me.SvgImageBox1.BackColor = System.Drawing.Color.Transparent
@@ -144,6 +126,9 @@ Partial Class frmDialog
'
'pnlFooter
'
Me.pnlFooter.Appearance.BackColor = System.Drawing.Color.FromArgb(CType(CType(230, Byte), Integer), CType(CType(230, Byte), Integer), CType(CType(230, Byte), Integer))
Me.pnlFooter.Appearance.Options.UseBackColor = True
Me.pnlFooter.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder
Me.pnlFooter.Controls.Add(Me.btnPositive)
Me.pnlFooter.Controls.Add(Me.btnNegative)
Me.pnlFooter.Dock = System.Windows.Forms.DockStyle.Bottom
@@ -160,6 +145,20 @@ Partial Class frmDialog
Me.SvgImageCollection1.Add("info", "image://svgimages/outlook inspired/about.svg")
Me.SvgImageCollection1.Add("question", "image://svgimages/icon builder/actions_question.svg")
'
'txtContent2
'
Me.txtContent2.Appearance.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtContent2.Appearance.Options.UseFont = True
Me.txtContent2.Appearance.Options.UseTextOptions = True
Me.txtContent2.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top
Me.txtContent2.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap
Me.txtContent2.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None
Me.txtContent2.Location = New System.Drawing.Point(98, 16)
Me.txtContent2.Name = "txtContent2"
Me.txtContent2.Size = New System.Drawing.Size(388, 124)
Me.txtContent2.TabIndex = 3
Me.txtContent2.Text = "LabelControl1"
'
'frmDialog
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -195,7 +194,7 @@ Partial Class frmDialog
Friend WithEvents pnlFooter As DevExpress.XtraEditors.PanelControl
Friend WithEvents SvgImageBox1 As DevExpress.XtraEditors.SvgImageBox
Friend WithEvents SvgImageCollection1 As DevExpress.Utils.SvgImageCollection
Friend WithEvents txtContent As DevExpress.XtraEditors.LabelControl
Friend WithEvents txtTitle As DevExpress.XtraEditors.LabelControl
Friend WithEvents PanelControl1 As DevExpress.XtraEditors.PanelControl
Friend WithEvents txtContent2 As DevExpress.XtraEditors.LabelControl
End Class

View File

@@ -28,7 +28,7 @@ Public Class frmDialog
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
txtContent.Text = pMessageText
txtContent2.Text = pMessageText
txtTitle.Text = pTitle
Select Case pDialogType
@@ -62,7 +62,7 @@ Public Class frmDialog
End Select
Dim oLineBreaks = txtContent.Text.Split(vbNewLine).Count
Dim oLineBreaks = txtContent2.Text.Split(vbNewLine).Count
If oLineBreaks > 6 Then
Dim oHeightOffset = oLineBreaks * 20

View File

@@ -288,7 +288,7 @@ Public Class frmDocumentResultList
DocumentViewer1.LoadFile(oFileName, New MemoryStream(oDocument.Contents))
If IsNothing(oDocument) Then
DocumentViewer1.CloseDocument()
FormHelper.ShowErrorMessage("File could not be loaded!", "GridView_FocusedRowChanged")
FormHelper.ShowErrorMessage(New IOException("File could not be loaded!"), "GridView_FocusedRowChanged")
Exit Sub
End If