Add Base(Ribbon)Form to provide Logger and ErrorHandler to all forms, Save Config per frmEdit Instance
This commit is contained in:
@@ -8,7 +8,6 @@ Imports DevExpress.LookAndFeel
|
||||
Imports DevExpress.XtraBars.Ribbon
|
||||
|
||||
Public Class frmMain
|
||||
Private _Logger As Logger
|
||||
Private _Timer As ClassTimer
|
||||
Private _Loading As Boolean = True
|
||||
|
||||
@@ -38,75 +37,89 @@ Public Class frmMain
|
||||
End Sub
|
||||
|
||||
Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
' Initialize Main Timer
|
||||
_Timer = New ClassTimer(My.LogConfig, Me, My.SysConfig.HeartbeatInterval)
|
||||
AddHandler _Timer.OnlineChanged, AddressOf HandleOnlineChanged
|
||||
SetOnlineLabel()
|
||||
Try
|
||||
' Initialize Main Timer
|
||||
_Timer = New ClassTimer(My.LogConfig, Me, My.SysConfig.HeartbeatInterval)
|
||||
AddHandler _Timer.OnlineChanged, AddressOf HandleOnlineChanged
|
||||
SetOnlineLabel()
|
||||
UserLookAndFeel.Default.SetSkinStyle(My.UIConfig.SkinName)
|
||||
|
||||
LabelCurrentUser.Caption = My.Application.User.UserName
|
||||
LabelCurrentMachine.Caption = My.Application.User.MachineName
|
||||
LabelCurrentVersion.Caption = My.Application.Info.Version.ToString
|
||||
LabelCurrentLanguage.Caption = My.Application.User.Language
|
||||
|
||||
Dim oDashboard = New frmDashboard()
|
||||
oDashboard.MdiParent = DocumentManager.MdiParent
|
||||
oDashboard.Show()
|
||||
|
||||
' --- Process Manager Panel ---
|
||||
Dim oDataTable = New DataTable("PMDocuments")
|
||||
Dim oDocNameColumn = New DataColumn("DocName", GetType(String))
|
||||
oDataTable.Columns.Add(oDocNameColumn)
|
||||
|
||||
Dim oRow = oDataTable.NewRow()
|
||||
oRow.Item("DocName") = "test1.xlsx"
|
||||
|
||||
oDataTable.Rows.Add(oRow)
|
||||
|
||||
ProcessManagerWidget.DataSource = oDataTable
|
||||
AddHandler ProcessManagerWidget.RowDoubleClicked, Sub(RowView As DataRowView)
|
||||
MsgBox($"Clicked on Document {RowView.Row.Item("DocName")}")
|
||||
End Sub
|
||||
|
||||
AddHandler UserLookAndFeel.Default.StyleChanged, AddressOf frmMain_StyleChanged
|
||||
|
||||
LoadLayout()
|
||||
|
||||
_Loading = False
|
||||
Catch ex As Exception
|
||||
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
End Try
|
||||
|
||||
|
||||
LabelCurrentUser.Caption = My.Application.User.UserName
|
||||
LabelCurrentMachine.Caption = My.Application.User.MachineName
|
||||
LabelCurrentVersion.Caption = My.Application.Info.Version.ToString
|
||||
LabelCurrentLanguage.Caption = My.Application.User.Language
|
||||
|
||||
Dim oDashboard = New frmDashboard()
|
||||
oDashboard.MdiParent = DocumentManager.MdiParent
|
||||
oDashboard.Show()
|
||||
|
||||
' --- Process Manager Panel ---
|
||||
Dim oDataTable = New DataTable("PMDocuments")
|
||||
Dim oDocNameColumn = New DataColumn("DocName", GetType(String))
|
||||
oDataTable.Columns.Add(oDocNameColumn)
|
||||
|
||||
Dim oRow = oDataTable.NewRow()
|
||||
oRow.Item("DocName") = "test1.xlsx"
|
||||
|
||||
oDataTable.Rows.Add(oRow)
|
||||
|
||||
ProcessManagerWidget.DataSource = oDataTable
|
||||
AddHandler ProcessManagerWidget.RowDoubleClicked, Sub(RowView As DataRowView)
|
||||
MsgBox($"Clicked on Document {RowView.Row.Item("DocName")}")
|
||||
End Sub
|
||||
|
||||
AddHandler UserLookAndFeel.Default.StyleChanged, AddressOf frmMain_StyleChanged
|
||||
|
||||
LoadLayout()
|
||||
|
||||
_Loading = False
|
||||
End Sub
|
||||
|
||||
Private Sub FrmMain_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
||||
SaveLayout()
|
||||
End Sub
|
||||
|
||||
Private Sub LoadLayout()
|
||||
Dim oLayoutPathForDockManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DockManager)
|
||||
Dim oLayoutPathForDocumentManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DocumentManager)
|
||||
|
||||
If File.Exists(oLayoutPathForDockManager) Then
|
||||
DockManager.RestoreLayoutFromXml(oLayoutPathForDockManager)
|
||||
End If
|
||||
|
||||
If File.Exists(oLayoutPathForDocumentManager) Then
|
||||
DocumentManager.View.RestoreLayoutFromXml(oLayoutPathForDocumentManager)
|
||||
Private Sub frmMain_StyleChanged(sender As Object, e As EventArgs) Handles Me.StyleChanged
|
||||
If _Loading = False Then
|
||||
My.UIConfig.SkinName = LookAndFeel.ActiveSkinName
|
||||
My.UIConfigManager.Save()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub LoadLayout()
|
||||
Try
|
||||
Dim oLayoutPathForDockManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DockManager)
|
||||
Dim oLayoutPathForDocumentManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DocumentManager)
|
||||
|
||||
If File.Exists(oLayoutPathForDockManager) Then
|
||||
DockManager.RestoreLayoutFromXml(oLayoutPathForDockManager)
|
||||
End If
|
||||
|
||||
If File.Exists(oLayoutPathForDocumentManager) Then
|
||||
DocumentManager.View.RestoreLayoutFromXml(oLayoutPathForDocumentManager)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub SaveLayout()
|
||||
Dim oLayoutPathForDockManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DockManager)
|
||||
Dim oLayoutPathForDocumentManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DocumentManager)
|
||||
Dim oDirectory As String = GetLayoutDirectory()
|
||||
Try
|
||||
Dim oLayoutPathForDockManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DockManager)
|
||||
Dim oLayoutPathForDocumentManager As String = GetLayoutPath(GroupName.LayoutMain, LayoutComponent.DocumentManager)
|
||||
Dim oDirectory As String = GetLayoutDirectory()
|
||||
|
||||
If Not Directory.Exists(oDirectory) Then
|
||||
Directory.CreateDirectory(oDirectory)
|
||||
End If
|
||||
If Not Directory.Exists(oDirectory) Then
|
||||
Directory.CreateDirectory(oDirectory)
|
||||
End If
|
||||
|
||||
DockManager.SaveLayoutToXml(oLayoutPathForDockManager)
|
||||
DocumentManager.View.SaveLayoutToXml(oLayoutPathForDocumentManager)
|
||||
DockManager.SaveLayoutToXml(oLayoutPathForDockManager)
|
||||
DocumentManager.View.SaveLayoutToXml(oLayoutPathForDocumentManager)
|
||||
Catch ex As Exception
|
||||
_ErrorHandler.ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonUserSettings_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonUserSettings.ItemClick
|
||||
@@ -167,13 +180,6 @@ Public Class frmMain
|
||||
oForm.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_StyleChanged(sender As Object, e As EventArgs) Handles Me.StyleChanged
|
||||
If _Loading = False Then
|
||||
My.UIConfig.SkinName = LookAndFeel.ActiveSkinName
|
||||
My.UIConfigManager.Save()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Manually merge the status bars of the parent and child MDI forms.
|
||||
Private Sub RibbonControl1_Merge(ByVal sender As System.Object, ByVal e As RibbonMergeEventArgs) Handles RibbonControl.Merge
|
||||
Dim oParentRibbon As RibbonControl = TryCast(sender, RibbonControl)
|
||||
|
||||
Reference in New Issue
Block a user