Inizio gestione cambio configurazione

This commit is contained in:
NicolaP
2022-11-21 20:17:04 +01:00
parent 0e7764b9df
commit 5bf6b4acd4
5 changed files with 227 additions and 3 deletions
+91
View File
@@ -11,6 +11,10 @@ Friend Module OptionModule
Friend m_LanguageList As New ObservableCollection(Of Language)
Friend m_SelectedLanguage As Language
' Elenco delle MTable disponibili nella configurazione corrente
Friend m_MTableList As New ObservableCollection(Of MTable)
Friend m_SelectedMTable As MTable
Friend m_OptionLauncherList As New List(Of String)
Friend m_SelectedOptionLauncher As Integer = 0
Friend m_bLauncherOpenOnce As Boolean = False
@@ -391,6 +395,10 @@ Friend Module OptionModule
DefaultGetMmUnits(ConstCompo.S_GENERALINI, ConstCompo.K_MMUNITSINI, IsMM)
m_IsMM = IsMM
If GetCurrentMTableList() Then
' abilito la modifica della MTbale solo se Debug superioere a 5
End If
Dim Width As String = String.Empty
DefaultGetPrivateProfileString(S_SIZE_INI, K_WIDTH_INI, "32", Width)
Utility.ConvertCompoConfig(Width, 500)
@@ -1000,6 +1008,59 @@ Friend Module OptionModule
End If
End Function
Public Function GetCurrentMTableList() As Boolean
If String.IsNullOrEmpty(IniFile.m_sDoorsDirPath) Then Return False
m_MTableList.Clear()
Dim sMTableDir As String = IniFile.m_sDoorsDirPath & "\MTables"
Dim Items As String() = Directory.GetFiles(sMTableDir)
' recupero i file che hanno estemsione *.mtl
For Each MTableFile As String In Items
If MTableFile.EndsWith(".mtl") Then
Dim sName As String = Path.GetFileNameWithoutExtension(MTableFile).ToLower
Dim sPath As String = MTableFile
Dim bIsValid As Boolean = True
Dim ExcludeList As List(Of String) = GetExludeList()
For Each ExcludedItem As String In ExcludeList
If sName.ToLower.Contains(ExcludedItem) Then
bIsValid = False
Exit For
End If
Next
If bIsValid Then
sName = Path.GetFileNameWithoutExtension(MTableFile)
Dim LocalMTable As New MTable(sName.Trim, sPath.Trim)
m_MTableList.Add(LocalMTable)
End If
End If
Next
If m_MTableList.Count < 1 Then Return False
' leggo il nome della MTable attiva
Dim sSelectedMTable As String = String.Empty
Dim nbSelected As Boolean = False
If GetMainPrivateProfileString(S_DOORS, K_MTABLE, "", sSelectedMTable) <> 0 Then
For Each ItemFile As MTable In m_MTableList
If ItemFile.FilePath.ToLower = sSelectedMTable.Trim.ToLower Then
m_SelectedMTable = ItemFile
nbSelected = True
Exit For
End If
Next
End If
If Not nbSelected Then m_SelectedMTable = m_MTableList(0)
Return True
End Function
Private Function GetExludeList() As List(Of String)
Dim LocalList As New List(Of String)
Dim sVal As String = String.Empty
GetMainPrivateProfileString(S_DOORS, "Exclude", "", sVal)
Dim sItems As String() = sVal.Split(","c)
For Each Item As String In sItems
LocalList.Add(Item.Trim)
Next
Return LocalList
End Function
End Module
' Classe che identifica una lingua del programma con nome e path del file dei messaggi
@@ -1032,3 +1093,33 @@ Public Class Language
End Sub
End Class
Public Class MTable
Private m_sName As String
Private m_sFilePath As String
Public Property Name As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
End Set
End Property
Public Property FilePath As String
Get
Return m_sFilePath
End Get
Set(value As String)
m_sFilePath = value
End Set
End Property
Sub New(sName As String, sFilePath As String)
Me.Name = sName
Me.FilePath = sFilePath
End Sub
End Class