diff --git a/Constants/ConstCompo.vb b/Constants/ConstCompo.vb index 69e90c3..f468284 100644 --- a/Constants/ConstCompo.vb +++ b/Constants/ConstCompo.vb @@ -57,5 +57,8 @@ Module ConstCompo Public Const K_LIST As String = "List" Public Const K_ON As String = "ON" Public Const K_OFF As String = "OFF" - + Public Const K_NEWDOOR As String = "New Door" + Public Const K_DDFEXTENSION As String = ".ddf" + Public Const K_NGEEXTENSION As String = ".nge" + Public Const K_LUAEXTENSION As String = ".lua" End Module diff --git a/Constants/ConstGen.vb b/Constants/ConstGen.vb index bdc622e..f287b32 100644 --- a/Constants/ConstGen.vb +++ b/Constants/ConstGen.vb @@ -37,5 +37,7 @@ Module ConstGen Public Const TEMP_DIR As String = "Temp" ' Sottodirettorio di default per il salvataggio con nome Public Const SAVE_DFL_NAMEDIR As String = "MyProjects" - + ' File ddf utilizzato per il disegno corrente + Public Const TEMP_FILE As String = "CurrDoor.ddf" + Public Const TEMP_FILE_TXT As String = "CurrDoor.txt" End Module diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 7eb59f2..8a15736 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -120,7 +120,6 @@ Module ConstIni Public Const K_DDFEXEC As String = "DdfExec" Public Const K_DDFFUNCTION As String = "DdfFun" Public Const K_DDFDIR As String = "DdfDir" - Public Const K_DDFDEFAULTDIR As String = "DdfDefaultDir" Public Const K_DDFMACHEXEC As String = "DdfMachExec" Public Const K_TABLESDIR As String = "TablesDir" Public Const K_COMPODIR As String = "CompoDirectory" diff --git a/DdfFile.vb b/DdfFile.vb index f718577..3731af9 100644 --- a/DdfFile.vb +++ b/DdfFile.vb @@ -11,793 +11,6 @@ Friend Module DdfFile 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 @@ -837,17 +50,17 @@ Friend Module DdfFile 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) + MessageBox.Show(EgtMsg(50106) & K_WIDTH, EgtMsg(50101), 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) + MessageBox.Show(EgtMsg(50106) & K_HEIGHT, EgtMsg(50101), 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) + MessageBox.Show(EgtMsg(50106) & K_THICKNESS, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5)) @@ -860,34 +73,31 @@ Friend Module DdfFile 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) + MessageBox.Show(EgtMsg(50106) & K_LOCKEDGEOVERMATERIAL_INI, EgtMsg(50101), 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) + MessageBox.Show(EgtMsg(50106) & K_HINGEDGEOVERMATERIAL_INI, EgtMsg(50101), 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) + MessageBox.Show(EgtMsg(50106) & K_TOPOVERMATERIAL_INI, EgtMsg(50101), 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) + MessageBox.Show(EgtMsg(50106) & K_BOTTOMOVERMATERIAL_INI, EgtMsg(50101), 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) @@ -965,7 +175,7 @@ Friend Module DdfFile 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 DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxOnOffParam).Name, CurrCompoParam.DDFName) Else @@ -978,7 +188,7 @@ Friend Module DdfFile 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 DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxParam).Name, CurrCompoParam.DDFName) Else @@ -1073,6 +283,7 @@ Friend Module DdfFile End Function + ' se il titolo presenta * allora vuol dire che era stato modificato, altrinenti no .Trim("*"c) Friend Function SetModify(rMainWindow As MainWindowViewModel) As Boolean If Trim(rMainWindow.ProjectNameMsg) = Trim(rMainWindow.ProjectNameMsg.Trim("*"c)) Then Return True diff --git a/DoorManager/DoorManagerViewModel.vb b/DoorManager/DoorManagerViewModel.vb index 3124170..2a148d3 100644 --- a/DoorManager/DoorManagerViewModel.vb +++ b/DoorManager/DoorManagerViewModel.vb @@ -41,7 +41,7 @@ Public Class DoorManagerViewModel DdfFile.WriteDDF(DoorParametersViewModel.CurrDoor, IniFile.m_sTempDir & "\CurrDoor.ddf") Select Case DeleteNewDoor - ' si è una porta appena creata + ' se è una porta appena creata Case 0 ' chiedo se deve essere eliminata la porta che era stata creata RemoveDoor() @@ -49,7 +49,6 @@ Public Class DoorManagerViewModel ' se è una porta "vecchia" Case 1 ' confronto il file della porta originale e quello aggiornato: se i due file sono uguali eccetto la data - ''If DdfFile.ComparisonFileDDF(IniFile.m_sTempDir & "\CurrDoor.ddf", m_SelectedDoor) Then ' non faccio nulla If DdfFile.SetModify(m_rfMainWindowViewModel) Then @@ -90,8 +89,6 @@ Public Class DoorManagerViewModel SelDoor.HingeEdgeOverMaterial = OptionModule.m_HingeEdgeOverMaterial SelDoor.TopOverMaterial = OptionModule.m_TopOverMaterial SelDoor.BottomOverMaterial = OptionModule.m_BottomOverMaterial - ' inizilaizzo le dimensioni della porta attraverso i parametri di OptioModule - 'SelDoor = OptionModule.GeneralDoor ' assegno la porta creata alla Programma come porta corrente DoorParametersViewModel.CurrDoor = SelDoor ' scrivo il ddf della nuova porta come file temp @@ -158,28 +155,16 @@ Public Class DoorManagerViewModel Public ReadOnly Property AddNewDoorToolTip As String Get - Return "Add new door" + Return EgtMsg(50302) End Get End Property Public ReadOnly Property RemoveDoorToolTip As String Get - Return "Remove door" + Return EgtMsg(50303) End Get End Property - 'Public ReadOnly Property GoAhaedToolTip As String - ' Get - ' Return "Go ahaed" - ' End Get - 'End Property - - 'Public ReadOnly Property GoBackToolTip As String - ' Get - ' Return "Go back" - ' End Get - 'End Property - ' Definizione comandi Private m_cmdAddDoor As ICommand Private m_cmdRemoveDoor As ICommand @@ -211,9 +196,9 @@ Public Class DoorManagerViewModel Dim NameExist As Boolean = True ' lancio la finestra per la creazione di una nuova porta Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog - SaveFileDialog.Title = "New Door" + SaveFileDialog.Title = K_NEWDOOR SaveFileDialog.Directory = m_CurrProject.Name - SaveFileDialog.Extension = ".ddf" + SaveFileDialog.Extension = K_DDFEXTENSION 'SaveFileDialog.FileName = m_CurrProject.Name & "\" ' se decido di chiuedere la finestra If Not SaveFileDialog.EgtShowDialog Then @@ -222,11 +207,11 @@ Public Class DoorManagerViewModel ' Controllo se ha estensione il nome della porta If Path.HasExtension(SaveFileDialog.FileName) Then Dim sExtension As String = Path.GetExtension(SaveFileDialog.FileName) - If Not sExtension.ToLower = ".ddf" Then - SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, ".ddf") + If Not sExtension.ToLower = K_DDFEXTENSION Then + SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, K_DDFEXTENSION) End If Else - SaveFileDialog.FileName &= ".ddf" + SaveFileDialog.FileName &= K_DDFEXTENSION End If '' '' controllo che il nome del file già non esiste nella lista! diff --git a/DoorParameters/Compo.vb b/DoorParameters/Compo.vb index 1e961d0..8305545 100644 --- a/DoorParameters/Compo.vb +++ b/DoorParameters/Compo.vb @@ -5,7 +5,7 @@ Imports EgtUILib Public Class Compo Implements INotifyPropertyChanged - Friend TempFileDDF As String = IniFile.m_sTempDir & "\CurrDoor.ddf" + Friend TempFileDDF As String = IniFile.m_sTempDir & "\" & TEMP_FILE Friend m_rfCurrDoor As Door ' definizione della funzione delegato: riceve il valore di modifica della compo e della general 'Delegate Function CompareIsModify(rIsModifyCompo As Boolean, rIsModifyDoor As Boolean) As Boolean @@ -175,7 +175,6 @@ Public Class Compo ' funzione che setta il template del parametro - Friend m_IsModifiedTemplateSelItem As Boolean = False Private m_TemplateSelItem As String Public Property TemplateSelItem As String @@ -195,7 +194,7 @@ Public Class Compo Dim CurrItemPath As String = m_CompoType.Path & "\" & value Dim ErrorList As String = String.Empty ' se il file ha estensione nge - If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = ".nge" Then + If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = K_NGEEXTENSION Then ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return m_TemplateSelItem = value @@ -209,7 +208,7 @@ Public Class Compo ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault) Else ' se il file non ha estensione allora creo l'estensione .lua - CurrItemPath &= ".lua" + CurrItemPath &= K_LUAEXTENSION ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return m_TemplateSelItem = value @@ -231,8 +230,8 @@ Public Class Compo Dim bIsFinished As Boolean = False ' se la lettura del primo parametro "--Default=" restituisce un valore non nullo - If Not String.IsNullOrWhiteSpace(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), "Default")) Then - Dim ConfigDefault As String = Trim(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), "Default")) + If Not String.IsNullOrWhiteSpace(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT)) Then + Dim ConfigDefault As String = Trim(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT)) If Not IsNumeric(ConfigDefault) Then ' se il valore letto non è numerico allora esco dal cilo per la lettura dei parametri Exit For @@ -251,7 +250,7 @@ Public Class Compo If Not String.IsNullOrWhiteSpace(ReadCurrCompo(LineIndex + ParamIndex)) Then Dim ReadLine As String ' carico i valori della stringa che seguono la chiave "--Param1=" - ReadLine = ParamLine(ReadCurrCompo(LineIndex + ParamIndex), "Param" & ParamIndex) + ReadLine = ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_PARAM & ParamIndex) ' se uno dei paraemtri è completamente sbagliato allora restituisce falso e non riempo la NewCompoParam che rimane Nothing bIsFinished = Not ReadParam(ReadLine, NewCompoParam, ErrorList) @@ -332,7 +331,6 @@ Public Class Compo ' leggo il nome DDF e il nome, restituisco il nome solo se esiste un messaggio associato Private Function MsgControl(sDDFName As String, sName As String, ByRef sErrorList As String) As String - 'If IsNumeric(sName) Then ' se è numerico ma non esiste un messaggio associato Dim ErrorMsg As String = "Msg" & Trim(sName) If String.Equals(Utility.ReadMsg(sName), ErrorMsg) Then @@ -714,42 +712,34 @@ End Class Public Class TextBoxParam Inherits CompoParam Implements INotifyPropertyChanged + Dim dValue As Double = -1 - Private m_Value As String + Friend m_Value As String Public Property Value As String Get - ToolTipValue = m_Value Return m_Value End Get Set(value As String) m_Value = value - ToolTipValue = m_Value + NotifyPropertyChanged("ToolTipValue") m_IsModifyCompoParam = True m_rfSetTitle() End Set End Property - Friend Sub SetValue(value As String) - m_Value = value - ToolTipValue = m_Value - End Sub - - Private m_ToolTipValue As String = String.Empty - Public Property ToolTipValue As String + Public ReadOnly Property ToolTipValue As String Get - Return m_ToolTipValue - End Get - Set(value As String) - If StringToDouble(value, dValue) Then - m_ToolTipValue = DoubleToString(dValue, 4) + If StringToDouble(Value, dValue) Then + Return DoubleToString(dValue, 4) Else - m_ToolTipValue = "Invalid Expression" + Return "Invalid Expression" End If - NotifyPropertyChanged("ToolTipValue") - End Set + End Get End Property + + Private m_ComboValuelList As New List(Of String) Public Property ComboValuelList As List(Of String) Get diff --git a/DoorParameters/Door.vb b/DoorParameters/Door.vb index 832fa5b..0b27f6f 100644 --- a/DoorParameters/Door.vb +++ b/DoorParameters/Door.vb @@ -17,7 +17,7 @@ Public Class Door If m_IsModifyDoor Then Return True ' se esiste almeno un elemento nella lista dei componenti If Not IsNothing(Me.CompoList) Then - ' assegno ad una variabile locale il vallore della componente, e ripto per tutte le componenti della lista + ' assegno ad una variabile locale il vallore della componente, e ripeto per tutte le componenti della lista For IndexCompoList = 0 To Me.CompoList.Count - 1 Dim rCompo As Compo = Me.CompoList(IndexCompoList) If Me.CompoList(IndexCompoList).IsModify Then @@ -136,13 +136,10 @@ Public Class Door Else MessageBox.Show("Invalid Value", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk) End If - 'm_Height = value - ' se la variabile è diversa da zero significa che il primo settaggio delle variabili è avvenuto - 'If SetChange <> 0 Then - ' SetChange += 1 - 'End If m_IsModifyDoor = True SetTitle() + SetVarSize() + UpdateToolTip() NotifyPropertyChanged("Height") End Set End Property @@ -159,12 +156,10 @@ Public Class Door Else MessageBox.Show("Invalid Value", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk) End If - 'm_Width = value - 'If SetChange <> 0 Then - ' SetChange += 1 - 'End If m_IsModifyDoor = True SetTitle() + SetVarSize() + UpdateToolTip() End Set End Property @@ -180,11 +175,10 @@ Public Class Door Else MessageBox.Show("Invalid Value", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk) End If - 'If SetChange <> 0 Then - ' SetChange += 1 - 'End If m_IsModifyDoor = True SetTitle() + SetVarSize() + UpdateToolTip() End Set End Property @@ -210,9 +204,6 @@ Public Class Door End Get Set(value As Boolean) m_NewDoor = value - 'If SetChange <> 0 Then - ' SetChange += 1 - 'End If If m_NewDoor Then m_IsModifyDoor = True SetTitle() End Set @@ -485,11 +476,6 @@ Public Class Door NewCompo.TemplateName = Name NewCompo.TemplateItemList = TemplateList - ' se la lista delle componenti contiene già almeno un elemento - ''If CompoList.Count > 0 Then - '' NewCompo.SetTemplateSelItem(SetItemTemplate(NewCompo.CompoType.DDFName)) - ''End If - If Not SetItemTemplate(NewCompo.CompoType.DDFName) = String.Empty Then NewCompo.SetTemplateSelItem(SetItemTemplate(NewCompo.CompoType.DDFName)) Else @@ -502,7 +488,6 @@ Public Class Door SelItemindex += 1 End While ' inizializzo la combobox template - 'NewCompo.TemplateSelItem = NewCompo.TemplateItemList(SelItemindex) NewCompo.SetTemplateSelItem(NewCompo.TemplateItemList(SelItemindex)) End If @@ -551,6 +536,7 @@ Public Class Door Return CompoList.Count - 1 End Function + ' ricerco la stessa componente all'interno della lista di comopnenti, se non trovo nulla restituisco una stringa vuota Private Function SetItemTemplate(CompoName As String) As String Dim IndexCompo As Integer = 0 For IndexCompo = 0 To CompoList.Count - 1 @@ -568,6 +554,18 @@ Public Class Door SetTitle() End Sub + ' aggiorna il ToolTip delle TextBox + Private Sub UpdateToolTip() + For CompoIndex = 0 To m_CompoList.Count - 1 + For ParamIndex = 0 To m_CompoList(CompoIndex).CompoParamList.Count - 1 + If TypeOf m_CompoList(CompoIndex).CompoParamList(ParamIndex) Is TextBoxParam Then + Dim TextBoxParam As TextBoxParam = DirectCast(m_CompoList(CompoIndex).CompoParamList(ParamIndex), TextBoxParam) + TextBoxParam.NotifyPropertyChanged("ToolTipValue") + End If + Next + Next + End Sub + #Region "LETTURA DDF" ' Genero una nuova porta da usare nella lettura di un DDF 'Dim m_Door As New Door @@ -724,8 +722,8 @@ Public Class Door 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) @@ -1258,7 +1256,7 @@ Public Class Door 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).SetValue(sVal) + DirectCast(CurrCompoParam, TextBoxParam).m_Value = sVal End If ' se il nome esiste ma è sabgliato @@ -1295,7 +1293,7 @@ Public Class Door 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).SetValue(sVal) + DirectCast(CurrCompoParam, TextBoxOnOffParam).m_Value = sVal DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = True Else ' cerco un parametro successivo diff --git a/DoorParameters/DoorParametersView.xaml b/DoorParameters/DoorParametersView.xaml index bdb45ca..26f63f6 100644 --- a/DoorParameters/DoorParametersView.xaml +++ b/DoorParameters/DoorParametersView.xaml @@ -232,7 +232,7 @@ Style="{StaticResource DoorParamsTxBx}" IsEnabled="{Binding IsChecked, ElementName=ChBx}" Margin="0,0,0,2" - ToolTip="{Binding ToolTipValue}"/> + ToolTip="{Binding ToolTipValue,UpdateSourceTrigger=PropertyChanged}"/> diff --git a/DoorParameters/DoorParametersViewModel.vb b/DoorParameters/DoorParametersViewModel.vb index 5f98d40..5d126c9 100644 --- a/DoorParameters/DoorParametersViewModel.vb +++ b/DoorParameters/DoorParametersViewModel.vb @@ -47,13 +47,13 @@ Public Class DoorParametersViewModel Public ReadOnly Property EdgeMsg As String Get - Return "Edge Type" + Return EgtMsg(50044) End Get End Property Public ReadOnly Property OverMaterialMsg As String Get - Return "Over Material" + Return EgtMsg(50045) End Get End Property diff --git a/Doors.vb b/Doors.vb index 032ad66..dc9ec3a 100644 --- a/Doors.vb +++ b/Doors.vb @@ -20,7 +20,7 @@ Public Module Doors ' Scelta file DDF Dim sFile As String sFile = sFilePath - ' scrivo la nel file di configurazione il nome della directory + ' scrivo nel file di configurazione il nome della directory WritePrivateProfileString(S_DOORS, K_DDFDIR, System.IO.Path.GetDirectoryName(sFile)) ' Generazione porta diff --git a/ProjectManager/ProjectManagerViewModel.vb b/ProjectManager/ProjectManagerViewModel.vb index e9c3c02..c4b4149 100644 --- a/ProjectManager/ProjectManagerViewModel.vb +++ b/ProjectManager/ProjectManagerViewModel.vb @@ -68,7 +68,7 @@ Public Class ProjectManagerViewModel End Property Public ReadOnly Property SendFeedbackToolTip As String Get - Return "Send Feedback" + Return EgtMsg(50046) End Get End Property Public ReadOnly Property OptionsToolTip As String @@ -285,11 +285,11 @@ Public Class ProjectManagerViewModel DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel).bSetChange = False m_rfMainWindowViewModel.ProjectNameMsg = SetTitle Else - MessageBox.Show(EgtMsg(50128), "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation) + MessageBox.Show(EgtMsg(50128), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation) End If Else - MessageBox.Show(EgtMsg(50128), "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation) + MessageBox.Show(EgtMsg(50128), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation) End If End Sub diff --git a/SceneManager/Refresh/RefreshPanelViewModel.vb b/SceneManager/Refresh/RefreshPanelViewModel.vb index e718c95..838bc03 100644 --- a/SceneManager/Refresh/RefreshPanelViewModel.vb +++ b/SceneManager/Refresh/RefreshPanelViewModel.vb @@ -86,7 +86,7 @@ Public Class RefreshPanelViewModel End Property Public Sub ShowErrorBtn() - MessageBox.Show(m_MsgGraphic, "Error", MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(m_MsgGraphic, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) End Sub #End Region ' Command diff --git a/SceneManager/SceneManagerViewModel.vb b/SceneManager/SceneManagerViewModel.vb index 8f64223..8c3431c 100644 --- a/SceneManager/SceneManagerViewModel.vb +++ b/SceneManager/SceneManagerViewModel.vb @@ -193,8 +193,8 @@ Public Class SceneManagerViewModel Friend Sub ShowGraphicError() Dim FileContent() As String ' controllo se esite il file CurrDoor.txt - If Not File.Exists(IniFile.m_sTempDir & "\CurrDoor.txt") Then Return - FileContent = File.ReadAllLines(IniFile.m_sTempDir & "\CurrDoor.txt") + If Not File.Exists(IniFile.m_sTempDir & "\" & TEMP_FILE_TXT) Then Return + FileContent = File.ReadAllLines(IniFile.m_sTempDir & "\" & TEMP_FILE_TXT) ' se il file esiste ma è vuoto If FileContent.Count = 0 Then MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) @@ -217,7 +217,7 @@ Public Class SceneManagerViewModel DirectCast(Me.InstrumentPanel.DataContext, InstrumentPanelViewModel).GetDistIsChecked = False ' rendo visibile il bottone dell'errore DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).ButtonVisibility = Visibility.Visible - DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).MsgError = "Error=" & nMsgErr + DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).MsgError = EgtMsg(50101) & nMsgErr ' altrimenti un avvertimento ElseIf nMsgErr < 0 Then While String.IsNullOrEmpty(FileContent(IndexLine)) AndAlso IndexLine < FileContent.Count @@ -226,7 +226,7 @@ Public Class SceneManagerViewModel DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).m_MsgGraphic = FileContent(IndexLine) 'MessageBox.Show(FileContent(IndexLine), "Warning", MessageBoxButton.OK, MessageBoxImage.Warning) DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).ButtonVisibility = Visibility.Visible - DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).MsgError = "Warning=" & nMsgErr + DirectCast(Me.RefreshPanel.DataContext, RefreshPanelViewModel).MsgError = EgtMsg(50144) & nMsgErr End If If nMsgErr = 0 Then @@ -256,7 +256,7 @@ Public Class SceneManagerViewModel ''' Public Sub RefreshBtn() Dim rfDoorParametersViewModel As DoorParametersViewModel = DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel) - Dim CurrDoorPath As String = IniFile.m_sTempDir & "\CurrDoor.ddf" + Dim CurrDoorPath As String = IniFile.m_sTempDir & "\" & TEMP_FILE If Not IsNothing(rfDoorParametersViewModel.CurrDoor) AndAlso Not String.IsNullOrWhiteSpace(DirectCast(m_rfMainWindowViewModel.DoorManager.DataContext, DoorManagerViewModel).SelectedDoor) Then DdfFile.WriteDDF(rfDoorParametersViewModel.CurrDoor, CurrDoorPath) ExecDoors(m_ProjectScene, CurrDoorPath) diff --git a/StatusBar/StatusBarViewModel.vb b/StatusBar/StatusBarViewModel.vb index 0586edc..bc25430 100644 --- a/StatusBar/StatusBarViewModel.vb +++ b/StatusBar/StatusBarViewModel.vb @@ -27,28 +27,6 @@ Public Class StatusBarViewModel End Set End Property - ''Private m_MsgError As String - ''Public Property MsgError As String - '' Get - '' Return m_MsgError - '' End Get - '' Set(value As String) - '' m_MsgError = value - '' NotifyPropertyChanged("MsgError") - '' End Set - ''End Property - - ''Private m_ButtonVisibility As Visibility = Visibility.Collapsed - ''Public Property ButtonVisibility As Visibility - '' Get - '' Return m_ButtonVisibility - '' End Get - '' Set(value As Visibility) - '' m_ButtonVisibility = value - '' NotifyPropertyChanged("ButtonVisibility") - '' End Set - ''End Property - Private m_UnitMeasure As String = OptionModule.m_SelectedMeasureUnit Public Property UnitMeasure As String @@ -83,9 +61,6 @@ Public Class StatusBarViewModel #End Region ' Fields & Properties - '' Definizione comandi - 'Private m_CmdShowErrorBtn As ICommand - ' applica la selezione del punto notevole Public Sub ActivateSnapPointSelected(SnapPoint As SPItem) m_rfSceneManagerViewModel.ProjectScene.SetSnapPointType(SnapPoint.SPValue) @@ -99,30 +74,6 @@ Public Class StatusBarViewModel #End Region ' Constructor -#Region "COMMAND" - -#Region "ShowErrorCommand" - '' carico il valore del messaggio di errore - 'Friend m_MsgGraphic As String - - 'Public ReadOnly Property ShowErrorBtnCommand As ICommand - ' Get - ' If m_CmdShowErrorBtn Is Nothing Then - ' m_CmdShowErrorBtn = New Command(AddressOf ShowErrorBtn) - ' End If - ' Return m_CmdShowErrorBtn - ' End Get - 'End Property - - 'Public Sub ShowErrorBtn() - ' MessageBox.Show(m_MsgGraphic, "Error", MessageBoxButton.OK, MessageBoxImage.Error) - 'End Sub - -#End Region ' ShowErrorCommand - -#End Region ' Command - - Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Public Sub NotifyPropertyChanged(propName As String)