74 lines
3.0 KiB
VB.net
74 lines
3.0 KiB
VB.net
Imports System.IO
|
|
Imports DevExpress.XtraGrid.Views.Base
|
|
|
|
''' <summary>
|
|
''' Helper Class to save DevExpress layouts
|
|
'''
|
|
''' Example:
|
|
'''
|
|
''' Layout 1 (for frmMain)
|
|
''' ----------------------------------------------
|
|
''' | Component 1 Component 2 |
|
|
''' | |-------------| |----------------| |
|
|
''' | | MainGrid | | DocumentGrid | |
|
|
''' | |-------------| |----------------| |
|
|
''' | |
|
|
''' |---------------------------------------------
|
|
''' </summary>
|
|
Public Class ClassLayout
|
|
Public Enum GroupName
|
|
LayoutMain
|
|
LayoutUserManager
|
|
End Enum
|
|
|
|
Public Enum LayoutComponent
|
|
DockManager
|
|
DocumentManager
|
|
End Enum
|
|
|
|
''' <summary>
|
|
''' Returns a path for the chosen Devexpress layout file
|
|
''' </summary>
|
|
''' <param name="Group">The Group to which the the component belongs to. For example, a form could be a Layout</param>
|
|
''' <param name="Component">The component to which the layout belongs to</param>
|
|
''' <returns></returns>
|
|
Public Shared Function GetLayoutPath(Group As GroupName, Component As LayoutComponent) As String
|
|
Dim oFileName As String = $"{Group.ToString}-{Component.ToString}.xml"
|
|
Return Path.Combine(GetLayoutDirectory(), oFileName)
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Returns a path for the chosen Devexpress layout file
|
|
''' </summary>
|
|
''' <param name="Group">The Group to which the the component belongs to. For example, a form could be a Layout</param>
|
|
''' <param name="Component">The component to which the layout belongs to</param>
|
|
''' <returns></returns>
|
|
Public Shared Function GetLayoutPath(Group As GroupName, Component As String) As String
|
|
Dim oFileName As String = $"{Group.ToString}-{Component}.xml"
|
|
Return Path.Combine(GetLayoutDirectory(), oFileName)
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Returns a path for the chosen Devexpress layout file
|
|
''' </summary>
|
|
''' <param name="Group">The Group to which the the component belongs to. For example, a form could be a Layout</param>
|
|
''' <param name="Component">The component to which the layout belongs to</param>
|
|
''' <param name="SubComponent">The sub component under the component</param>
|
|
''' <returns></returns>
|
|
Public Shared Function GetLayoutPath(Group As GroupName, Component As String, SubComponent As String) As String
|
|
Dim oFileName As String = $"{Group.ToString}-{Component}-{SubComponent}.xml"
|
|
Return Path.Combine(GetLayoutDirectory(), oFileName)
|
|
End Function
|
|
|
|
Public Shared Function GetLayoutDirectory() As String
|
|
Return Path.Combine(GetAppDataFolder(), ClassConstants.FOLDER_NAME_LAYOUT)
|
|
End Function
|
|
|
|
Private Shared Function GetAppDataFolder() As String
|
|
Dim oLocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
|
|
Dim oProduct = My.Application.Info.ProductName
|
|
Dim oCompany = My.Application.Info.CompanyName
|
|
Return Path.Combine(oLocalAppData, oCompany, oProduct)
|
|
End Function
|
|
End Class
|