Imports System.Collections.ObjectModel Imports System.IO Imports EgtUILib Friend Module IniFile Public Enum ComboListResult As Integer MISTAKE = -1 NOTFOUND = 0 FOUND = 1 End Enum ' Path IniFile Friend m_sIniFile As String = String.Empty ' Path Compo.ini file Friend m_sCompoIniFile As String = String.Empty ' IniFile Public Function GetPrivateProfileInt(IpAppName As String, IpKeyName As String, nDefault As Integer) As Integer Return EgtUILib.GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sIniFile) End Function Public Function GetPrivateProfileDouble(IpAppName As String, IpKeyName As String, nDefault As Integer) As Double Return EgtUILib.GetPrivateProfileDouble(IpAppName, IpKeyName, nDefault, m_sIniFile) End Function Public Function GetPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sIniFile) End Function Public Function GetPrivateProfileColor(IpAppName As String, IpKeyName As String, ByRef Col As EgtUILib.EgtInterface.Color3d) As Boolean Return EgtUILib.GetPrivateProfileColor(IpAppName, IpKeyName, Col, m_sIniFile) End Function Public Function GetPrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean Return EgtUILib.GetPrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile) End Function Public Function GetPrivateProfileZoomWin(IpAppName As String, IpKeyName As String, ByRef bOutline As Boolean, ByRef Col As EgtUILib.EgtInterface.Color3d) As Boolean Return EgtUILib.GetPrivateProfileZoomWin(IpAppName, IpKeyName, bOutline, Col, m_sIniFile) End Function Public Function GetPrivateProfileFloatingWinPos(lpAppName As String, lpKeyName As String, ByRef nState As String, ByRef nIndex As Integer, ByRef nLeft As Integer, ByRef nTop As Integer) As Boolean Dim sVal As String = String.Empty GetPrivateProfileString(lpAppName, lpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() >= 4 Then nState = sItems(0) nIndex = CInt(sItems(1)) nLeft = CInt(sItems(2)) nTop = CInt(sItems(3)) Return True End If Return False End Function Public Function GetPrivateProfileLanguage(ByVal lpAppName As String, ByVal lpKeyName As String) As Language Dim sVal As String = String.Empty GetPrivateProfileString(lpAppName, lpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() = 2 Then Return New Language(sItems(0), sItems(1)) End If Return Nothing End Function Public Function WritePrivateProfileString(IpAppName As String, IpKeyName As String, ByRef IpString As String) As Boolean Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sIniFile) End Function Public Function WritePrivateProfileWinPos(IpAppName As String, IpKeyName As String, ByRef nFlag As Integer, ByRef nLeft As Integer, ByRef nTop As Integer, ByRef nWidth As Integer, ByRef nHeight As Integer) As Boolean Return EgtUILib.WritePrivateProfileWinPos(IpAppName, IpKeyName, nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile) End Function #Region "Old Function" ' Compo Public Function CompoGetPrivateProfileInt(IpAppName As String, IpKeyName As String, nDefault As Integer) As Integer Return EgtUILib.GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sCompoIniFile) End Function Public Function CompoGetPrivateProfileDouble(IpAppName As String, IpKeyName As String, nDefault As Integer) As Double Return EgtUILib.GetPrivateProfileDouble(IpAppName, IpKeyName, nDefault, m_sCompoIniFile) End Function Public Function CompoGetPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sCompoIniFile) End Function 'Funzione che gestisce il nome della componente Public Function CompoGetPrivateProfileNameGroup(IpAppName As String, IpKeyName As String, ByRef NameDDF As String, ByRef Name As String) As Boolean Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split("/".ToCharArray) If sItems.Count() = 2 Then If IsNumeric(sItems(1)) Then Name = EgtMsg(CInt(sItems(1))) Else Name = sItems(1) End If NameDDF = sItems(0) Else NameDDF = sItems(0) Name = sItems(0) Return True End If Return False End Function ' Funzione che legge valori TextBox Public Function CompoGetPrivateProfileTextBox(IpAppName As String, IpKeyName As String, ByRef DDFName As String, ByRef Name As String) As Boolean Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() >= 2 Then DDFName = sItems(0) If IsNumeric(sItems(1)) Then Name = EgtMsg(CInt(sItems(1))) Else Name = DDFName End If Return True End If Return False End Function ' Funzione che legge valori SpecialTextBox Public Function CompoGetPrivateProfileSpecialTextBox(IpAppName As String, IpKeyName As String, ByRef DDFName As String, ByRef Name As String, ByRef ComboIndex As Integer, ByRef SelComboItemList As List(Of String)) As Boolean Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() >= 2 Then DDFName = sItems(0) If IsNumeric(sItems(1)) Then Name = (EgtMsg(CInt(sItems(1)))) Else Name = DDFName End If If sItems.Count() >= 3 Then ComboIndex = CInt(sItems(2)) SelComboItemList = New List(Of String) For Index = 3 To sItems.Count() - 1 If IsNumeric(sItems(Index)) Then SelComboItemList.Add(EgtMsg(CInt(sItems(Index)))) Else SelComboItemList.Add(sItems(Index)) End If Next Return True End If End If Return False End Function ' Funzione che legge i valori della SwitchTextBox Public Function CompoGetPrivateProfileSwitchTextBox(IpAppName As String, IpKeyName As String, ByRef DDFName As List(Of String), ByRef Name As List(Of String), ByRef ComboIndex As Integer, ByRef SelComboItemList As List(Of String)) As Boolean Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() >= 2 Then DDFName(0) = sItems(0) If IsNumeric(sItems(1)) Then Name(0) = EgtMsg(CInt(sItems(1))) End If DDFName(1) = sItems(2) If IsNumeric(sItems(3)) Then Name(1) = EgtMsg(CInt(sItems(3))) End If If IsNumeric(sItems(4)) Then ComboIndex = (CInt(sItems(1))) End If If sItems.Count() >= 3 Then ComboIndex = CInt(sItems(2)) SelComboItemList = New List(Of String) For Index = 3 To sItems.Count() - 1 If IsNumeric(sItems(Index)) Then SelComboItemList.Add(EgtMsg(CInt(sItems(Index)))) Else SelComboItemList.Add(sItems(Index)) End If Next Return True End If End If Return False End Function ' Funzione che legge valori ComboBox Public Function CompoGetPrivateProfileComboBox(IpAppName As String, IpKeyName As String, ByRef DDFName As String, ByRef Name As String) As Boolean Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) If sItems.Count() >= 2 Then DDFName = sItems(0) If IsNumeric(sItems(1)) Then Name = EgtMsg(CInt(sItems(1))) Else Name = DDFName End If Return True End If Return False End Function ' Funzione che legge valori ComboBoxList Public Function CompoGetPrivateProfileComboBoxList(IpAppName As String, IpKeyName As String, ByRef ComboList As List(Of String), ByRef ComboListDDF As List(Of String)) As Integer Dim sVal As String = String.Empty CompoGetPrivateProfileString(IpAppName, IpKeyName, "", sVal) Dim sItems() As String = sVal.Split(",".ToCharArray) Dim ListType As Integer = 0 Dim ListPath As String = String.Empty If sItems.Count() >= 2 Then ListType = CInt(sItems(0)) If ListType = 0 Then ComboList = New List(Of String) ComboListDDF = New List(Of String) For Index = 1 To sItems.Count() - 1 Dim sItemsDDF() As String = sItems(Index).Split("/".ToCharArray) If sItemsDDF.Count() = 2 Then ComboListDDF.Add(sItemsDDF(0)) If IsNumeric(sItemsDDF(1)) Then ComboList.Add(EgtMsg(CInt(sItemsDDF(1)))) Else ComboList.Add(sItemsDDF(1)) End If Else ComboList.Add(sItemsDDF(0)) End If Next Else If Directory.Exists(sItems(1)) Then ListPath = sItems(1) ComboList = New List(Of String) OpenDirectory(ListPath, ComboList) Else MessageBox.Show(EgtMsg(ConstMsg.MSG_ERROR) & ListPath, EgtMsg(ConstMsg.MSG_ERROR + 1), MessageBoxButton.OK, MessageBoxImage.Error) ListPath = String.Empty ComboList = New List(Of String) Return ComboListResult.MISTAKE End If End If Return ComboListResult.FOUND End If Return ComboListResult.NOTFOUND End Function Friend Sub OpenDirectory(DirectoryPath As String, ByRef ComboList As List(Of String)) RecursiveOpenDirectory(DirectoryPath, ComboList, DirectoryPath) End Sub Friend Sub RecursiveOpenDirectory(DirectoryPath As String, ByRef ComboList As List(Of String), InitialDirectory As String) Dim SubDir() As String = Directory.GetDirectories(DirectoryPath) For Index = 0 To SubDir.Count - 1 RecursiveOpenDirectory(SubDir(Index), ComboList, InitialDirectory) Next Dim Files() As String = Directory.GetFiles(DirectoryPath) For Index = 0 To Files.Count - 1 Dim CurrFileExtension As String = Path.GetExtension(Files(Index)) If CurrFileExtension = ".lua" Or CurrFileExtension = ".nge" Then ComboList.Add(If(CurrFileExtension.ToLower = ".lua", Files(Index).Replace(CurrFileExtension, "").Replace(InitialDirectory & "\", ""), Files(Index).Replace(InitialDirectory & "\", ""))) End If Next End Sub #End Region ' Old Funtion ' Funzione che legge valori del file Config.ini passando la path del file da leggere Public Function GetPrivateProfileCompoName(IpAppName As String, IpKeyName As String, ByRef DDFName As String, ByRef Name As String, CompoIniPath As String) As Boolean Dim sVal As String = String.Empty ' Carico il valore della stringa nel parametro sVal EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sVal, CompoIniPath) Dim sItems() As String = sVal.Split("/"c) If sItems.Count() >= 2 Then DDFName = sItems(0) If IsNumeric(sItems(1)) Then Name = EgtMsg(CInt(sItems(1))) Else Name = DDFName End If Return True End If Return False End Function End Module ' Classe che identifica una lingua del programma con nome e path del file dei messaggi Public Class Language 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