1158fa4d9f
- modifiche e migliorie varie.
1094 lines
58 KiB
VB.net
1094 lines
58 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports System.Text.RegularExpressions
|
|
|
|
Friend Module DdfFile
|
|
|
|
' il vettore che conterrà tutti le linee del file DDF da leggere
|
|
Private FileContent As String()
|
|
' lista ordinata delle componenti da stampare
|
|
Friend CompoListOrder As New List(Of String)
|
|
Friend UnitMeasure As String
|
|
|
|
''#Region "LETTURA DDF"
|
|
'' ' Genero una nuova porta da usare nella lettura di un DDF
|
|
'' Dim m_Door As New Door
|
|
'' ' Leggo e stampo a video
|
|
'' Public Sub ReadDDF(sPathDDF As String, ByRef ReadDoor As Door)
|
|
'' m_Door = ReadDoor
|
|
'' ' restituisce un problema nella lettura di un valore della compo
|
|
'' Dim InvalidValue As String = String.Empty
|
|
'' ' controllo se esite il file DDF
|
|
'' If Not File.Exists(sPathDDF) Then Return
|
|
'' FileContent = File.ReadAllLines(sPathDDF)
|
|
'' ' se il file esiste ma è vuoto
|
|
'' If FileContent.Count = 0 Then
|
|
'' MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
'' End If
|
|
'' ' leggo riga per riga
|
|
'' For LineIndex As Integer = 0 To FileContent.Count - 1
|
|
|
|
'' ' pulisco dai commenti
|
|
'' ' FileContent(LineIndex) = FindComments(FileContent(LineIndex))
|
|
|
|
'' ' Leggo le unità di misura
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_MEASURES) Then
|
|
'' LineIndex = GetMeasure(LineIndex)
|
|
'' ' se manca una parola chiave nel DDF
|
|
'' If LineIndex = -1 Then
|
|
'' ' carico il messaggio di errore
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_MEASURES + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' ' interrompo la lettura del file
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' Leggo il codice
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_CODE) Then
|
|
'' LineIndex = GetCode(LineIndex)
|
|
'' ' se manca una parola chiave nel DDF
|
|
'' If LineIndex = -1 Then
|
|
'' ' carico il messaggio di errore
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_CODE + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' ' interrompo la lettura del file
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' Leggo il ordine
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), S_ORDER) Then
|
|
'' LineIndex = GetOrder(LineIndex + 1)
|
|
'' ' se manca una parola chiave nel DDF
|
|
'' If LineIndex = -1 Then
|
|
'' ' carico il messaggio di errore
|
|
'' InvalidValue += String.Format(EgtMsg(50102), S_ORDER + vbCrLf)
|
|
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' ' interrompo la lettura del file
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' Leggo la data
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_DATE) Then
|
|
'' LineIndex = GetDate(LineIndex)
|
|
'' ' se manca una parola chiave nel DDF
|
|
'' If LineIndex = -1 Then
|
|
'' ' carico il messaggio di errore
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_DATE + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' ' interrompo la lettura del file
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' size
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_SIZE) Then
|
|
'' LineIndex = GetSize(LineIndex + 1)
|
|
'' ' se manca una parola chiave nel DDF
|
|
'' If LineIndex = -1 Then
|
|
'' ' carico il messaggio di errore
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_SIZE + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' ' interrompo la lettura del file
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' swing
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_SWING) Then
|
|
'' LineIndex = GetSwing(LineIndex)
|
|
'' If LineIndex = -1 Then
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_SWING + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
'' ' profiles
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' If SearchKey(FileContent(LineIndex), K_PROFILES) Then
|
|
'' LineIndex = GetProfiles(LineIndex + 1)
|
|
'' If LineIndex = -1 Then
|
|
'' InvalidValue += String.Format(EgtMsg(50102), K_PROFILES + vbCrLf)
|
|
'' ' assegno una porta vuota ed esco dal ciclo
|
|
'' ReadDoor = Nothing
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
|
|
'' ' Compo
|
|
'' ' siccome dopo ogni lettura restituisco la riga successiva: controllo che veramente esiste nel file
|
|
'' If LineIndex < FileContent.Count - 1 Then
|
|
'' ' se trovo un nome seguito dai due punti
|
|
'' If Not String.IsNullOrWhiteSpace(SearchName(FileContent(LineIndex))) Then
|
|
'' ' carivo la stringa letta come nome DDF
|
|
'' Dim CompoNameDDF = SearchName(FileContent(LineIndex))
|
|
'' ' passo la riga successiva e il nome DDF alla funzione che controlla se esiste la compo e restituisce la riga successiva
|
|
'' LineIndex = GetNewCompo(LineIndex + 1, CompoNameDDF, InvalidValue)
|
|
'' ' se restituisco una riga scommentata ma non interpretabile
|
|
'' ElseIf Not String.IsNullOrWhiteSpace(FindComments(FileContent(LineIndex))) Then
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50130), LineIndex)
|
|
'' End If
|
|
'' Else
|
|
'' Exit For
|
|
'' End If
|
|
|
|
'' Next
|
|
'' ' quando finisce la lettura di tutte le righe esci dal ciclo
|
|
'' If Not String.IsNullOrWhiteSpace(InvalidValue) Then
|
|
'' MessageBox.Show(InvalidValue, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
'' End If
|
|
'' End Sub
|
|
|
|
'' ' restituice la riga scommentata
|
|
'' Public Function FindComments(sLine As String) As String
|
|
'' ' se non trovo un commento nella riga
|
|
'' If String.IsNullOrWhiteSpace(SearchComments(sLine)) Then
|
|
'' If sLine = "#" Then
|
|
'' ' se trovo solo il simbolo di commento senza un commento allora restituisco una riga vuota
|
|
'' Return String.Empty
|
|
'' Else
|
|
'' ' restituisco la riga stessa
|
|
'' Return sLine
|
|
'' End If
|
|
'' Else
|
|
'' ' altrimenti restituisci la riga che precede il commento
|
|
'' Dim x As String = SearchStringBeforeComments(sLine)
|
|
'' Return SearchStringBeforeComments(sLine)
|
|
'' End If
|
|
'' End Function
|
|
|
|
'' ' restituisce il valore della stringa che precede i due punti
|
|
'' Friend Function SearchName(sLine As String) As String
|
|
'' Return Regex.Match(FindComments(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value
|
|
'' End Function
|
|
|
|
'' ' restituisce il trattino
|
|
'' Friend Function Score(sLine As String) As String
|
|
'' Return Regex.Match(FindComments(sLine), "\s*(-)*\s*(.*?\b)\s*:.*").Groups(1).Value
|
|
'' End Function
|
|
|
|
'' ' Cerca la stringa con il trattino
|
|
'' Friend Function SearchScore(sLine As String) As Boolean
|
|
'' If Regex.Match(FindComments(sLine), "\s*(-).*$").Groups(1).Value = "-" Then Return True
|
|
'' Return False
|
|
'' End Function
|
|
|
|
'' ' restituisce il nome compreso tra il trattino meno e i due punti
|
|
'' Friend Function SearchTemplate(sLine As String) As String
|
|
'' Return Regex.Match(FindComments(sLine), "\s*-*\s*(.*?\b)\s*:.*$").Groups(1).Value
|
|
'' End Function
|
|
|
|
'' ' restituisce la stringa dopo i due punti
|
|
'' Friend Function SearchKeyValue(sLine As String, sKey As String) As String
|
|
'' Dim x = Regex.Match(FindComments(sLine), "\s*-*\s*" & sKey & "\s*:\s*(.*?\b)\s*$").Groups(1).Value
|
|
'' Return Regex.Match(FindComments(sLine), "\s*-*\s*" & sKey & "\s*:\s*(.*?\b)\s*$").Groups(1).Value
|
|
'' End Function
|
|
|
|
'' ' cerca il nome che precede i due punti
|
|
'' Friend Function SearchKey(sLine As String, sKey As String) As Boolean
|
|
'' Dim x = FindComments(sLine)
|
|
'' If Not Regex.Match(FindComments(sLine), "\s*(" & sKey & ")\s*:.*$").Groups(1).Value = sKey Then Return False
|
|
'' Return True
|
|
'' End Function
|
|
|
|
''#Region "Carica il General della porta"
|
|
'' ' Leggo l'unità di misura
|
|
'' Public Function GetMeasure(Index As Integer) As Integer
|
|
'' Dim Measure As String = SearchKeyValue(FileContent(Index), K_MEASURES)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(Measure) Then
|
|
'' ' assegno la riga successiva
|
|
'' Index += 1
|
|
'' ' assegna il valore di default caricato nell'OptionModule
|
|
'' If String.Equals(Trim(UnitMeasure), "0") Then
|
|
'' ' converto il valore intero del file config.ini in stringa
|
|
'' m_Door.Measure = "inches"
|
|
'' Else
|
|
'' m_Door.Measure = "mm"
|
|
'' End If
|
|
'' Else
|
|
'' ' carico il valore nella porta corrente
|
|
'' m_Door.Measure = Measure
|
|
'' ' passo alla riga successiva
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' Leggo il codice
|
|
'' Public Function GetCode(Index As Integer) As Integer
|
|
'' Dim Code As String = SearchKeyValue(FileContent(Index), K_CODE)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(Code) Then
|
|
'' ' assegno la riga successiva
|
|
'' Index += 1
|
|
'' ' assegna il valore di default caricato nell'OptionModule
|
|
'' m_Door.Code = "124-AA-657"
|
|
'' Else
|
|
'' m_Door.Code = Code
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' Leggo valori di Order
|
|
'' Public Function GetOrder(ByRef Index As Integer) As Integer
|
|
'' Dim ExitOrder As Integer = 0
|
|
'' Dim Customer As String = SearchKeyValue(FileContent(Index), K_CUSTOMER)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(Customer) Then
|
|
'' ' se non c'è la parola chiave allora esci
|
|
'' If Not SearchKey(FileContent(Index), K_CUSTOMER) Then ExitOrder = -1
|
|
'' ' altrimenti lascia il valore vuoto
|
|
'' Index += 1
|
|
'' Else
|
|
'' ' carico il valore nella porta corrente
|
|
'' m_Door.Customer = Customer
|
|
'' ' passo alla riga successiva
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim Elevation As String = SearchKeyValue(FileContent(Index), K_ELEVATION)
|
|
'' If String.IsNullOrWhiteSpace(Elevation) Then
|
|
'' If Not SearchKey(FileContent(Index), K_ELEVATION) Then ExitOrder = -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.Elevation = Elevation
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim Project As String = SearchKeyValue(FileContent(Index), K_PROJECT)
|
|
'' If String.IsNullOrWhiteSpace(Project) Then
|
|
'' If Not SearchKey(FileContent(Index), K_PROJECT) Then ExitOrder = -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.Project = Project
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim PO As String = SearchKeyValue(FileContent(Index), K_PO)
|
|
'' If String.IsNullOrWhiteSpace(PO) Then
|
|
'' If Not SearchKey(FileContent(Index), K_PO) Then ExitOrder = -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.PO = PO
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim Line As String = SearchKeyValue(FileContent(Index), K_LINE)
|
|
'' If String.IsNullOrWhiteSpace(Line) Then
|
|
'' If Not SearchKey(FileContent(Index), K_LINE) Then ExitOrder = -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.Line = Line
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return SkipOrder(FileContent, Index, ExitOrder)
|
|
'' End Function
|
|
|
|
'' Private Function SkipOrder(Array() As String, ByRef Index As Integer, ExitOrder As Integer) As Integer
|
|
'' ' se trovo un problema nella lettura dell'ordine allora la funzione GetOrder restituisce -1
|
|
'' If ExitOrder = -1 Then
|
|
'' ' cerco la data
|
|
'' While Not SearchName(Array(Index)) = "date"
|
|
'' Index += 1
|
|
'' End While
|
|
'' End If
|
|
'' ' riparto quindi dalla data
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' Leggo il codice
|
|
'' Public Function GetDate(Index As Integer) As Integer
|
|
'' Dim sDate As String = SearchKeyValue(FileContent(Index), K_DATE)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(sDate) Then
|
|
'' ' assegno la riga successiva
|
|
'' Index += 1
|
|
'' ' assegna il valore di default caricato nell'OptionModule
|
|
'' m_Door.DatePar = System.DateTime.Now.ToString("dd/MM/yyyy")
|
|
'' Else
|
|
'' m_Door.DatePar = sDate
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' carico valori di Size
|
|
'' Public Function GetSize(Index As Integer) As Integer
|
|
'' Dim Width As String = SearchKeyValue(FileContent(Index), K_WIDTH)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(Width) Then
|
|
'' ' se non c'è la parola chiave allora esci
|
|
'' If Not SearchKey(FileContent(Index), K_WIDTH) Then Return -1
|
|
'' ' altrimenti lascia il valore vuoto
|
|
'' Index += 1
|
|
'' Else
|
|
'' ' carico il valore nella porta corrente
|
|
'' m_Door.Width = Width
|
|
'' ' passo alla riga successiva
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim Height As String = SearchKeyValue(FileContent(Index), K_HEIGHT)
|
|
'' If String.IsNullOrWhiteSpace(Height) Then
|
|
'' If Not SearchKey(FileContent(Index), K_HEIGHT) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.Height = Height
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim Thickness As String = SearchKeyValue(FileContent(Index), K_THICKNESS)
|
|
'' If String.IsNullOrWhiteSpace(Thickness) Then
|
|
'' If Not SearchKey(FileContent(Index), K_THICKNESS) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.Thickness = Thickness
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' carico valori swing
|
|
'' Public Function GetSwing(Index As Integer) As Integer
|
|
'' Dim Swing As String = SearchKeyValue(FileContent(Index), K_SWING)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(Swing) Then
|
|
'' ' se non c'è la parola chiave allora esci
|
|
'' If Not SearchKey(FileContent(Index), K_SWING) Then Return -1
|
|
'' ' altrimenti lascia il valore vuoto
|
|
'' Index += 1
|
|
'' Else
|
|
'' ' carico il valore nella porta corrente
|
|
'' m_Door.Swing = Swing
|
|
'' ' passo alla riga successiva
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' carico valori profiles
|
|
'' Public Function GetProfiles(Index As Integer) As Integer
|
|
'' ' Creo una stringa per scrivere gli errori
|
|
'' Dim ReadingError As String = String.Empty
|
|
'' ' Lock
|
|
'' Dim LockEdgeType As String = SearchKeyValue(FileContent(Index), K_LOCKEDGE)
|
|
'' ' se il valore restituito è nullo o vuoto
|
|
'' If String.IsNullOrWhiteSpace(LockEdgeType) Then
|
|
'' ' se non c'è la parola chiave allora esci
|
|
'' If Not SearchKey(FileContent(Index), K_LOCKEDGE) Then Return -1
|
|
'' ' altrimenti lascia il valore vuoto
|
|
'' Index += 1
|
|
'' Else
|
|
'' ' carico il valore nella porta corrente
|
|
'' m_Door.LockEdgeType = LockEdgeType
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim LockEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
|
|
'' If String.IsNullOrWhiteSpace(LockEdgeMachining) Then
|
|
'' If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.LockEdgeMachining = Utility.ConvertOnOffToBoolean(LockEdgeMachining)
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim LockEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERAL)
|
|
'' If String.IsNullOrWhiteSpace(LockEdgeOverMaterial) Then
|
|
'' If Not SearchKey(FileContent(Index), K_OVERMATERAL) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.LockEdgeOverMaterial = LockEdgeOverMaterial
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' ' Hinge
|
|
'' Dim HingeEdgeType As String = SearchKeyValue(FileContent(Index), K_HINGEEDGE)
|
|
'' If String.IsNullOrWhiteSpace(HingeEdgeType) Then
|
|
'' If Not SearchKey(FileContent(Index), K_HINGEEDGE) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.HingeEdgeType = HingeEdgeType
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim HingeEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
|
|
'' If String.IsNullOrWhiteSpace(HingeEdgeMachining) Then
|
|
'' If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.HingeEdgeMachining = ConvertOnOffToBoolean(HingeEdgeMachining)
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim HingeEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERAL)
|
|
'' If String.IsNullOrWhiteSpace(HingeEdgeOverMaterial) Then
|
|
'' If Not SearchKey(FileContent(Index), K_OVERMATERAL) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.HingeEdgeOverMaterial = HingeEdgeOverMaterial
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' ' Top
|
|
'' Dim TopType As String = SearchKeyValue(FileContent(Index), K_TOP)
|
|
'' If String.IsNullOrWhiteSpace(TopType) Then
|
|
'' If Not SearchKey(FileContent(Index), K_TOP) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.TopType = TopType
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim TopMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
|
|
'' If String.IsNullOrWhiteSpace(TopMachining) Then
|
|
'' If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.TopMachining = ConvertOnOffToBoolean(TopMachining)
|
|
'' Index += 1
|
|
'' End If
|
|
'' Dim TopOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERAL)
|
|
'' If String.IsNullOrWhiteSpace(TopOverMaterial) Then
|
|
'' If Not SearchKey(FileContent(Index), K_OVERMATERAL) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.TopOverMaterial = TopOverMaterial
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' ' Bottom
|
|
'' Dim BottomType As String = SearchKeyValue(FileContent(Index), K_BOTTOM)
|
|
'' If String.IsNullOrWhiteSpace(BottomType) Then
|
|
'' If Not SearchKey(FileContent(Index), K_BOTTOM) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.BottomType = BottomType
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' Dim BottomMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
|
|
'' If String.IsNullOrWhiteSpace(BottomMachining) Then
|
|
'' If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.BottomMachining = ConvertOnOffToBoolean(BottomMachining)
|
|
'' Index += 1
|
|
'' End If
|
|
|
|
'' Dim BottomOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERAL)
|
|
'' If String.IsNullOrWhiteSpace(BottomOverMaterial) Then
|
|
'' If Not SearchKey(FileContent(Index), K_OVERMATERAL) Then Return -1
|
|
'' Index += 1
|
|
'' Else
|
|
'' m_Door.BottomOverMaterial = BottomOverMaterial
|
|
'' Index += 1
|
|
'' End If
|
|
'' ' restituisco la riga successiva all'ultimo valore letto
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
''#End Region ' Carica il General della porta
|
|
|
|
'' ' ricerco la compo nella lista dei compobtn
|
|
'' Public Function GetNewCompo(Index As Integer, CompoNameDDF As String, ByRef InvalidValue As String) As Integer
|
|
'' Dim bDDFName As Boolean = False
|
|
'' Dim bCompo As Boolean = False
|
|
'' ' controllo che il nome passato esiste nella lista delle componenti
|
|
'' Dim CompoListIndex As Integer
|
|
'' ' se la stringa ha un trattino ipotizzo che il nome della componente sia lo stesso dell'ultima componente inserita
|
|
'' If Not String.IsNullOrWhiteSpace(Score(FileContent(Index - 1))) Then
|
|
'' If m_Door.m_CompoList.Count > 0 Then
|
|
'' CompoNameDDF = m_Door.m_CompoList.Last.CompoType.DDFName
|
|
'' Index -= 1
|
|
'' Else
|
|
'' Index -= 1
|
|
'' Return Index
|
|
'' End If
|
|
'' End If
|
|
|
|
'' For CompoListIndex = 0 To CompoPanelViewModel.CompoTypeList.Count() - 1
|
|
'' ' eseguo il confronto con il nome delle componenti che è stato acricato nel file Default.ini
|
|
'' If CompoPanelViewModel.CompoTypeList(CompoListIndex).DDFName = CompoNameDDF Then
|
|
'' ' se il nome esiste
|
|
'' bDDFName = True
|
|
'' ' passo alla lettura delle righe successive (quindi a quella passata nella funzione)
|
|
'' While Index < FileContent.Count AndAlso Not String.IsNullOrWhiteSpace(FindComments(FileContent(Index)))
|
|
'' ' cerco il nome
|
|
'' ' controllo che la stringa abbia i due punti: se non ha i due punti
|
|
'' If String.IsNullOrWhiteSpace(SearchName(FileContent(Index))) Then
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50131), CompoNameDDF, Index - 1)
|
|
'' InvalidValue &= Environment.NewLine & CompoNameDDF & " has not been created."
|
|
'' ' esco dalla lettura della compo
|
|
'' Exit While
|
|
'' ' se ha il trattino
|
|
'' Else
|
|
'' ' creo la nuova componente
|
|
'' Dim m_CurrCompo = New Compo(CompoPanelViewModel.CompoTypeList(CompoListIndex), m_Door)
|
|
'' ' Leggo il file ini del componente per vedere se c'è il template: se c'è
|
|
'' Dim CurrCompoTypePath As String = CompoPanelViewModel.CompoTypeList(CompoListIndex).Path
|
|
'' If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME) <> 0 Then
|
|
'' ' leggo nomi
|
|
'' Dim Name As String = String.Empty
|
|
'' Dim DDFName As String = String.Empty
|
|
'' IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
|
|
'' ' creo la lista dei templati della compnente
|
|
'' Dim TemplateList As New List(Of String)
|
|
'' ' che carico con i nome delle directory contenute nella directory principale (quella che contiene il file Config.ini)
|
|
'' IniFile.OpenDirectory(CompoPanelViewModel.CompoTypeList(CompoListIndex).Path, TemplateList)
|
|
'' ' aggiungo il template come parametro (è un parametro particolare, quindi esiste separatamente)
|
|
'' m_CurrCompo.TemplateDDFName = DDFName
|
|
'' m_CurrCompo.TemplateName = Name
|
|
'' m_CurrCompo.TemplateItemList = TemplateList
|
|
|
|
'' ' cercco trattino "-": se lo trovo
|
|
'' If SearchScore(FileContent(Index)) Then
|
|
'' ' leggo il valore del template e lo assegno alla componente che sto generando
|
|
'' ' attenzione: devo passare anche il nome del parametro da cercare; per ora posso avere "template" o "shape" come parola chiave
|
|
'' m_CurrCompo.TemplateSelItem = SearchKeyValue(FileContent(Index), SearchTemplate(FileContent(Index)))
|
|
'' ' se il template non ha nessun nome
|
|
'' If String.IsNullOrWhiteSpace(m_CurrCompo.TemplateSelItem) Then
|
|
'' ' elimina la compo che stai creando
|
|
'' m_CurrCompo = Nothing
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format("Template non found in line {0}", Index - 1)
|
|
'' ' ed esci dal ciclo while
|
|
'' Exit While
|
|
'' End If
|
|
'' 'mi sposto nella riga successiva
|
|
'' Index += 1
|
|
'' ' leggo i parametri della componente
|
|
'' ReadParam(m_CurrCompo, InvalidValue, Index)
|
|
'' ' se creo la componente allora assegno vero
|
|
'' bCompo = True
|
|
'' Else
|
|
'' ' restituisco la riga precedente alla funzione ReadDDF
|
|
'' Index -= 1
|
|
'' ' se non ha il trattino (ma ha un template) esci dal ciclo
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50132), DDFName, Index - 1)
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
|
|
'' Exit While
|
|
'' End If
|
|
'' ' la componente non ha template (louver_cut_outs)
|
|
'' Else
|
|
'' ' nascondo il template
|
|
'' m_CurrCompo.TemplateVisibility = Visibility.Collapsed
|
|
'' ' leggo il nome del template della compo dal file config.ini
|
|
'' Dim sTemplateName As String = String.Empty
|
|
'' ' controllo il tipo di estensione del file (nome letto da Config.ini)
|
|
'' EgtUILib.GetPrivateProfileString(S_TEMPLATE, K_COMPO, "", sTemplateName, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
|
|
'' If String.IsNullOrWhiteSpace(sTemplateName) Then
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50134), CurrCompoTypePath, CONFIGINI_FILE_NAME)
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
|
|
'' m_CurrCompo = Nothing
|
|
'' ElseIf Not File.Exists(CurrCompoTypePath & "\" & sTemplateName & ".lua") Then
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50135), CurrCompoTypePath, CONFIGINI_FILE_NAME, sTemplateName)
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
|
|
'' Else
|
|
'' ' assegno il nome del tipo di componente
|
|
'' m_CurrCompo.TemplateSelItem = sTemplateName
|
|
'' ReadParam(m_CurrCompo, InvalidValue, Index)
|
|
'' ' se creo la compo allora assegno vero
|
|
'' bCompo = True
|
|
'' End If
|
|
'' End If
|
|
'' m_Door.CompoList.Add(m_CurrCompo)
|
|
'' End If
|
|
'' ' se la stringa non ha i due punti
|
|
'' End While
|
|
'' Exit For
|
|
'' End If
|
|
'' Next
|
|
'' If Not bDDFName Then
|
|
'' ' la componente none esiste
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50136), CompoNameDDF, Index - 1)
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
|
|
'' Index -= 1
|
|
'' End If
|
|
|
|
'' Return Index
|
|
'' End Function
|
|
|
|
'' ' leggo i parametri della componente
|
|
'' Sub ReadParam(ByRef CompoTemplateItem As Compo, ByRef InvalidValue As String, ByRef IndexLine As Integer)
|
|
'' ' questo è l'indice dei parametri della componente
|
|
'' Dim IndexParam As Integer
|
|
'' For IndexParam = 0 To CompoTemplateItem.CompoParamList.Count - 1
|
|
'' ' carico la lista dei parametri della componente
|
|
'' Dim CurrCompoParam As CompoParam = CompoTemplateItem.CompoParamList(IndexParam)
|
|
'' ' Controllo che il file non sia terminato
|
|
'' If IndexLine + IndexParam < FileContent.Count Then
|
|
'' ' se è di tipo textboBoxOnOff lo tratto separatamente
|
|
'' If Not TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then
|
|
|
|
'' ' se il nome del parametro è lo stesso di quello presente nella componente
|
|
'' If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
|
|
'' ' verifico di che tipo si tratta: combobox
|
|
'' If TypeOf CurrCompoParam Is ComboBoxParam Then
|
|
'' ' leggo il valore DDF dal file
|
|
'' Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
|
|
|
|
'' Dim IndexName As Integer = 0
|
|
'' ' carico la lista dei valori (messaggi)
|
|
'' Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemList
|
|
'' Dim IndexListDDF As Integer = 0
|
|
'' ' carico la lista dei valori DDF
|
|
'' Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemListDDF
|
|
'' ' riscrivo i valori della lista DDF senza spaziatura
|
|
'' For IndexListDDF = 0 To ListDDF.Count - 1
|
|
'' ListDDF(IndexListDDF) = Trim(ListDDF(IndexListDDF))
|
|
'' Next
|
|
'' ' carico il valore IndexName come indice del valore selezionato dalla lista DDF
|
|
'' IndexName = ListDDF.IndexOf(sVal)
|
|
'' Dim SelItem As String = String.Empty
|
|
'' ' se è stata trovata una corrispondenza tra il valore letto dal foile e il valore presente nella lista DDF
|
|
'' If IndexName >= 0 Then
|
|
'' ' restituisco il valore DDF della lista associato all'indice passato
|
|
'' SelItem = Trim(List(IndexName))
|
|
'' Else
|
|
'' ' il nome DDF non è corretto
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50137), sVal, IndexLine)
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
|
|
'' SelItem = List(0)
|
|
'' End If
|
|
'' ' assegno al parametro della compnente il valore "filtrato"
|
|
'' DirectCast(CurrCompoParam, ComboBoxParam).SelItem = SelItem
|
|
|
|
'' ' assegno il valore letto alla textbox
|
|
'' ElseIf TypeOf CurrCompoParam Is TextBoxParam Then
|
|
'' Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
|
|
'' ' per ora non esegue nessun tipo di controllo sui valori letti dal file DDF
|
|
'' DirectCast(CurrCompoParam, TextBoxParam).Value = sVal
|
|
'' End If
|
|
|
|
'' ' se il nome esiste ma è sabgliato
|
|
'' ElseIf Not String.IsNullOrWhiteSpace(SearchName(FileContent(IndexLine + IndexParam))) Then
|
|
'' ' se il nome non è preceduto dal trattino
|
|
'' If String.IsNullOrWhiteSpace(Score(FileContent(IndexLine + IndexParam))) Then
|
|
'' ' il nome DDF non è corretto
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
|
|
'' Else
|
|
'' ' istanzio tutti i valori che mancano alla compo corrente di default
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
|
|
'' ' esco dal ciclo for dei parametri
|
|
'' Exit For
|
|
'' End If
|
|
'' 'se c'è una riga vuota
|
|
'' ElseIf String.IsNullOrWhiteSpace(SearchName(FileContent(IndexLine + IndexParam))) Then
|
|
'' ' spostati alla riga successiva nel fie DDF
|
|
'' IndexLine += 1
|
|
'' ' e continua a cercare lo stesso parametro
|
|
'' IndexParam -= 1
|
|
'' ' se trovo un trattino vuol dire che cè una nuova componente
|
|
'' End If
|
|
|
|
'' ' se è una TextBoxOnOff
|
|
'' Else
|
|
'' ' prima verifico che ci sia veramnte la stringa nel file DDF
|
|
'' If IndexLine + IndexParam < FileContent.Count Then
|
|
'' If Not String.IsNullOrWhiteSpace(Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
|
|
'' ' poi verifico che sia ugule al paramentro: se ha lo stesso nome DDF
|
|
'' If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
|
|
'' ' se la stringa c'è nel DDF vuol dire che è stata selezionata
|
|
'' Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).Value = sVal
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = True
|
|
'' Else
|
|
'' ' cerco un parametro successivo
|
|
'' If IndexParam < CompoTemplateItem.CompoParamList.Count - 1 Then
|
|
'' ' controllo che il file abbia un'altra riga da leggere: se c'è un'altra riga
|
|
'' If IndexLine + IndexParam < FileContent.Count Then
|
|
'' ' confronto con il succesivo parametro: se è uguale
|
|
'' If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam + 1).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
|
|
'' ' significa che la TextBoxOnOff è stata disattivata
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
|
|
'' IndexLine -= 1
|
|
'' Else
|
|
'' ' se sono diversi: è decisamente un errore
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
|
|
'' ' disattivo la TextBoxOnOff
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
|
|
'' IndexLine -= 1
|
|
'' End If
|
|
'' ' se il file è terminato
|
|
'' Else
|
|
'' ' istanzio tutti i valori che mancano alla compo corrente di default
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50140))
|
|
'' End If
|
|
'' ' non ci sono più parametri nella lista
|
|
'' Else
|
|
'' ' significa che la TextBoxOnOff è stata disattivata
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
|
|
'' IndexLine = IndexLine - 1
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' ' se cè una riga vuota passo alla succesiva
|
|
'' IndexLine += 1
|
|
'' ' e continua a cercare lo stesso parametro
|
|
'' IndexParam -= 1
|
|
'' End If
|
|
'' Else
|
|
'' ' se la textBoxOnOff è l'ultima della lista (quindi seguita da uno psazio vuoto) allora considero che sia disattivata
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' Else
|
|
'' ' se il file è più corto di quel che dovrebbe essere (mancono alcuni parametri nel file prima della fine)
|
|
'' If TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then
|
|
'' DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
|
|
'' Else
|
|
'' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
|
|
'' InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
|
|
'' InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50140))
|
|
'' End If
|
|
'' End If
|
|
'' Next
|
|
'' ' terminata la lettura dei parametri
|
|
'' IndexLine += IndexParam
|
|
'' End Sub
|
|
|
|
''#End Region ' Lettura ddf
|
|
|
|
#Region "SCRITTURA DDF"
|
|
|
|
'genero le stringhe che dovranno essere scritte nel DDF
|
|
Friend Sub WriteDDF(Door As Door, sPath As String)
|
|
' Door = DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor
|
|
' pulisco lista prima di iniziare a scrivere
|
|
Dim DdfFileContent As New List(Of String)
|
|
If String.IsNullOrEmpty(Door.Measure) Then
|
|
Door.Measure = OptionModule.m_SelectedMeasureUnit
|
|
End If
|
|
DdfFileContent.Add("#EGTDOORCREATOR")
|
|
'Genero una lista di stringhe
|
|
If Door.Measure = "Inches" Then
|
|
Door.Measure = "inches"
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_MEASURES & ": " & Door.Measure)
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
If String.IsNullOrEmpty(Door.Code) Then
|
|
Door.Code = "1111"
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_CODE & ": " & Door.Code)
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
DdfFileContent.Add(ConstCompo.S_ORDER & ":")
|
|
' Probablimente da cambiare
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_CUSTOMER & ": ")
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_ELEVATION & ": ")
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PROJECT & ": ")
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PO & ": ")
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LINE & ": ")
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
DdfFileContent.Add(ConstCompo.K_DATE & ":" & " " & System.DateTime.Now.ToString("dd/MM/yyyy"))
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
Dim dVal As Double = 0
|
|
DdfFileContent.Add(ConstCompo.K_SIZE & ":")
|
|
If Not StringToDouble(Door.Width, dVal) Then
|
|
MessageBox.Show("Invalid value in Width", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_WIDTH & ": " & DoubleToString(dVal, 5))
|
|
If Not StringToDouble(Door.Height, dVal) Then
|
|
MessageBox.Show("Invalid value in Height", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HEIGHT & ": " & DoubleToString(dVal, 5))
|
|
If Not StringToDouble(Door.Thickness, dVal) Then
|
|
MessageBox.Show("Invalid value in Thickness", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5))
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
DdfFileContent.Add("" & ConstCompo.K_SWING & ": " & Door.Swing)
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
DdfFileContent.Add("")
|
|
DdfFileContent.Add("" & ConstCompo.K_PROFILES & ":")
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & Door.LockEdgeType)
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Door.LockEdgeMachining))
|
|
If Not StringToDouble(Door.LockEdgeOverMaterial, dVal) Then
|
|
MessageBox.Show("Invalid value in LockEdgeOverMaterial", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERAL & ": " & DoubleToString(dVal, 5))
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & Door.HingeEdgeType)
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Door.HingeEdgeMachining))
|
|
If Not StringToDouble(Door.HingeEdgeOverMaterial, dVal) Then
|
|
MessageBox.Show("Invalid value in HingeEdgeOverMaterial", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERAL & ": " & DoubleToString(dVal, 5))
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_TOP & ": " & Door.TopType)
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Door.TopMachining))
|
|
If Not StringToDouble(Door.TopOverMaterial, dVal) Then
|
|
MessageBox.Show("Invalid value in TopOverMaterial", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERAL & ": " & DoubleToString(dVal, 5))
|
|
DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_BOTTOM & ": " & Door.BottomType)
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Door.BottomMachining))
|
|
If Not StringToDouble(Door.BottomOverMaterial, dVal) Then
|
|
MessageBox.Show("Invalid value in BottomOverMaterial", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERAL & ": " & DoubleToString(dVal, 5))
|
|
' aggiungo una riga vuota per separare la lista successiva
|
|
|
|
'DdfFileContent.Add("")
|
|
|
|
' Riordino e stampo le compo
|
|
SearchCompo(DdfFileContent, Door)
|
|
If Not Directory.Exists(Path.GetDirectoryName(sPath)) Then
|
|
Directory.CreateDirectory(Path.GetDirectoryName(sPath))
|
|
End If
|
|
File.WriteAllLines(sPath, DdfFileContent, Text.Encoding.UTF8)
|
|
End Sub
|
|
|
|
' stampa le compo seguedo l'ordine della lista delle componenti del ddf
|
|
Public Sub SearchCompo(DdfFileContent As List(Of String), ByRef Door As Door)
|
|
Dim NewCompoNameDDF = False
|
|
Dim WritingError As String = String.Empty
|
|
' cerco la prima componente da aggiungere alla lista delle componenti
|
|
For Index1 = 0 To DdfFile.CompoListOrder.Count() - 1
|
|
For Index2 = 0 To Door.CompoList.Count() - 1
|
|
' se trovo la componenete da aggiungere
|
|
If DdfFile.CompoListOrder(Index1) = Door.CompoList(Index2).CompoType.DDFName Then
|
|
' se il nome della componente da aggiungere già esiste
|
|
If Index2 >= 1 AndAlso String.Equals(Door.CompoList(Index2).CompoType.DDFName, Door.CompoList(Index2 - 1).CompoType.DDFName) Then
|
|
NewCompoNameDDF = True
|
|
Else
|
|
' aggiungo una riga vuota per separare il nome della nuova componente
|
|
DdfFileContent.Add("")
|
|
End If
|
|
' Carico nella lista dei componenti la lista di stringhe da stampare
|
|
DdfFileContent.AddRange(GenerateCompolistDDF(Door.CompoList(Index2), WritingError, NewCompoNameDDF))
|
|
End If
|
|
NewCompoNameDDF = False
|
|
Next
|
|
Next
|
|
' finto di leggere tutte le componenti stampo il messaggio degli errori
|
|
If Not String.IsNullOrWhiteSpace(WritingError) Then
|
|
MessageBox.Show(WritingError, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
End Sub
|
|
|
|
'Genero la lista di parametri di ogni compo che vedo a video
|
|
Public Function GenerateCompolistDDF(Compo As Compo, ByRef sErrorList As String, bNewCompoNameDDF As Boolean) As List(Of String)
|
|
Dim CompoListDDF As New List(Of String)
|
|
' se il nome non esiste ancora nella lista lo aggiungo
|
|
If Not bNewCompoNameDDF Then
|
|
' aggiungo il nome DDF della componente
|
|
CompoListDDF.Add(Compo.CompoType.DDFName & ":")
|
|
End If
|
|
' se esiste il template
|
|
If Not String.IsNullOrWhiteSpace(Compo.TemplateDDFName) Then
|
|
' aggiungo " - nomeTemplate: TemplateSelezionato"
|
|
CompoListDDF.Add(K_SCORE & Compo.TemplateDDFName & ": " & Compo.TemplateSelItem)
|
|
End If
|
|
' creo l'indice dei parametri della compo
|
|
Dim ParamIndex As Integer
|
|
' scrivo tutti i parametri della compo
|
|
For ParamIndex = 0 To Compo.CompoParamList.Count - 1
|
|
Dim CurrCompoParam As CompoParam = Compo.CompoParamList(ParamIndex)
|
|
' controllo il tipo di parametro: ComboBox
|
|
|
|
If TypeOf CurrCompoParam Is ComboBoxParam Then
|
|
' controllo che sia selezionato un elemento
|
|
If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, ComboBoxParam).SelItem) Then
|
|
Dim IndexDDF As Integer = 0
|
|
' carico la lista DDF
|
|
Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemListDDF
|
|
' rccolgo il valore IndexDDF come indice del valore selezionato dalla lista
|
|
IndexDDF = DirectCast(CurrCompoParam, ComboBoxParam).ItemList.IndexOf(DirectCast(CurrCompoParam, ComboBoxParam).SelItem)
|
|
' restituisco il valore DDF della lista associato all'indice passato
|
|
Dim SelItemDDF As String = Trim(List(IndexDDF))
|
|
CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, ComboBoxParam).DDFName & ": " & SelItemDDF)
|
|
Else
|
|
' se non è selezionato nessun elemento (cosa impossibile...)
|
|
If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine
|
|
sErrorList &= String.Format(EgtMsg(50114), DirectCast(CurrCompoParam, ComboBoxParam).Name, CurrCompoParam.DDFName)
|
|
End If
|
|
|
|
ElseIf TypeOf CurrCompoParam Is TextBoxOnOffParam Then
|
|
If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue) AndAlso DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive Then
|
|
' se è stata inserita un'espressine non valida restituisco un errore
|
|
If DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue = "Invalid Expression" Then
|
|
If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine
|
|
sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxOnOffParam).Name, CurrCompoParam.DDFName)
|
|
Else
|
|
CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxOnOffParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue)
|
|
End If
|
|
ElseIf Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue) AndAlso Not DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive Then
|
|
' non restituire nessun tipo di errore
|
|
End If
|
|
' TextBox
|
|
ElseIf TypeOf CurrCompoParam Is TextBoxParam Then
|
|
If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue) Then
|
|
' se è stata inserita un'espressine non valida restituisco iun errore
|
|
If DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue = "Invalid Expression" Then
|
|
If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine
|
|
sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxParam).Name, CurrCompoParam.DDFName)
|
|
Else
|
|
CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue)
|
|
End If
|
|
Else
|
|
If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine
|
|
sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxParam).Name, CurrCompoParam.DDFName)
|
|
End If
|
|
End If
|
|
Next
|
|
Return CompoListDDF
|
|
End Function
|
|
|
|
#End Region ' Scrittura DDF
|
|
|
|
'eseguo il confronto tra il DDF Nuovo e quello in lettura nella finestra grafica: restituisce falso se i due file sono diversi
|
|
Friend Function ComparisonFileDDF(sPathNewDoor As String, sPathTempDoor As String) As Boolean
|
|
''Dim FileContentNewDoor As String()
|
|
''Dim FileContentTempDoor As String()
|
|
Dim bComparison As Boolean = False
|
|
''FileContentNewDoor = File.ReadAllLines(sPathNewDoor)
|
|
''FileContentTempDoor = File.ReadAllLines(sPathTempDoor)
|
|
''Dim nComparison As Integer
|
|
|
|
'' individuo il file più corto tra i due
|
|
''Dim EndOfFile As Integer
|
|
''If FileContentNewDoor.Count > FileContentTempDoor.Count Then
|
|
'' EndOfFile = FileContentTempDoor.Count
|
|
'' nComparison = 1
|
|
''ElseIf FileContentNewDoor.Count < FileContentTempDoor.Count Then
|
|
'' EndOfFile = FileContentNewDoor.Count
|
|
'' nComparison = -1
|
|
''ElseIf FileContentNewDoor.Count = FileContentTempDoor.Count Then
|
|
'' EndOfFile = FileContentNewDoor.Count
|
|
'' nComparison = 0
|
|
''End If
|
|
|
|
''Dim Line As Integer = 0
|
|
''Dim LineBis As Integer = 0
|
|
'' confronto riga per riga i due file
|
|
''For Line = 0 To EndOfFile - 1
|
|
|
|
'' SkipWhiteSpace(FileContentNewDoor, Line, FileContentNewDoor.Count - 1)
|
|
'' SkipWhiteSpace(FileContentTempDoor, LineBis, FileContentTempDoor.Count - 1)
|
|
|
|
'' If Trim(FindComments(FileContentNewDoor(Line))) = Trim(FindComments(FileContentTempDoor(LineBis))) Then
|
|
'' bComparison = True
|
|
'' LineBis += 1
|
|
'' Else
|
|
'' se la riga cercata è la data allora non considerare la modifica
|
|
'' If Trim(SearchName(FileContentNewDoor(Line))) = "date" Then
|
|
'' bComparison = True
|
|
'' LineBis += 1
|
|
'' ElseIf IsNumeric(SearchKeyValue(FileContentNewDoor(Line), SearchName(FileContentNewDoor(Line)))) Then
|
|
'' Dim sValNewDoor As Double
|
|
'' StringToDouble(SearchKeyValue(FileContentNewDoor(Line), SearchName(FileContentNewDoor(Line))), sValNewDoor)
|
|
'' Dim sValTempDoor As Double
|
|
'' StringToDouble(SearchKeyValue(FileContentTempDoor(Line), SearchName(FileContentTempDoor(LineBis))), sValTempDoor)
|
|
'' If sValNewDoor = sValTempDoor Then
|
|
'' bComparison = True
|
|
'' LineBis += 1
|
|
'' Else
|
|
'' bComparison = False
|
|
'' Exit For
|
|
'' End If
|
|
'' End If
|
|
'' End If
|
|
''Next
|
|
''studio le righe che non sono state analizzate sopra
|
|
''Select Case nComparison
|
|
'' Case 1
|
|
'' For MissinIndex = EndOfFile To FileContentNewDoor.Count - 1
|
|
'' If Not String.IsNullOrWhiteSpace(FindComments(FileContentNewDoor(MissinIndex))) Then
|
|
'' bComparison = False
|
|
'' Exit Select
|
|
'' Else
|
|
'' bComparison = True
|
|
'' End If
|
|
'' Next
|
|
'' Case -1
|
|
'' For MissinIndex = EndOfFile To FileContentTempDoor.Count - 1
|
|
'' If Not String.IsNullOrWhiteSpace(FindComments(FileContentTempDoor(MissinIndex))) Then
|
|
'' bComparison = False
|
|
'' Exit Select
|
|
'' Else
|
|
'' bComparison = True
|
|
'' End If
|
|
'' Next
|
|
''End Select
|
|
Return bComparison
|
|
|
|
End Function
|
|
|
|
Friend Function SetModify(rMainWindow As MainWindowViewModel) As Boolean
|
|
If Trim(rMainWindow.ProjectNameMsg) = Trim(rMainWindow.ProjectNameMsg.Trim("*"c)) Then
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
''Public Function SkipWhiteSpace(Array() As String, ByRef Index As Integer, LastIndex As Integer) As Integer
|
|
'' Array(Index) = FindComments(Array(Index))
|
|
'' While String.IsNullOrWhiteSpace(Array(Index)) And Index < LastIndex
|
|
'' Index += 1
|
|
'' Array(Index) = FindComments(Array(Index))
|
|
'' End While
|
|
'' Return Index
|
|
''End Function
|
|
|
|
End Module
|