52 lines
1.6 KiB
VB.net
52 lines
1.6 KiB
VB.net
Imports DevExpress.XtraBars.Ribbon
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Namespace Base
|
|
''' <summary>
|
|
''' This BaseClass is used to provide common functionality like the Logger or ErrorHandler to all Forms
|
|
''' To use it, create a form and change the `Inherits` statement in FormName.Designer.vb to this form, eg.:
|
|
'''
|
|
''' Partial Class frmExample
|
|
''' Inherits BaseForm
|
|
'''
|
|
''' ...
|
|
''' End Class
|
|
''' </summary>
|
|
Public Class BaseForm
|
|
Inherits Form
|
|
|
|
Private ReadOnly _ErrorHandler As ClassErrorHandler
|
|
|
|
Protected ReadOnly Property Logger As Logger
|
|
|
|
Public Sub New()
|
|
' Get the full name of the inheriting form
|
|
' so the log messages have the right classname
|
|
Dim oClassName = [GetType]().FullName
|
|
|
|
' My.LogConfig is undefined in the designer
|
|
Logger = My.LogConfig?.GetLogger(oClassName)
|
|
_ErrorHandler = New ClassErrorHandler(Logger)
|
|
|
|
' When you add something, be careful if it
|
|
' depends on a global var like My.LogConfig
|
|
' you might need to check for its existence with ?
|
|
End Sub
|
|
|
|
Public Sub ShowErrorMessage(Exception As Exception)
|
|
_ErrorHandler.ShowErrorMessage(Exception)
|
|
End Sub
|
|
|
|
Private Sub InitializeComponent()
|
|
SuspendLayout()
|
|
'
|
|
'BaseForm
|
|
'
|
|
ClientSize = New Size(284, 261)
|
|
Name = "BaseForm"
|
|
|
|
ResumeLayout(False)
|
|
End Sub
|
|
End Class
|
|
End Namespace
|