119 lines
4.2 KiB
VB.net
119 lines
4.2 KiB
VB.net
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraBars.Docking
|
|
Imports DevExpress.XtraGrid.Views.BandedGrid
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DigitalData.Modules.Base
|
|
Imports DigitalData.Modules.Config
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Namespace DocumentResultList
|
|
Public Class Layout
|
|
Inherits BaseClass
|
|
|
|
Private Config As ConfigManager(Of Config)
|
|
Private GridViews As List(Of GridView)
|
|
|
|
Public Sub New(pLogConfig As LogConfig, pConfig As ConfigManager(Of DocumentResultList.Config), pGridViews As List(Of GridView))
|
|
MyBase.New(pLogConfig)
|
|
Config = pConfig
|
|
GridViews = pGridViews
|
|
End Sub
|
|
|
|
#Region "Saving and Restoring layout"
|
|
|
|
|
|
|
|
Public Sub DockManager_SaveLayout(pDockManager As DockManager)
|
|
Try
|
|
Dim oXml As String = GetDockmanager_LayoutName()
|
|
pDockManager.SaveLayoutToXml(oXml)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Logger.Info("Error while saving GridLayout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub DockManager_RestoreLayout(pDockManager As DockManager)
|
|
Try
|
|
Dim oXml As String = GetDockmanager_LayoutName()
|
|
pDockManager.RestoreLayoutFromXml(oXml)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Logger.Info("Error while restoring GridLayout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub GridView_RestoreLayout(pGridView As GridView)
|
|
Try
|
|
Dim oLayoutFile As String = GetGrid_LayoutName(pGridView)
|
|
If IO.File.Exists(oLayoutFile) Then
|
|
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
|
|
End If
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Logger.Info("Error while restoring layout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub GridView_SaveLayout(pGridView As GridView)
|
|
Try
|
|
Dim oXml As String = GetGrid_LayoutName(pGridView)
|
|
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Logger.Info("Error while saving GridLayout: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function GetDockmanager_LayoutName() As String
|
|
Dim Filename As String = $"DockManagerDocResult_UserLayout.xml"
|
|
Dim oDirectory As String = IO.Path.GetDirectoryName(Config.UserConfigPath)
|
|
Return IO.Path.Combine(oDirectory, Filename)
|
|
End Function
|
|
|
|
Public Function GetGrid_LayoutName(pGridView As GridView) As String
|
|
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
|
|
Dim oDirectory As String = IO.Path.GetDirectoryName(Config.UserConfigPath)
|
|
Return IO.Path.Combine(oDirectory, Filename)
|
|
End Function
|
|
#End Region
|
|
|
|
Public Sub SetGroupPanelVisible(pVisible As Boolean)
|
|
For Each oView In GridViews
|
|
oView.OptionsView.ShowGroupPanel = pVisible
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetGroupPanelVisible() As Boolean
|
|
Dim oView = GridViews.First()
|
|
Return oView.OptionsView.ShowGroupPanel
|
|
End Function
|
|
|
|
Public Sub SetFilterRowVisible(pVisible As Boolean)
|
|
For Each oView In GridViews
|
|
oView.OptionsView.ShowAutoFilterRow = pVisible
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetFilterRowVisible() As Boolean
|
|
Dim oView = GridViews.First()
|
|
Return oView.OptionsView.ShowAutoFilterRow
|
|
End Function
|
|
|
|
Public Sub SetBandTitleVisible(pVisible As Boolean)
|
|
For Each oView In GridViews
|
|
DirectCast(oView, BandedGridView).OptionsView.ShowBands = pVisible
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetBandTitleVisible() As Boolean
|
|
Dim oView = GridViews.First()
|
|
Return DirectCast(oView, BandedGridView).OptionsView.ShowBands
|
|
End Function
|
|
|
|
End Class
|
|
|
|
|
|
|
|
|
|
End Namespace |