Imports System.IO Imports EgtWPFLib5 Imports EgtUILib Public Class MyMachine Inherits Machine Sub New(sDirPath As String, sIniPath As String) MyBase.New(sDirPath, sIniPath) End Sub Public Shared Shadows Function MachineListInit(sMachinesRootDir As String, MachineList As IList(Of Machine)) As Boolean ' Se direttorio base macchine non definito o non esiste, ritorno If String.IsNullOrWhiteSpace(sMachinesRootDir) OrElse Not Directory.Exists(sMachinesRootDir) Then MachineList = Nothing Return False End If ' Cerco le macchine Dim Machines As String() = Directory.GetDirectories(sMachinesRootDir) For i As Integer = 0 To Machines.Count - 1 Dim PathIni As String = Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini" If File.Exists(PathIni) Then Dim sMaterial As String = "" GetPrivateProfileString(S_GENERAL, "Material", "", sMaterial, Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini") If sMaterial = "Additive" Then MachineList.Add(New MyMachine(Machines(i), PathIni)) End If End If Next Return True End Function Friend Shared Function InsertMachine(sPath As String, MachineList As IList(Of Machine)) As Boolean ' Verifico presenza file caratteristici Dim sName As String = Path.GetFileName(sPath) Dim MachineIniPath As String = sPath & "\" & sName & ".ini" Dim MachineMldePath As String = sPath & "\" & sName & ".mlde" If Not File.Exists(MachineIniPath) Or Not File.Exists(MachineMldePath) Then Return False ' Cerco la posizione di inserimento Dim nPos As Integer = 0 For nI As Integer = 0 To MachineList.Count() - 1 Dim nRes As Integer = String.Compare(sName, MachineList(nI).Name, True) If nRes = 0 Then Return True ElseIf nRes < 0 Then Exit For Else nPos += 1 End If Next ' Inserisco nella lista MachineList.Insert(nPos, New MyMachine(sPath, MachineIniPath)) Return True End Function End Class