88 lines
2.9 KiB
VB.net
88 lines
2.9 KiB
VB.net
Imports EgtWPFLib5
|
|
|
|
Public Module Configuration
|
|
|
|
''' <summary>
|
|
''' Flag per impostare la visualizzazione con la singola pagina
|
|
''' </summary>
|
|
Private m_bOnlyProd As Boolean
|
|
Public ReadOnly Property bOnlyProd As Boolean
|
|
Get
|
|
Return m_bOnlyProd
|
|
End Get
|
|
End Property
|
|
Public Sub SetOnlyProd(value As Boolean)
|
|
m_bOnlyProd = value
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Flag per visualizzare il pulsante Db Attrezzaggi
|
|
''' </summary>
|
|
Private m_bModifySetup As Boolean
|
|
Public ReadOnly Property bModifySetup As Boolean
|
|
Get
|
|
Return m_bModifySetup
|
|
End Get
|
|
End Property
|
|
Public Sub SetModifySetup(value As Boolean)
|
|
m_bModifySetup = value
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Flag per salvare correttamente i dati nel file lua corretto
|
|
''' </summary>
|
|
Private m_bMachConfig As Boolean
|
|
Public ReadOnly Property bMachConfig As Boolean
|
|
Get
|
|
Return m_bMachConfig
|
|
End Get
|
|
End Property
|
|
Public Sub SetMachConfig(value As Boolean)
|
|
m_bMachConfig = value
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che recupera la directory del file INI
|
|
''' </summary>
|
|
Public Sub GetIniFileDirectory()
|
|
' Impostazione path radice per i dati
|
|
Dim m_sDataRoot As String = System.AppDomain.CurrentDomain.BaseDirectory
|
|
If EgtUILib.GetPrivateProfileString(ConstGen.S_DATA, ConstGen.K_DATAROOT, "", m_sDataRoot, m_sDataRoot & "\" & ConstGen.DAT_FILE_NAME) = 0 Then
|
|
m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory
|
|
End If
|
|
' Impostazione direttorio di configurazione
|
|
Dim m_sConfigDir As String = m_sDataRoot & "\" & ConstGen.CONF_DIR
|
|
' Impostazione path Ini file
|
|
IniFile.m_sIniFile = m_sConfigDir & "\" & Core.ConstIni.INI_FILE_NAME
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione per recuperare bOnlyProd
|
|
''' </summary>
|
|
''' <param name="Section">Sezione dove si trova la variabile che devo cercare</param>
|
|
''' <param name="Key">Variabile che sto cercando</param>
|
|
''' <param name="Path">Cartella dove e' presente il file ini</param>
|
|
''' <param name="Default_Value">Valore di defaul opzionabile</param>
|
|
''' <returns></returns>
|
|
Public Function Read_Value(Section As String, Key As String, Path As String, Optional Default_Value As String = "") As String
|
|
Dim Reader_Lines As String() = System.IO.File.ReadAllLines(Path)
|
|
Dim Current_Section As String = ""
|
|
|
|
For Each Reader_Line As String In Reader_Lines
|
|
|
|
If Reader_Line.StartsWith("[") AndAlso Reader_Line.EndsWith("]") Then
|
|
Current_Section = Reader_Line
|
|
ElseIf Current_Section.Equals($"[{Section}]") Then
|
|
Dim lineParts As String() = Reader_Line.Split({"="c}, 2)
|
|
|
|
If lineParts.Length >= 1 AndAlso lineParts(0) = Key Then
|
|
Return If(lineParts.Length >= 2, lineParts(1), Default_Value)
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Return Default_Value
|
|
End Function
|
|
|
|
End Module
|