75faf31631
- escludo dalla lista dei template il file Matching.lua
175 lines
7.0 KiB
VB.net
175 lines
7.0 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Friend Module IniFile
|
|
|
|
Public Enum ComboListResult As Integer
|
|
MISTAKE = -1
|
|
NOTFOUND = 0
|
|
FOUND = 1
|
|
End Enum
|
|
|
|
' Livello dell'utilizzatore
|
|
Friend m_nUserLevel As Integer = 1
|
|
' Livello della chiave inserita nel PC
|
|
Friend m_nKeyLevel As Integer = 0
|
|
' Opzioni attive sulla chiave
|
|
Friend m_nKeyOptions As UInteger = 0
|
|
Friend Enum KEY_OPT As UInteger
|
|
BASE = 1
|
|
DOORS = 2
|
|
GUNSTOCK = 4
|
|
DOORCREATOR = 8
|
|
End Enum
|
|
|
|
' Path cartella Config
|
|
Friend m_sConfigDir As String = String.Empty
|
|
' Path IniFile
|
|
Friend m_sIniFile As String = String.Empty
|
|
' Path Temp directory
|
|
Friend m_sTempDir As String = String.Empty
|
|
' Path Compo.ini file
|
|
Friend m_DefaultIniFile As String = String.Empty
|
|
' Path MyProject directory
|
|
Friend m_MyProjectDir As String = String.Empty
|
|
' Path Template directory
|
|
Friend m_TemplateDir As String = String.Empty
|
|
' Path Compo directory
|
|
Friend m_CompoDir As String = String.Empty
|
|
' Path Help directory
|
|
Friend m_sHelpDir As String = String.Empty
|
|
' Path del file ddf --> nome file della porta corrente
|
|
Friend m_DDFFilePath As String = String.Empty
|
|
' Path Doors directory
|
|
Friend m_sDoorsDirPath As String = String.Empty
|
|
|
|
' IniFile
|
|
|
|
Public Function GetPrivateProfileLanguage(ByVal lpAppName As String, ByVal lpKeyName As String) As Language
|
|
Dim sVal As String = String.Empty
|
|
GetMainPrivateProfileString(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 DefaultGetPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer
|
|
Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_DefaultIniFile)
|
|
End Function
|
|
|
|
Public Function DefaultGetPrivateProfileList(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal List As List(Of String)) As Boolean
|
|
Dim sVal As String = String.Empty
|
|
DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
' se la lista ha almeno un elemento
|
|
If sItems.Count > 0 Then
|
|
For Index = 0 To sItems.Count() - 1
|
|
List.Add(Trim(sItems(Index)))
|
|
Next
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Function DefaultGetPrivateProfileObservableCollection(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal List As ObservableCollection(Of String)) As Boolean
|
|
Dim sVal As String = String.Empty
|
|
DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
' se la lista ha almeno un elemento
|
|
If sItems.Count > 0 Then
|
|
For Index = 0 To sItems.Count() - 1
|
|
List.Add(Trim(sItems(Index)))
|
|
Next
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Function DefaultGetPrivateProfilesMachining(ByVal lpAppName As String, ByVal lpKeyName As String, ByRef IpBoolean As Boolean) As Boolean
|
|
Dim sVal As String = String.Empty
|
|
DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
If String.Equals(Trim(sVal), "1") Then
|
|
IpBoolean = True
|
|
Else
|
|
IpBoolean = False
|
|
End If
|
|
Return IpBoolean
|
|
End Function
|
|
|
|
Public Function DefaultGetPrivateProfilesVisibility(ByVal lpAppName As String, ByVal lpKeyName As String, ByRef IpVisibility As Visibility) As Visibility
|
|
Dim sVal As String = String.Empty
|
|
DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
If String.Equals(Trim(sVal), "1") Then
|
|
IpVisibility = Visibility.Visible
|
|
Else
|
|
IpVisibility = Visibility.Collapsed
|
|
End If
|
|
Return IpVisibility
|
|
End Function
|
|
|
|
Public Function DefaultGetPrivateProfilesBevel(ByVal lpAppName As String, ByVal lpKeyName As String, ByRef IpBoolean As Visibility) As Visibility
|
|
Dim sVal As String = String.Empty
|
|
DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
If String.Equals(Trim(sVal), "1") Then
|
|
IpBoolean = Visibility.Visible
|
|
Else
|
|
IpBoolean = Visibility.Collapsed
|
|
End If
|
|
Return IpBoolean
|
|
End Function
|
|
|
|
Public Function DefaultWritePrivateProfileString(IpAppName As String, IpKeyName As String, ByRef IpString As String) As Boolean
|
|
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_DefaultIniFile)
|
|
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
|
|
If Not Files(Index).Contains("Matching.lua") Then
|
|
ComboList.Add(If(CurrFileExtension.ToLower = ".lua", Files(Index).Replace(CurrFileExtension, "").Replace(InitialDirectory & "\", ""), Files(Index).Replace(InitialDirectory & "\", "")))
|
|
End If
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' 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
|
|
|
|
Public Function GetPrivateProfileJambSide(IpAppName As String, IpKeyName As String, ByRef Side 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)
|
|
Side = sVal
|
|
Return True
|
|
End Function
|
|
|
|
End Module
|