Improve Base Form Properties, Improve PanelManager
This commit is contained in:
parent
e7e6d73411
commit
896426da3b
@ -10,6 +10,10 @@ Public Class ClassErrorHandler
|
||||
Public Sub New(Logger As Logger)
|
||||
_Logger = Logger
|
||||
End Sub
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_Logger.Error(Exception)
|
||||
MsgBox(GetMessage(Exception), MsgBoxStyle.Critical, "Unexpected Error")
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception)
|
||||
Dim oTargetSite = Exception.TargetSite
|
||||
@ -34,11 +38,6 @@ Public Class ClassErrorHandler
|
||||
Return oMessage
|
||||
End Function
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_Logger.Error(Exception)
|
||||
MsgBox(GetMessage(Exception), MsgBoxStyle.Critical, "Unexpected Error")
|
||||
End Sub
|
||||
|
||||
Private Function GetMethodName(Exception As Exception) As String
|
||||
Dim oMethodName = Exception.TargetSite?.ReflectedType?.Name
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
Imports DevExpress.XtraBars.Docking2010
|
||||
Imports DevExpress.XtraBars.Docking2010.Views
|
||||
Imports DevExpress.XtraBars.Docking2010.Views.Tabbed
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassPanelManager
|
||||
@ -88,17 +89,42 @@ Public Class ClassPanelManager
|
||||
' TODO: determine how much panels at most can be added
|
||||
' check if initial panels should be loaded
|
||||
For Each oPanelInfo As PanelInfo In oInitialPanelInfo
|
||||
' Create the control
|
||||
Dim oControl = oPanelInfo.InnerControl
|
||||
oControl.Dock = DockStyle.Fill
|
||||
|
||||
' Create the panel and add the control
|
||||
' create the panel
|
||||
Dim oPanel = _dockManager.AddPanel(oPanelInfo.Position)
|
||||
|
||||
' create the control
|
||||
Dim oControl As BasePanel = GetPanelControl(oPanelInfo)
|
||||
|
||||
If oControl Is Nothing Then
|
||||
Dim oPanelType = oPanelInfo.PanelControl.GetType.ToString
|
||||
_logger.Warn("Unknown panel type {0}", oPanelType)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
' configure the panel
|
||||
oPanel.Options.ShowCloseButton = oPanelInfo.CanBeClosed
|
||||
oPanel.Options.ShowAutoHideButton = oPanelInfo.CanBePinned
|
||||
oPanel.Options.ShowMaximizeButton = oPanelInfo.CanBeMaximized
|
||||
oPanel.Options.AllowFloating = oPanelInfo.CanBeUndocked
|
||||
|
||||
' hashcode is needed to know which form a panel belongs to
|
||||
oPanel.Tag = oForm.GetHashCode
|
||||
oPanel.Text = oPanelInfo.Caption
|
||||
oPanel.Text = oPanelInfo.Title
|
||||
oPanel.Controls.Add(oControl)
|
||||
Next
|
||||
|
||||
' TODO: establish communication channel to load panels on-demand
|
||||
End Sub
|
||||
|
||||
Private Function GetPanelControl(PanelInfo As PanelInfo) As BasePanel
|
||||
If TypeOf PanelInfo.PanelControl Is DocumentPanel Then
|
||||
Dim oPanelControl As DocumentPanel = DirectCast(PanelInfo.PanelControl, DocumentPanel)
|
||||
oPanelControl.Datasource = PanelInfo.Datasource
|
||||
oPanelControl.Dock = DockStyle.Fill
|
||||
|
||||
Return oPanelControl
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -159,7 +159,6 @@
|
||||
<Compile Include="Panels\DocumentPanel.vb">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Panels\IPanel.vb" />
|
||||
<Compile Include="Panels\PanelInfo.vb" />
|
||||
<Compile Include="_TEST\DockManagerTest.Designer.vb">
|
||||
<DependentUpon>DockManagerTest.vb</DependentUpon>
|
||||
|
||||
@ -14,8 +14,14 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class BaseForm
|
||||
Inherits Form
|
||||
|
||||
Protected ReadOnly _Logger As Logger
|
||||
Protected ReadOnly _ErrorHandler As ClassErrorHandler
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _ErrorHandler As ClassErrorHandler
|
||||
|
||||
Protected ReadOnly Property Logger As Logger
|
||||
Get
|
||||
Return _Logger
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New()
|
||||
' Get the full name of the inheriting form
|
||||
@ -30,4 +36,8 @@ Public Class BaseForm
|
||||
' 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
|
||||
End Class
|
||||
@ -17,8 +17,14 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class BaseRibbonForm
|
||||
Inherits RibbonForm
|
||||
|
||||
Protected ReadOnly _Logger As Logger
|
||||
Protected ReadOnly _ErrorHandler As ClassErrorHandler
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _ErrorHandler As ClassErrorHandler
|
||||
|
||||
Protected ReadOnly Property Logger As Logger
|
||||
Get
|
||||
Return _Logger
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New()
|
||||
' Get the full name of the inheriting form
|
||||
@ -34,6 +40,17 @@ Public Class BaseRibbonForm
|
||||
' you might need to check for its existence with ?
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_ErrorHandler.ShowErrorMessage(Exception)
|
||||
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
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
Public Class BasePanel
|
||||
|
||||
Public Property Caption As String
|
||||
End Class
|
||||
|
||||
42
EDMI_ClientSuite/Panels/DocumentPanel.Designer.vb
generated
42
EDMI_ClientSuite/Panels/DocumentPanel.Designer.vb
generated
@ -1,6 +1,6 @@
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class DocumentPanel
|
||||
Inherits System.Windows.Forms.UserControl
|
||||
Inherits BasePanel
|
||||
|
||||
'UserControl überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
@ -22,40 +22,40 @@ Partial Class DocumentPanel
|
||||
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.GridControl1 = New DevExpress.XtraGrid.GridControl()
|
||||
Me.GridView1 = New DevExpress.XtraGrid.Views.Grid.GridView()
|
||||
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.GridControlMain = New DevExpress.XtraGrid.GridControl()
|
||||
Me.GridViewMain = New DevExpress.XtraGrid.Views.Grid.GridView()
|
||||
CType(Me.GridControlMain, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.GridViewMain, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'GridControl1
|
||||
'GridControlMain
|
||||
'
|
||||
Me.GridControl1.Dock = System.Windows.Forms.DockStyle.Fill
|
||||
Me.GridControl1.Location = New System.Drawing.Point(0, 0)
|
||||
Me.GridControl1.MainView = Me.GridView1
|
||||
Me.GridControl1.Name = "GridControl1"
|
||||
Me.GridControl1.Size = New System.Drawing.Size(1027, 383)
|
||||
Me.GridControl1.TabIndex = 0
|
||||
Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1})
|
||||
Me.GridControlMain.Dock = System.Windows.Forms.DockStyle.Fill
|
||||
Me.GridControlMain.Location = New System.Drawing.Point(0, 0)
|
||||
Me.GridControlMain.MainView = Me.GridViewMain
|
||||
Me.GridControlMain.Name = "GridControlMain"
|
||||
Me.GridControlMain.Size = New System.Drawing.Size(1027, 383)
|
||||
Me.GridControlMain.TabIndex = 0
|
||||
Me.GridControlMain.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridViewMain})
|
||||
'
|
||||
'GridView1
|
||||
'GridViewMain
|
||||
'
|
||||
Me.GridView1.GridControl = Me.GridControl1
|
||||
Me.GridView1.Name = "GridView1"
|
||||
Me.GridViewMain.GridControl = Me.GridControlMain
|
||||
Me.GridViewMain.Name = "GridViewMain"
|
||||
'
|
||||
'DocumentPanel
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.Controls.Add(Me.GridControl1)
|
||||
Me.Controls.Add(Me.GridControlMain)
|
||||
Me.Name = "DocumentPanel"
|
||||
Me.Size = New System.Drawing.Size(1027, 383)
|
||||
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.GridView1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.GridControlMain, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.GridViewMain, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
Friend WithEvents GridControl1 As DevExpress.XtraGrid.GridControl
|
||||
Friend WithEvents GridView1 As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
Friend WithEvents GridControlMain As DevExpress.XtraGrid.GridControl
|
||||
Friend WithEvents GridViewMain As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
End Class
|
||||
|
||||
@ -1,12 +1,26 @@
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DigitalData.GUIs.ClientSuite
|
||||
|
||||
Public Class DocumentPanel
|
||||
Inherits BasePanel
|
||||
|
||||
Public WriteOnly Property Datasource As DataTable
|
||||
Set(value As DataTable)
|
||||
GridControlMain.DataSource = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Sub DocumentPanel_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Dim oGridPatcher As New ClassControlPatcher(Of GridControl)(Me)
|
||||
oGridPatcher.
|
||||
ProcessContainer(AddressOf GridControlDefaults.DefaultGridSettings).
|
||||
ProcessContainer(AddressOf GridControlDefaults.ReadOnlyGridSettings)
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewMain_RowClick(sender As Object, e As RowClickEventArgs) Handles GridViewMain.RowClick
|
||||
If e.Button = MouseButtons.Left And e.Clicks = 2 Then
|
||||
MsgBox("Open Preview")
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Public Interface IPanel
|
||||
ReadOnly Property PanelName As String
|
||||
End Interface
|
||||
@ -1,7 +1,26 @@
|
||||
Imports DevExpress.XtraBars.Docking
|
||||
|
||||
Public Class PanelInfo
|
||||
Public Caption As String
|
||||
Public InnerControl As BasePanel
|
||||
Public Position As DockingStyle
|
||||
End Class
|
||||
Public ReadOnly Title As String
|
||||
Public ReadOnly PanelControl As BasePanel
|
||||
Public ReadOnly Position As DockingStyle
|
||||
Public ReadOnly Datasource As DataTable
|
||||
|
||||
Public CanBeClosed As Boolean = True
|
||||
Public CanBePinned As Boolean = True
|
||||
Public CanBeUndocked As Boolean = True
|
||||
Public CanBeMaximized As Boolean = True
|
||||
|
||||
Public Sub New(PanelControl As BasePanel, Position As DockingStyle)
|
||||
Me.Title = PanelControl.Caption
|
||||
Me.PanelControl = PanelControl
|
||||
Me.Position = Position
|
||||
End Sub
|
||||
|
||||
Public Sub New(PanelControl As BasePanel, Position As DockingStyle, Datasource As DataTable)
|
||||
Me.Title = PanelControl.Caption
|
||||
Me.PanelControl = PanelControl
|
||||
Me.Position = Position
|
||||
Me.Datasource = Datasource
|
||||
End Sub
|
||||
End Class
|
||||
@ -32,7 +32,7 @@ Public Class frmDocTest
|
||||
|
||||
GridControl1.DataSource = oDatatable
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ Public Class frmFileTest
|
||||
_fileOp = New Document(My.LogConfig, My.Settings.EDM_NetworkService_Adress)
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Warn($"Unexpected error in frmFileTest_Load: {ex.Message}")
|
||||
Logger.Warn($"Unexpected error in frmFileTest_Load: {ex.Message}")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -38,7 +38,7 @@ Public Class frmFileTest
|
||||
listboxLog.Items.Add($"----------------------------------------------------------")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -60,7 +60,7 @@ Public Class frmFileTest
|
||||
listboxLog.Items.Add($"Filename: {oDocObject.FileName}")
|
||||
listboxLog.Items.Add($"----------------------------------------------------------")
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -82,7 +82,7 @@ Public Class frmFileTest
|
||||
listboxLog.Items.Add($"Filename: {oDocObject.FileName}")
|
||||
listboxLog.Items.Add($"----------------------------------------------------------")
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
@ -68,7 +68,7 @@ Public Class frmMain
|
||||
' We're done loading now
|
||||
_Loading = False
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -96,7 +96,7 @@ Public Class frmMain
|
||||
'DocumentManager.View.RestoreLayoutFromXml(oLayoutPathForDocumentManager)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub SaveLayout()
|
||||
@ -112,7 +112,7 @@ Public Class frmMain
|
||||
'DockManager.SaveLayoutToXml(oLayoutPathForDockManager)
|
||||
'DocumentManager.View.SaveLayoutToXml(oLayoutPathForDocumentManager)
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -197,8 +197,6 @@ Public Class frmMain
|
||||
End Sub
|
||||
|
||||
Private Sub MainNav_SelectedItemChanging(sender As Object, e As DevExpress.XtraBars.Navigation.SelectedItemChangingEventArgs) Handles MainNav.SelectedItemChanging
|
||||
|
||||
|
||||
Select Case e.Item.Name
|
||||
Case NavbarItemHome.Name
|
||||
Dim oForm As New frmHome()
|
||||
|
||||
@ -32,7 +32,7 @@ Public Class frmObjectEditor
|
||||
}
|
||||
|
||||
If _Datatable Is Nothing Then
|
||||
_ErrorHandler.ShowErrorMessage(New ArgumentNullException("Datatable is empty"))
|
||||
ShowErrorMessage(New ArgumentNullException("Datatable is empty"))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@ -54,7 +54,7 @@ Public Class frmObjectEditor
|
||||
Await LoadLanguageTableAsync(My.Application.User.Language)
|
||||
LoadDetailForm()
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -110,7 +110,7 @@ Public Class frmObjectEditor
|
||||
|
||||
Await My.Channel.CloseDatabaseRequestAsync()
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
@ -16,11 +16,15 @@ Public Class frmSearch
|
||||
|
||||
Public Overrides Function GetInitialPanels() As List(Of PanelInfo)
|
||||
Dim oList = MyBase.GetInitialPanels()
|
||||
Dim oPanel = New DocumentPanel()
|
||||
Dim oData As DataTable
|
||||
|
||||
oList.Add(New PanelInfo() With {
|
||||
.Caption = "Search",
|
||||
.InnerControl = New DocumentPanel(),
|
||||
.Position = DockingStyle.Bottom
|
||||
My.Channel.CreateDatabaseRequest("Get Users", False)
|
||||
oData = My.Channel.ReturnDatatable("SELECT * FROM VWICM_USER").Table
|
||||
My.Channel.CloseDatabaseRequest()
|
||||
|
||||
oList.Add(New PanelInfo(oPanel, DockingStyle.Bottom, oData) With {
|
||||
.CanBeClosed = False
|
||||
})
|
||||
|
||||
Return oList
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user