move clientsuite to GUIs.ClientSuite folder
This commit is contained in:
94
GUIs.ClientSuite/Base/BaseRibbonForm.vb
Normal file
94
GUIs.ClientSuite/Base/BaseRibbonForm.vb
Normal file
@@ -0,0 +1,94 @@
|
||||
Imports DevExpress.XtraBars.Docking
|
||||
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 BaseRibbonForm
|
||||
'''
|
||||
''' ...
|
||||
''' End Class
|
||||
'''
|
||||
''' Only BaseRibbonForms can have panels attached to it!
|
||||
''' </summary>
|
||||
Public Class BaseRibbonForm
|
||||
Inherits RibbonForm
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _ErrorHandler As ClassErrorHandler
|
||||
|
||||
Protected ReadOnly Property Logger As Logger
|
||||
Get
|
||||
Return _Logger
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Sets or gets the ribbon Page that will be shown when the window is visible
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DefaultRibbonPage As RibbonPage
|
||||
|
||||
Protected Overrides Sub OnLoad(e As EventArgs)
|
||||
MyBase.OnLoad(e)
|
||||
|
||||
If DefaultRibbonPage IsNot Nothing Then
|
||||
Ribbon.SelectPage(DefaultRibbonPage)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnVisibleChanged(e As EventArgs)
|
||||
MyBase.OnVisibleChanged(e)
|
||||
|
||||
If Visible And DefaultRibbonPage IsNot Nothing Then
|
||||
Ribbon.SelectPage(DefaultRibbonPage)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnActivated(e As EventArgs)
|
||||
MyBase.OnVisibleChanged(e)
|
||||
|
||||
If Visible And DefaultRibbonPage IsNot Nothing Then
|
||||
Ribbon.SelectPage(DefaultRibbonPage)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
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
|
||||
|
||||
Public Sub ShowErrorMessage(ErrorMessage As String)
|
||||
_ErrorHandler.ShowErrorMessage(New Exception(ErrorMessage))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Returns a list of panels that will be show when the form is opened.
|
||||
''' This can be overridden by all inheriting forms to extend the list of panels
|
||||
''' Panels will be created by PanelManager.
|
||||
''' </summary>
|
||||
''' <seealso cref="ClassPanelManager"/>
|
||||
''' <returns>A list of PanelInformation</returns>
|
||||
Public Overridable Function GetInitialPanels() As List(Of PanelInfo)
|
||||
Return New List(Of PanelInfo)
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user