diff --git a/HardwareManager/Hardware.vb b/HardwareManager/Hardware.vb index 35ab20c..cade418 100644 --- a/HardwareManager/Hardware.vb +++ b/HardwareManager/Hardware.vb @@ -739,14 +739,15 @@ Public Class Hardware Dim nIsActiveMaterial As Integer = 3 Dim bIsCurrentMaterial As Boolean = True StdTemplateGetPrivateProfileListMaterial(S_CHAPTER & ChapterIndex, K_MATERIAL, sMaterialList, nIsActiveMaterial) - For Each ItemMaterial In sMaterialList - bIsCurrentMaterial = False - Dim ArrayItemMaterial As String() = ItemMaterial.Split("/"c) - If Trim(ArrayItemMaterial(0)) = Trim(Map.refHardwarePageVM.GenericPart.SelectedMaterial.NameDDF) Then - bIsCurrentMaterial = True - Exit For - End If - Next + 'For Each ItemMaterial In sMaterialList + ' bIsCurrentMaterial = False + ' Dim ArrayItemMaterial As String() = ItemMaterial.Split("/"c) + ' If Trim(ArrayItemMaterial(0)) = Trim(Map.refHardwarePageVM.GenericPart.SelectedMaterial.NameDDF) Then + ' bIsCurrentMaterial = True + ' Exit For + ' End If + 'Next + IsCurrentMaterial(sMaterialList, bIsCurrentMaterial) If Not bIsCurrentMaterial And nIsActive <> 4 Then nIsActive = nIsActiveMaterial @@ -793,6 +794,18 @@ Public Class Hardware Dim NewParam As New CompoParam(m_HardwareGeneral.DDFName, m_HardwareGeneral.Name, Chapter) Dim sHelpParam As String = String.Empty EgtUILib.GetPrivateProfileString(S_CHAPTER & ChapterIndex, "HelpParam" & ParamIndex, "", sHelpParam, m_StdTemplate) + ' verifico se il materiale corrente deve essere visualizzato in funzione del materiale associato al parametro + Dim sMaterialParam As String = String.Empty + Dim MaterialParamList As New List(Of String) + Dim bIsCurrentMaterialParam As Boolean = True + Dim sDefaultGhostValue As String = "" + StdTemplateGetPrivateProfileListMaterialParam(S_CHAPTER & ChapterIndex, "MaterialParam" & ParamIndex, MaterialParamList, sDefaultGhostValue) + IsCurrentMaterial(MaterialParamList, bIsCurrentMaterialParam) + If Not bIsCurrentMaterialParam Then + ' trasformo il parametro in Ghost + TrasformCurrParamInGhost(sParam, sDefaultGhostValue) + End If + ' leggo il tipo di parametro, se la lettura va a buon fine la carico If Chapter.ReadParamHardware(sParam, sHelpParam, NewParam, ErrorReading) Then Chapter.CompoParamList.Add(NewParam) If TypeOf NewParam Is TextBoxOnOffParam Then @@ -834,6 +847,29 @@ Public Class Hardware End If End Sub + ' recupera il l'elenco dei materiali indicati nella stringa e verifica se nell'elenco รจ presente il materiale attivo nella porta + Private Sub IsCurrentMaterial(sMaterialList As List(Of String), ByRef bIsCurrentMaterial As Boolean) + For Each ItemMaterial In sMaterialList + bIsCurrentMaterial = False + Dim ArrayItemMaterial As String() = ItemMaterial.Split("/"c) + If Trim(ArrayItemMaterial(0)) = Trim(Map.refHardwarePageVM.GenericPart.SelectedMaterial.NameDDF) Then + bIsCurrentMaterial = True + Exit For + End If + Next + End Sub + + Private Sub TrasformCurrParamInGhost(ByRef sParamLine As String, ByVal sDefaultValue As String) + ' separo la stringa + Dim sItems As String() = sParamLine.Split(";"c) + If sItems.Count > 2 Then + sItems(0) = "Ghost" + sItems(2) = sDefaultValue + End If + ' riassemblo la stringa iniziale + sParamLine = Trim(sItems(0)) & "; " & Trim(sItems(1)) & "; " & Trim(sItems(2)) + End Sub + ' carico la liste dei nomi dei capitoli Private Function SetGroupChaptername(sName As String) As Boolean If m_GroupChapterName.Count = 0 Then m_GroupChapterName.Add(sName) diff --git a/IniFile.vb b/IniFile.vb index 5e4f4c2..36dc6ca 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -59,6 +59,8 @@ Friend Module IniFile Friend m_sListLabelCurrent As String = String.Empty ' Path dell'eseguibile Cam5 Friend m_sEgtCameEXEPath As String = String.Empty + ' Path LuaLibs Dir + Friend m_sLuaLibsDir As String = String.Empty ' EgtDoorCreator.ini Public Function GetPrivateProfileLanguage(ByVal lpAppName As String, ByVal lpKeyName As String) As Language @@ -289,6 +291,27 @@ Friend Module IniFile Return True End Function + ' restituisce l'elenco dei materiali ed eventualmente il valore di default da associare al parametro Ghost che viene generato in sostituzione del parametro letto + Public Function StdTemplateGetPrivateProfileListMaterialParam(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal List As List(Of String), ByRef sDefaultParam As String) As Boolean + Dim sVal As String = String.Empty + StdTemplateGetPrivateProfileString(lpAppName, lpKeyName, "", sVal) + If String.IsNullOrEmpty(sVal) Then Return False + Dim sItems() As String = sVal.Split(",".ToCharArray) + ' se la lista ha almeno due elementi + If sItems.Count > 1 Then + For Index = 0 To sItems.Count() - 2 + List.Add(Trim(sItems(Index))) + Next + End If + ' se la lista ha un solo elemento, oppure ha un solo elemento + Dim LastItems As String() = sItems.Last.Split(";"c) + List.Add(Trim(LastItems(0))) + If LastItems.Count > 1 Then + sDefaultParam = Trim(LastItems(1)) + End If + Return True + End Function + Public Function StdTemplateGetPrivateProfileChapterName(ByVal lpAppName As String, ByVal lpKeyName As String, ByRef sValueLua As String, ByRef sValue As String) As Boolean Dim sVal As String = String.Empty StdTemplateGetPrivateProfileString(lpAppName, lpKeyName, "", sVal) diff --git a/MainWindow/MainWindowModel.vb b/MainWindow/MainWindowModel.vb index 12d8b55..34b4756 100644 --- a/MainWindow/MainWindowModel.vb +++ b/MainWindow/MainWindowModel.vb @@ -96,6 +96,7 @@ Friend Class MainWindowModel Dim sLuaLibsDir As String = String.Empty GetMainPrivateProfileString(S_LUA, K_LIBSDIR, "", sLuaLibsDir) EgtSetLuaLibs(sLuaLibsDir) + IniFile.m_sLuaLibsDir = sLuaLibsDir Dim sLuaBaseLib As String = String.Empty GetMainPrivateProfileString(S_LUA, K_BASELIB, "EgtBase", sLuaBaseLib) EgtLuaRequire(sLuaBaseLib) diff --git a/OptionsWindow/OptionModule.vb b/OptionsWindow/OptionModule.vb index 095e3ba..bbbe75f 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -1065,7 +1065,7 @@ Friend Module OptionModule Public Sub GetCurrentMachineInMTable() ' aggiorno il file Config.ini dell'EgtCAM5 - EgtLuaExecFile(IniFile.m_sConfigDir & "\ChangeConfig.lua") + EgtLuaExecFile(IniFile.m_sLuaLibsDir & "\ChangeConfig.lua") ' assegno variabili Dim sDir As String = IniFile.m_sDoorsDirPath.Replace("\", "/") EgtLuaSetGlobStringVar("CCD.NewBaseDir", sDir) diff --git a/OptionsWindow/OptionsViewModel.vb b/OptionsWindow/OptionsViewModel.vb index 8d5d3c9..89e1ada 100644 --- a/OptionsWindow/OptionsViewModel.vb +++ b/OptionsWindow/OptionsViewModel.vb @@ -122,7 +122,7 @@ Public Class OptionsVM Public ReadOnly Property EnableConfig As Boolean Get - If GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) > 4 And File.Exists(IniFile.m_sConfigDir & "\ChangeConfig.lua") Then + If GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) > 4 And File.Exists(IniFile.m_sLuaLibsDir & "\ChangeConfig.lua") Then Return True Else Return False @@ -2045,7 +2045,7 @@ Public Class OptionsVM If m_IsChangedConfig AndAlso EnableConfig AndAlso m_OrigBaseDir <> IniFile.m_sDoorsDirPath AndAlso m_OrigMTable <> OptionModule.m_SelectedMTable.Name Then ' aggiorno il file Config.ini dell'EgtCAM5 - EgtLuaExecFile(IniFile.m_sConfigDir & "\ChangeConfig.lua") + EgtLuaExecFile(IniFile.m_sLuaLibsDir & "\ChangeConfig.lua") ' assegno variabili EgtLuaSetGlobStringVar("CCD.NewBaseDir", IniFile.m_sDoorsDirPath) EgtLuaSetGlobStringVar("CCD.NewMTable", OptionModule.m_SelectedMTable.Name)