EgtDoorCreator :
- sistemata scrittura nell'ini della MTable corrente - aggiunta gestione configurazione hardware custom con file luae - WriteFile di Hardware rinominata ReadFile perchè legge un file.
This commit is contained in:
@@ -481,11 +481,12 @@ Public Class Hardware
|
||||
Return True
|
||||
End Function
|
||||
|
||||
' elimina il file temporaneo CurrHardware.lua
|
||||
' elimina il file temporaneo CurrHardware.lua (se esiste anche CurrHardware.luae)
|
||||
Public Function DeleteTempFile() As Boolean
|
||||
If String.IsNullOrWhiteSpace(CurrHardwareFilePath) Then Return False
|
||||
Try
|
||||
File.Delete(CurrHardwareFilePath)
|
||||
if File.Exists(CurrHardwareFilePath & "e") Then File.Delete(CurrHardwareFilePath & "e")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
Return True
|
||||
@@ -1600,7 +1601,7 @@ Public Class Hardware
|
||||
bNewHardware = False
|
||||
Dim ErrorMsg As String = String.Empty
|
||||
Dim NewFileContent As New ObservableCollection(Of String)
|
||||
If Not WriteFile(NewFileContent) Then Return False
|
||||
If Not ReadFile(NewFileContent) Then Return False
|
||||
|
||||
' scrivo tutto sul file corrente
|
||||
Try
|
||||
@@ -1790,19 +1791,20 @@ Public Class Hardware
|
||||
Map.refHardwarePageVM.GenericPart.CompoList.Clear()
|
||||
If String.IsNullOrWhiteSpace(Map.refHardwarePageVM.CurrHardware.SelTemplate) Then Return False
|
||||
Dim NewFileContent As New ObservableCollection(Of String)
|
||||
If Not WriteFile(NewFileContent) Then Return False
|
||||
If Not ReadFile(NewFileContent) Then Return False
|
||||
' costruisco il nome del percorso del file corrente
|
||||
Dim ModelDir As String = String.Empty
|
||||
' costruisco il percorso del file temporaneo nella cartella corrente:
|
||||
Dim CurrDirectoryInModelDir As String = Path.GetDirectoryName(Map.refHardwarePageVM.CurrHardware.SelTemplate)
|
||||
CurrDirectoryInModelDir = Trim(CurrDirectoryInModelDir.Replace(m_HardwareGeneral.Path, ""))
|
||||
'If m_SelBrand.ModelDir <> RegexFunction.ModelTemplate(m_HardwareGeneral.Path) Then ModelDir = m_SelBrand.ModelDirGraphic & "\"
|
||||
If m_SelBrand.ModelDir <> m_HardwareGeneral.Path Then ModelDir = m_SelBrand.ModelDirGraphic & "\"
|
||||
If Not String.IsNullOrWhiteSpace(CurrDirectoryInModelDir) Then ModelDir = ModelDir & CurrDirectoryInModelDir & "\"
|
||||
Dim sTempFileHardw As String = m_HardwareGeneral.Path & "\" & ModelDir & TEMP_FILE_HARDWARE
|
||||
' salvo il file
|
||||
File.WriteAllLines(sTempFileHardw, NewFileContent)
|
||||
'LoadSwingFromTemplate()
|
||||
' salvo eventuale file associato luae
|
||||
Dim sLuaeFile As String = m_HardwareGeneral.Path & "\" & ModelDir & Map.refHardwarePageVM.CurrHardware.SelTemplate & ".luae"
|
||||
If File.Exists(sLuaeFile) Then File.Copy(sLuaeFile, sTempFileHardw & "e")
|
||||
' aggiungo la componente
|
||||
Map.refHardwarePageVM.GenericPart.AddNewHardware(m_HardwareGeneral, ModelDir & Path.GetFileNameWithoutExtension(TEMP_FILE_HARDWARE))
|
||||
CurrHardwareFilePath = sTempFileHardw
|
||||
@@ -1819,7 +1821,7 @@ Public Class Hardware
|
||||
If Not File.Exists(TemplFile) Then Return False
|
||||
Dim FileContent() As String = File.ReadAllLines(TemplFile)
|
||||
Dim NewFileContent As New ObservableCollection(Of String)
|
||||
If Not WriteFile(NewFileContent) Then Return False
|
||||
If Not ReadFile(NewFileContent) Then Return False
|
||||
' costruisco il nome del percorso del file corrente
|
||||
Dim CurrConfig As String = m_HardwareGeneral.Path & "\" & CONFIGINI_FILE_NAME
|
||||
Dim CurrItemPath As String = CurrPath()
|
||||
@@ -1831,7 +1833,7 @@ Public Class Hardware
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function WriteFile(ByRef NewFileContent As ObservableCollection(Of String)) As Boolean
|
||||
Private Function ReadFile(ByRef NewFileContent As ObservableCollection(Of String)) As Boolean
|
||||
For IndexName As Integer = 0 To m_GroupChapterName.Count - 1
|
||||
CascadedChapter(m_GroupChapters, m_GroupChapterName(IndexName))
|
||||
Next
|
||||
|
||||
@@ -2079,6 +2079,7 @@ Public Class OptionsVM
|
||||
Dim sVal As String = ""
|
||||
EgtLuaGetGlobStringVar("CCD.NewMachineName", sVal)
|
||||
OptionModule.m_CurrentMachine = sVal
|
||||
WriteMainPrivateProfileString(S_DOORS, K_MTABLE, OptionModule.m_SelectedMTable.FilePath)
|
||||
EgtLuaResetGlobVar("CCD")
|
||||
' chiudo il programma e lo riavvio
|
||||
Map.refMainWindowVM.CloseApplication()
|
||||
@@ -2095,6 +2096,7 @@ Public Class OptionsVM
|
||||
Dim sVal As String = ""
|
||||
EgtLuaGetGlobStringVar("CCD.NewMachineName", sVal)
|
||||
OptionModule.m_CurrentMachine = sVal
|
||||
WriteMainPrivateProfileString(S_DOORS, K_MTABLE, OptionModule.m_SelectedMTable.FilePath)
|
||||
EgtLuaResetGlobVar("CCD")
|
||||
End If
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user