From 00784e5477d56e0eaec74e90547a88f824ec0f8f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 3 Jan 2018 18:26:27 +0000 Subject: [PATCH] EgtDOORCreator 1.8l8 : - migliorie varie a lettura/scrittura. --- Assembly/Assembly.vb | 180 ++-- AssemblyManager/AssemblyManagerVM.vb | 14 +- CompoPanel/CompoPanelVM.vb | 2 +- Constants/ConstCompo.vb | 117 ++- Constants/ConstIni.vb | 156 ++- DdfFile.vb | 224 ++-- DoorParameters/Compo.vb | 18 +- DoorParameters/Part.vb | 1405 ++++++++++---------------- IniFile.vb | 36 +- MainWindow/MainWindowModel.vb | 2 +- My Project/AssemblyInfo.vb | 4 +- OptionsWindow/OptionModule.vb | 48 +- OptionsWindow/OptionsViewModel.vb | 12 +- ProjectManager/ProjectManagerVM.vb | 20 +- RegexFunction.vb | 85 +- StatusBar/StatusBarVM.vb | 2 +- Utility.vb | 82 +- 17 files changed, 1050 insertions(+), 1357 deletions(-) diff --git a/Assembly/Assembly.vb b/Assembly/Assembly.vb index e44c32e..8ca22a9 100644 --- a/Assembly/Assembly.vb +++ b/Assembly/Assembly.vb @@ -698,9 +698,8 @@ Public Class Assembly Shared Sub ReadDDFAssembly(sPathDDF As String, ByRef ReadAssembly As Assembly) BuiltReffCompo = False ' restituisce un problema nella lettura di un valore della compo - Dim InvalidValue As String = String.Empty - InvalidValue += "In General Assembly:" + vbCrLf - ' controllo se esite il file DDF + Dim sErrorInfo As String = String.Empty + ' controllo se esiste il file DDF If Not File.Exists(sPathDDF) Then Return End If @@ -709,107 +708,100 @@ Public Class Assembly If ReadAssembly.FileContent.Count = 0 Then MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) End If - Dim bSecure As Boolean = False '--------------------------------------------------------------------------------------------------------------------------------- ' leggo riga per riga - Dim LineIndexDots As Integer = 0 - Dim IndexLine As Integer = LineIndexDots - ReadAssembly.GetGeneralAssembly(ReadAssembly, IndexLine, InvalidValue) + Dim IndexLine As Integer = 0 + Dim bOk As Boolean = ReadAssembly.GetGeneralAssembly(IndexLine, sErrorInfo) '--------------------------------------------------------------------------------------------------------------------------------- - If Not IsNothing(ReadAssembly) Then + If bOk Then If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Error in reading General Assembly in DDF" + vbCrLf) + sErrorInfo += String.Format(EgtMsg(50102), "Error in reading General Assembly in DDF" + vbCrLf) ReadAssembly = Nothing Else If ReadAssembly.GetDDFDoor(IndexLine) = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Door has not been founded in Assembly DDF" + vbCrLf) ReadAssembly = Nothing End If End If + Else + ReadAssembly = Nothing End If - If Not InvalidValue = "In General Assembly:" + vbCrLf Then - MessageBox.Show(InvalidValue, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) + If Not String.IsNullOrWhiteSpace(sErrorInfo) Then + sErrorInfo = "In General Assembly:" & vbCrLf & sErrorInfo + MessageBox.Show(sErrorInfo, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) End If End Sub - Public Function GetGeneralAssembly(ReadAssembly As Assembly, ByRef IndexLine As Integer, InvalidValue As String) As Boolean - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + Private Function GetGeneralAssembly(ByRef IndexLine As Integer, sErrorInfo As String) As Boolean + IndexLine = SkipWhiteSpace(IndexLine) ' Size - If IndexLine < ReadAssembly.FileContent.Count - 1 Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "Size") Then - IndexLine = ReadAssembly.GetSize(IndexLine + 1) + If IndexLine < FileContent.Count - 1 Then + If SearchKey(FileContent(IndexLine), "Size") Then + IndexLine = GetSize(IndexLine + 1) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Size" + vbCrLf) - ReadAssembly = Nothing - 'Exit For + sErrorInfo += String.Format(EgtMsg(50102), "Size" + vbCrLf) + Return False End If End If End If - If IndexLine = 0 Then Return False - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + If IndexLine = 0 Then Return True + IndexLine = SkipWhiteSpace(IndexLine) ' Light - If IndexLine < ReadAssembly.FileContent.Count - 1 Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "Light") Then - IndexLine = ReadAssembly.GetLight(IndexLine + 1) + If IndexLine < FileContent.Count - 1 Then + If SearchKey(FileContent(IndexLine), "Light") Then + IndexLine = GetLight(IndexLine + 1) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Light" + vbCrLf) - ReadAssembly = Nothing - ''Exit For + sErrorInfo += String.Format(EgtMsg(50102), "Light" + vbCrLf) + Return False End If End If End If - If IndexLine = 0 Then Return False - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + IndexLine = SkipWhiteSpace(IndexLine) ' Overlap - If IndexLine < ReadAssembly.FileContent.Count - 1 Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "Overlap") Then - IndexLine = ReadAssembly.GetOverlap(IndexLine + 1) + If IndexLine < FileContent.Count - 1 Then + If SearchKey(FileContent(IndexLine), "Overlap") Then + IndexLine = GetOverlap(IndexLine + 1) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Overlap" + vbCrLf) - ReadAssembly = Nothing - 'Exit For + sErrorInfo += String.Format(EgtMsg(50102), "Overlap" + vbCrLf) + Return False End If End If End If - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + IndexLine = SkipWhiteSpace(IndexLine) ' Exterior - If IndexLine < ReadAssembly.FileContent.Count - 1 Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "Exterior") Then - IndexLine = ReadAssembly.GetExterior(IndexLine + 1) + If IndexLine < FileContent.Count - 1 Then + If SearchKey(FileContent(IndexLine), "Exterior") Then + IndexLine = GetExterior(IndexLine + 1) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "Exterior" + vbCrLf) - ReadAssembly = Nothing - 'Exit For + sErrorInfo += String.Format(EgtMsg(50102), "Exterior" + vbCrLf) + Return False End If End If End If - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + IndexLine = SkipWhiteSpace(IndexLine) ' Profiles - If IndexLine < ReadAssembly.FileContent.Count - 1 Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "profiles") Then - IndexLine = ReadAssembly.GetProfiles(IndexLine + 1) + If IndexLine < FileContent.Count - 1 Then + If SearchKey(FileContent(IndexLine), "profiles") Then + IndexLine = GetProfiles(IndexLine + 1) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "profiles" + vbCrLf) - ReadAssembly = Nothing - 'Exit For + sErrorInfo += String.Format(EgtMsg(50102), "profiles" + vbCrLf) + Return False End If End If End If - IndexLine = ReadAssembly.SkipWhiteSpace(IndexLine) + IndexLine = SkipWhiteSpace(IndexLine) ' Doors - If IndexLine < ReadAssembly.FileContent.Count Then - If SearchKey(ReadAssembly.FileContent(IndexLine), "doors") Then + If IndexLine < FileContent.Count Then + If SearchKey(FileContent(IndexLine), "doors") Then ' in questo modo non passo dalla proprietà ( in breve quello che accadrebbe usando il metodo Set) - IndexLine = ReadAssembly.GetValue(IndexLine, "doors", ReadAssembly.m_DoorNumber) + IndexLine = GetValue(IndexLine, "doors", m_DoorNumber) If IndexLine = -1 Then - InvalidValue += String.Format(EgtMsg(50102), "doors" + vbCrLf) - ReadAssembly = Nothing - 'Exit For + sErrorInfo += String.Format(EgtMsg(50102), "doors" + vbCrLf) + Return False End If ' se sono arrivato fino a qui significa che ormai è terminata la pagina - If IsNothing(ReadAssembly.m_Exterior) Or Not ReadAssembly.m_Exterior Then - ReadAssembly.m_Exterior = False - ReadAssembly.m_OverlapTop = OptionModule.m_OverlapTop + If IsNothing(m_Exterior) OrElse Not m_Exterior Then + m_Exterior = False + m_OverlapTop = OptionModule.m_OverlapTop End If End If End If @@ -817,12 +809,10 @@ Public Class Assembly End Function ' salta le righe che non contengono un metadata - Public Function SkipWhiteSpace(Index As Integer) As Integer + Private Function SkipWhiteSpace(Index As Integer) As Integer Dim ExitLoop As Boolean = False While Not ExitLoop And Index < FileContent.Count - 1 If FileContent(Index).Contains("##") Then - Dim x = Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*:\s*$").Groups(1).Value - Dim y = Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*:\s*(.*?\b)$").Groups(1).Value If Not String.IsNullOrWhiteSpace(Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*:\s*$").Groups(1).Value) Then ExitLoop = True ElseIf Not String.IsNullOrWhiteSpace(Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*:\s*(.*?\b)$").Groups(1).Value) Then @@ -845,22 +835,16 @@ Public Class Assembly ' funzione per la ricerca dei valori, restituice la riga successiva Private Function GetValue(Index As Integer, Name As String, ByRef Var As String) As Integer - If Index = -1 Then - Return Index + If Index = -1 Then Return -1 + Dim Local_Var As String = GetValueWithKey(FileContent(Index), Name) + If String.IsNullOrWhiteSpace(Local_Var) Then + ' se non c'è la parola chiave allora esci + If Not SearchKey(FileContent(Index), Name) Then Return -1 + ' altrimenti lascia il valore vuoto Else - Dim Local_Var As String = SearchKeyValue(FileContent(Index), Name) - If String.IsNullOrWhiteSpace(Local_Var) Then - ' se non c'è la parola chiave allora esci - If Not SearchKey(FileContent(Index), Name) Then Return -1 - ' altrimenti lascia il valore vuoto - Index += 1 - Return Index - Else - Var = Local_Var - Index += 1 - Return Index - End If + Var = Local_Var End If + Return Index + 1 End Function ' funzione per la ricerca dei profili, restituisce la riga successiva @@ -872,7 +856,7 @@ Public Class Assembly Else ' Lock Dim Bevel As String - Bevel = SearchKeyValue(FileContent(Index), Name) + Bevel = GetValueWithKey(FileContent(Index), Name) ' se il valore restituito è nullo o vuoto If String.IsNullOrWhiteSpace(Bevel) Then ' se non c'è la parola chiave allora esci @@ -911,7 +895,7 @@ Public Class Assembly If Index = -1 Then Return Index Else - Dim Machining = SearchKeyValue(FileContent(Index), K_MACHINING) + Dim Machining = GetValueWithKey(FileContent(Index), K_MACHINING) If String.IsNullOrWhiteSpace(Machining) Then If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1 Index += 1 @@ -923,7 +907,7 @@ Public Class Assembly If Index = -1 Then Return Index Else - VarOverMaterial = SearchKeyValue(FileContent(Index), K_OVERMATERIAL) + VarOverMaterial = GetValueWithKey(FileContent(Index), K_OVERMATERIAL) If String.IsNullOrWhiteSpace(VarOverMaterial) Then If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1 Index += 1 @@ -943,7 +927,7 @@ Public Class Assembly End Sub ' Size - Friend Function GetSize(Index As Integer) As Integer + Private Function GetSize(Index As Integer) As Integer If Index = -1 Then Return -1 Index = GetValue(Index, "thickness", m_Thickness) If Index = -1 Then Return -1 @@ -952,7 +936,7 @@ Public Class Assembly End Function ' light - Friend Function GetLight(Index As Integer) As Integer + Private Function GetLight(Index As Integer) As Integer If Index = -1 Then Return -1 Index = GetValue(Index, "up", m_LightUp) If Index = -1 Then Return -1 @@ -963,8 +947,9 @@ Public Class Assembly Index = GetValue(Index, "bottom", m_LightBottom) Return Index End Function + ' Overlap - Friend Function GetOverlap(Index As Integer) As Integer + Private Function GetOverlap(Index As Integer) As Integer If Index = -1 Then Return -1 Index = GetValue(Index, "thickness", m_ThicknessHead) If Index = -1 Then Return -1 @@ -977,7 +962,7 @@ Public Class Assembly End Function ' Profiles - Friend Function GetProfiles(Index As Integer) As Integer + Private Function GetProfiles(Index As Integer) As Integer If Index = -1 Then Return -1 Index = GetValueProfiles(Index, K_LOCKEDGE, m_LockEdgeType, m_LockEdgeMachining, m_LockEdgeOverMaterial) If Index = -1 Then Return -1 @@ -990,7 +975,7 @@ Public Class Assembly End Function ' exterior - Friend Function GetExterior(Index As Integer) As Integer + Private Function GetExterior(Index As Integer) As Integer m_Exterior = True If Index = -1 Then Return -1 Index = GetValue(Index, "top", m_OverlapTop) @@ -999,7 +984,7 @@ Public Class Assembly Return Index End Function - Public Function GetDDFDoor(IndexLine As Integer) As Integer + Private Function GetDDFDoor(IndexLine As Integer) As Integer Dim Line As Integer = IndexLine While Line < FileContent.Count - 1 AndAlso Not Search3Dots(FileContent(Line)) Dim Local_Door As New Part @@ -1180,29 +1165,30 @@ Public Class Assembly End Sub #End Region ' Associazione delle compo lette da ddf - ' Agiorna IsVisible delle porte contenute nell'ArrayPartDoor + ' Aggiorna IsVisible delle porte contenute nell'ArrayPartDoor Public Sub DoorVisibility() + Dim nDoorNumber As Integer = 1 + Integer.TryParse(m_DoorNumber, nDoorNumber) ' aggiorno la visibilità delle porte senza però modificare la dimensione dei Jamb caricati - For Index As Integer = 0 To CInt(m_DoorNumber) - 1 + For Index As Integer = 0 To nDoorNumber - 1 If Not IsNothing(m_ArrayPartDoor(Index)) Then m_ArrayPartDoor(Index).IsVisible = Visibility.Visible m_ArrayPartDoor(Index).NotifyPropertyChanged("IsVisible") End If Next - For Index As Integer = CInt(m_DoorNumber) To K_DOORNUMBER + For Index As Integer = nDoorNumber To MAX_DOORNUMBER If Not IsNothing(m_ArrayPartDoor(Index)) Then m_ArrayPartDoor(Index).IsVisible = Visibility.Collapsed m_ArrayPartDoor(Index).NotifyPropertyChanged("IsVisible") End If Next If Not IsNothing(GetArrayPartDoor(0).Door) Then - If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then m_DoorNumber = "1" - End If - If m_DoorNumber = "1" Then - OneDoorProperty = True - Else - OneDoorProperty = False + If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then + m_DoorNumber = "1" + nDoorNumber = 1 + End If End If + OneDoorProperty = (nDoorNumber = 1) NotifyPropertyChanged("CurrAssembly") End Sub #End Region ' Lettura Assemblato @@ -1261,7 +1247,7 @@ Public Class Assembly UpDateCurrCompoJamb(CurrCompo) ResetCompoParam() Else - MessageBox.Show("Script Lua (" & CurrCompo.CompoType.Path & "\" & "Matching.lua" & ")has not been found", "Error", MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show("Script Lua (" & CurrCompo.CompoType.Path & "\" & MATCHING_FILE_NAME & ")has not been found", "Error", MessageBoxButton.OK, MessageBoxImage.Error) End If End If Next @@ -1462,7 +1448,7 @@ Public Class Assembly m_ArrayPartDoor(Index).NotifyPropertyChanged("TypePart") End If Next - For Index As Integer = CInt(m_DoorNumber) To K_DOORNUMBER + For Index As Integer = CInt(m_DoorNumber) To MAX_DOORNUMBER If Not IsNothing(m_ArrayPartDoor(Index)) Then m_ArrayPartDoor(Index).IsVisible = Visibility.Collapsed m_ArrayPartDoor(Index).NotifyPropertyChanged("IsVisible") diff --git a/AssemblyManager/AssemblyManagerVM.vb b/AssemblyManager/AssemblyManagerVM.vb index 28ef9e2..ea0120b 100644 --- a/AssemblyManager/AssemblyManagerVM.vb +++ b/AssemblyManager/AssemblyManagerVM.vb @@ -293,7 +293,7 @@ Public Class AssemblyManagerVM ' qui carico il vettore delle porte (se il vettore è vuoto) Dim ref_PartDoor As PartDoor Dim ref_Door As Part - For IndexDoor As Integer = 0 To K_DOORNUMBER + For IndexDoor As Integer = 0 To MAX_DOORNUMBER ref_PartDoor = New PartDoor ref_Door = New Part ref_Door.TypePart = "DO_" & IndexDoor + 1 @@ -316,7 +316,7 @@ Public Class AssemblyManagerVM ' i parametri che seguono non influenzano in alcun modo i jamb ref_Part.SetSwing(OptionModule.m_Swing) ref_Part.IsActive = False - ref_Part.Measure = OptionModule.m_SelectedMeasureUnit + ref_Part.Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit) ref_Part.Weight = OptionModule.m_Weight ref_Part.SetLockEdgeType(OptionModule.m_LockEdgeType) ref_Part.SetHingeEdgeType(OptionModule.m_HingeEdgeType) @@ -389,19 +389,19 @@ Public Class AssemblyManagerVM ' Creo nuovo assembly ' Lancio la finestra per chiedere il nome dell'assemblato Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog - SaveFileDialog.Title = K_NEWDOOR + SaveFileDialog.Title = "New Door" SaveFileDialog.Directory = m_CurrProject.Name - SaveFileDialog.Extension = K_DDFEXTENSION + SaveFileDialog.Extension = DDF_EXTENSION ' Se annullo esco If Not SaveFileDialog.EgtShowDialog Then Return ' Controllo se il nome della porta ha estensione If Path.HasExtension(SaveFileDialog.FileName) Then Dim sExtension As String = Path.GetExtension(SaveFileDialog.FileName) - If Not sExtension.ToLower = K_DDFEXTENSION Then - SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, K_DDFEXTENSION) + If Not sExtension.ToLower = DDF_EXTENSION Then + SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, DDF_EXTENSION) End If Else - SaveFileDialog.FileName &= K_DDFEXTENSION + SaveFileDialog.FileName &= DDF_EXTENSION End If ' controllo che il nome non sia presente nella lista degli assemblati Dim bNameExist As Boolean = False diff --git a/CompoPanel/CompoPanelVM.vb b/CompoPanel/CompoPanelVM.vb index 1d3b967..4589ee1 100644 --- a/CompoPanel/CompoPanelVM.vb +++ b/CompoPanel/CompoPanelVM.vb @@ -69,7 +69,7 @@ Public Class CompoPanelVM Dim CurrCompoPath As String = CompoArray(Index) & "\" & ConstCompo.CONFIGINI_FILE_NAME If File.Exists(CurrCompoPath) Then GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, CompoNameDDF, CompoName, CurrCompoPath) - GetPrivateProfileJambSide("PositionSide", "Side", Side, CurrCompoPath) + GetPrivateProfileJambSide(S_POSITIONSIDE, K_SIDE, Side, CurrCompoPath) If CompoPanelList(IndexCompoOrder) = CompoNameDDF Then m_CompoTypeList.Add(New CompoType(CompoName, CompoNameDDF, CompoArray(Index), Side)) Exit For diff --git a/Constants/ConstCompo.vb b/Constants/ConstCompo.vb index bf3d833..ae125aa 100644 --- a/Constants/ConstCompo.vb +++ b/Constants/ConstCompo.vb @@ -1,76 +1,85 @@ '---------------------------------------------------------------------------- -' EgalTech 2015-2015 +' EgalTech 2017-2018 '---------------------------------------------------------------------------- -' File : ConstCompo.vb Data : 12.02.15 Versione : 1.6b3 -' Contenuto : Modulo costanti sezione e chiavi per file Ini. +' File : ConstCompo.vb Data : 02.01.18 Versione : 1.8l8 +' Contenuto : Modulo costanti sezione e chiavi per file Ddf e Ini. ' ' ' -' Modifiche : 12.02.15 DS Creazione modulo. +' Modifiche : 12.02.17 DS Creazione modulo. ' ' '---------------------------------------------------------------------------- Module ConstCompo - Public Const COMPOINI_FILE_NAME As String = "Compo.ini" - Public Const CONFIGINI_FILE_NAME As String = "Config.ini" - - Public Const K_MEASURES As String = "measures" - - Public Const K_CODE As String = "code" - + ' Sezioni e chiavi standard del file DDF + Public Const S_PRODUCE As String = "produce" + Public Const S_MEASURES As String = "measures" + Public Const S_CODE As String = "code" Public Const S_ORDER As String = "order" - Public Const K_CUSTOMER As String = "customer" - Public Const K_ELEVATION As String = "elevation" - Public Const K_PROJECT As String = "project" - Public Const K_PO As String = "PO" - Public Const K_LINE As String = "Line" - - Public Const K_DATE As String = "date" - Public Const K_FRAME As String = "frame" + Public Const K_CUSTOMER As String = "customer" + Public Const K_ELEVATION As String = "elevation" + Public Const K_PROJECT As String = "project" + Public Const K_PO As String = "PO" + Public Const K_LINE As String = "Line" + Public Const S_DATE As String = "date" + Public Const S_PIECE As String = "piece" + Public Const S_POSITION As String = "position" + Public Const K_X As String = "x" + Public Const K_Y As String = "y" + Public Const K_Z As String = "z" + Public Const S_SIZE As String = "size" + Public Const K_WIDTH As String = "width" + Public Const K_HEIGHT As String = "height" + Public Const K_THICKNESS As String = "thickness" + Public Const S_WEIGHT As String = "pressure" + Public Const S_SWING As String = "swing" + Public Const S_SECURE As String = "secure" + Public Const S_PROFILES As String = "profiles" + Public Const K_LOCKEDGE As String = "lockedge" + Public Const K_HINGEEDGE As String = "hingeedge" + Public Const K_TOP As String = "top" + Public Const K_BOTTOM As String = "bottom" + Public Const K_MACHINING As String = "machining" + Public Const K_OVERMATERIAL As String = "overmaterial" + Public Const K_IDCODECOMPONENT As String = "IdCodeComponent" + ' Nome, sezioni e chiavi del file Config.ini + Public Const CONFIGINI_FILE_NAME As String = "Config.ini" Public Const S_COMPO As String = "Compo" + Public Const K_NAME As String = "Name" Public Const S_TEMPLATE As String = "Template" - Public Const K_NAME As String = "Name" - Public Const K_ISACTIVE As String = "IsActive" - Public Const K_COMPO As String = "Compo" + Public Const K_ISACTIVE As String = "IsActive" + ' K_NAME come sopra indicato + Public Const K_COMPO As String = "Compo" Public Const S_NGECONFIG As String = "NgeConfig" - Public Const K_PARAM As String = "Param" + Public Const K_DEFAULT As String = "Default" + Public Const S_POSITIONSIDE As String = "PositionSide" + Public Const K_SIDE As String = "Side" Public Const S_GR_PARAM_DEFAULT = "Graphic parameters" - Public Const K_DEFAULT As String = "Default" + Public Const K_PARAM As String = "Param" - Public Const K_SIZE As String = "size" - Public Const K_WIDTH As String = "width" - Public Const K_HEIGHT As String = "height" - Public Const K_THICKNESS As String = "thickness" - Public Const K_SWING As String = "swing" - Public Const K_WEIGHT As String = "pressure" - Public Const K_SECURE As String = "secure" - Public Const K_PROFILES As String = "profiles" - Public Const K_LOCKEDGE As String = "lockedge" - Public Const K_MACHINING As String = "machining" - Public Const K_OVERMATERIAL As String = "overmaterial" - Public Const K_HINGEEDGE As String = "hingeedge" - Public Const K_TOP As String = "top" - Public Const K_BOTTOM As String = "bottom" - Public Const K_SCORE As String = " - " - Public Const K_SPACE3 As String = " " + ' Alcune stringhe notevoli dei file DDF + Public Const DDF_HYPHEN As String = " - " + Public Const DDF_SPACE3 As String = " " + Public Const DDF_SPACE5 As String = " " + Public Const DDF_METADATA As String = "##" + Public Const DDF_ON As String = "ON" + Public Const DDF_OFF As String = "OFF" + Public Const DDF_PARTIALEND As String = "---" + Public Const DDF_END As String = "..." - Public Const K_METADATA As String = "##" + ' Estensioni notevoli di file + Public Const DDF_EXTENSION As String = ".ddf" + Public Const DDT_EXTENSION As String = ".ddt" + Public Const LUA_EXTENSION As String = ".lua" + Public Const NGE_EXTENSION As String = ".nge" - Public Const K_SPACE5 As String = " " - Public Const K_PARTIALEND As String = " --- " - Public Const K_END As String = " ... " - 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_NEWTEMPLATE As String = "New Template" - Public Const K_DDFEXTENSION As String = ".ddf" - Public Const K_NGEEXTENSION As String = ".nge" - Public Const K_LUAEXTENSION As String = ".lua" - Public Const K_DDTEXTENSION As String = ".ddt" + ' Nome file di matching tra componenti su ante e telaio + Public Const MATCHING_FILE_NAME As String = "Matching.lua" + + ' Numero massimo di ante in una singola porta + Public Const MAX_DOORNUMBER As Integer = 5 - Public Const K_DOORNUMBER As Integer = 5 End Module diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 1e3a208..aa6ff13 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -12,7 +12,7 @@ '---------------------------------------------------------------------------- Module ConstIni - + '------------------------------------------------------------------------- Public Const INI_FILE_NAME As String = "EgtDOORCreator.ini" Public Const S_GENERAL As String = "General" @@ -25,81 +25,12 @@ Module ConstIni Public Const K_MESSAGES As String = "Messages" Public Const K_WINPLACE As String = "WinPlace" Public Const K_SUPPORT As String = "Support" - - Public Const S_SIZE As String = "Size" - Public Const K_WIDTH_INI As String = "Width" - Public Const K_HEIGHT_INI As String = "Height" - Public Const K_THICKNESS_INI As String = "Thickness" - Public Const K_WEIGHT_INI As String = "Weight" - Public Const K_WEIGHTISCHECKED_INI As String = "WeightIsChecked" - Public Const K_SWING_LIST_INI As String = "SwingList" - Public Const K_SWING_INI As String = "Swing" - - Public Const S_EDGE As String = "Edge" - Public Const K_EDGETYPE_LIST_INI As String = "EdgeTypeList" - Public Const K_LOCKEDGE_INI As String = "LockEdge" - Public Const K_HINGEDGE_INI As String = "HingeEdge" - Public Const K_TOPEDGE_INI As String = "TopEdge" - Public Const K_BOTTOMEDGE_INI As String = "BottomEdge" - Public Const K_BEVELU_INI As String = "BevelUp" - Public Const K_BEVELD_INI As String = "BevelDowm" - - Public Const K_CONFIGURATION As String = "Configuration" - Public Const S_RUNAS As String = "RunAs" - Public Const S_MACHININGASSEMBLY As String = "MachiningAssembly" - - Public Const S_MACHINING As String = "Machining" - Public Const K_LOCKEDGEISCHECKED_INI As String = "LockEdgeIsChecked" - Public Const K_HINGEDGEEISCHECKED_INI As String = "HingeEdgeIsChecked" - Public Const K_TOPISCHECKED_INI As String = "TopEdgeIsChecked" - Public Const K_BOTTOMISCHECKED_INI As String = "BottomEdgeIsChecked" - - Public Const S_OVERMATERIALASSEMBLY As String = "OverMaterialAssembly" - - Public Const S_OVERMATERIAL As String = "OverMaterial" - Public Const K_LOCKEDGEOVERMATERIAL_INI As String = "LockEdgeOverMaterial" - Public Const K_HINGEDGEOVERMATERIAL_INI As String = "HingeEdgeOverMaterial" - Public Const K_TOPOVERMATERIAL_INI As String = "TopEdgeOverMaterial" - Public Const K_BOTTOMOVERMATERIAL_INI As String = "BottomEdgeOverMaterial" - - Public Const S_COMPOORDER As String = "CompoOrder" - Public Const K_COMPOORDER_INI As String = "CompoDDFOrder" - Public Const S_COMPOOPANELORDER_INI As String = "CompoPanelOrder" - - Public Const S_LIGHT As String = "Light" - Public Const K_LIGHTUP As String = "LightUp" - Public Const K_LIGHTBOTTOM As String = "LightBottom" - Public Const K_LIGHTHINGE As String = "LightHinge" - Public Const K_LIGHTLOCK As String = "LightLock" - - Public Const S_SIZEJAMB As String = "SizeJamb" - Public Const S_OVERLAP As String = "Overlap" - Public Const K_OVERLAPTOP As String = "OverlapTop" - Public Const K_OVERLAPHINGE As String = "OverlapHinge" - Public Const K_OVERLAPLOCK As String = "OverlapLock" - Public Const K_EXTERIOR As String = "Exterior" - Public Const K_DELTAT As String = "DeltaT" - Public Const K_THICKNESSHEAD As String = "ThicknessHead" - - Public Const S_EDGEASSEMBLY = "EdgeAssembly" - - Public Const S_PART As String = "Part" - Public Const K_TOPJAMB As String = "TopJamb" - Public Const K_LEFTJAMB As String = "LeftJamb" - Public Const K_BOTTOMJAMB As String = "BottomJamb" - Public Const K_RIGHTJAMB As String = "RightJamb" - - Public Const S_DOORSNUMBER As String = "DoorsNumber" - Public Const K_DOORSLISTNUMBER As String = "DoorsNumberList" - Public Const K_DOORSELECTEDTNUMBER As String = "DoorsNumberSelected" + Public Const K_RUNAS As String = "RunAs" + Public Const K_DISPOSITION As String = "Disposition" Public Const S_LANGUAGES As String = "Languages" Public Const K_LANGUAGE As String = "Language" - Public Const S_LAUNCHERWINDOW As String = "LauncherWindow" - Public Const K_LAUNCHER As String = "Launcher" - Public Const K_LASTPROJECT As String = "LastProject" - Public Const S_LUA As String = "Lua" Public Const K_LIBSDIR As String = "LibsDir" Public Const K_BASELIB As String = "BaseLib" @@ -129,18 +60,6 @@ Module ConstIni Public Const K_DISTLINE As String = "DistLine" Public Const K_MMUNITS As String = "MmUnits" - Public Const S_GRID As String = "Grid" - Public Const K_DRAWSHOWGRID As String = "DrawShowGrid" - Public Const K_MACHININGSHOWGRID As String = "MachiningShowGrid" - Public Const K_SHOWFRAME As String = "ShowFrame" - Public Const K_SNAPSTEP As String = "SnapStep" - Public Const K_SNAPSTEPINCH As String = "SnapStepInch" - Public Const K_MINLINESSTEP As String = "MinLineSStep" - Public Const K_MAJLINESSTEP As String = "MajLineSStep" - Public Const K_EXTSSTEP As String = "ExtSStep" - Public Const K_MINLNCOLOR As String = "MinLnColor" - Public Const K_MAJLNCOLOR As String = "MajLnColor" - Public Const S_DOORS As String = "Doors" Public Const K_BASEDIR As String = "BaseDir" Public Const K_DDFEXEC As String = "DdfExec" @@ -149,4 +68,73 @@ Module ConstIni Public Const K_TEMPLATEDIR As String = "TemplateDirectory" Public Const K_MACHINDIR As String = "MachinDirectory" + Public Const S_LAUNCHERWINDOW As String = "LauncherWindow" + Public Const K_LAUNCHER As String = "Launcher" + Public Const K_LASTPROJECT As String = "LastProject" + + '------------------------------------------------------------------------- + Public Const DEFAULT_INI_FILE_NAME As String = "Default.ini" + + Public Const S_SIZE_INI As String = "Size" + Public Const K_WIDTH_INI As String = "Width" + Public Const K_HEIGHT_INI As String = "Height" + Public Const K_THICKNESS_INI As String = "Thickness" + Public Const K_WEIGHT_INI As String = "Weight" + Public Const K_WEIGHTISCHECKED_INI As String = "WeightIsChecked" + Public Const K_SWING_LIST_INI As String = "SwingList" + Public Const K_SWING_INI As String = "Swing" + + Public Const S_EDGE As String = "Edge" + Public Const S_EDGEASSEMBLY = "EdgeAssembly" + Public Const K_EDGETYPE_LIST_INI As String = "EdgeTypeList" + Public Const K_LOCKEDGE_INI As String = "LockEdge" + Public Const K_HINGEDGE_INI As String = "HingeEdge" + Public Const K_TOPEDGE_INI As String = "TopEdge" + Public Const K_BOTTOMEDGE_INI As String = "BottomEdge" + Public Const K_BEVELU_INI As String = "BevelUp" + Public Const K_BEVELD_INI As String = "BevelDowm" + + Public Const S_MACHINING As String = "Machining" + Public Const S_MACHININGASSEMBLY As String = "MachiningAssembly" + Public Const K_LOCKEDGEISCHECKED_INI As String = "LockEdgeIsChecked" + Public Const K_HINGEDGEEISCHECKED_INI As String = "HingeEdgeIsChecked" + Public Const K_TOPISCHECKED_INI As String = "TopEdgeIsChecked" + Public Const K_BOTTOMISCHECKED_INI As String = "BottomEdgeIsChecked" + + Public Const S_OVERMATERIAL As String = "OverMaterial" + Public Const S_OVERMATERIALASSEMBLY As String = "OverMaterialAssembly" + Public Const K_LOCKEDGEOVERMATERIAL_INI As String = "LockEdgeOverMaterial" + Public Const K_HINGEDGEOVERMATERIAL_INI As String = "HingeEdgeOverMaterial" + Public Const K_TOPOVERMATERIAL_INI As String = "TopEdgeOverMaterial" + Public Const K_BOTTOMOVERMATERIAL_INI As String = "BottomEdgeOverMaterial" + + Public Const S_COMPOORDER As String = "CompoOrder" + Public Const K_COMPOORDER_INI As String = "CompoDDFOrder" + Public Const S_COMPOOPANELORDER_INI As String = "CompoPanelOrder" + + Public Const S_LIGHT As String = "Light" + Public Const K_LIGHTUP As String = "LightUp" + Public Const K_LIGHTBOTTOM As String = "LightBottom" + Public Const K_LIGHTHINGE As String = "LightHinge" + Public Const K_LIGHTLOCK As String = "LightLock" + + Public Const S_SIZEJAMB As String = "SizeJamb" + Public Const S_OVERLAP As String = "Overlap" + Public Const K_OVERLAPTOP As String = "OverlapTop" + Public Const K_OVERLAPHINGE As String = "OverlapHinge" + Public Const K_OVERLAPLOCK As String = "OverlapLock" + Public Const K_EXTERIOR As String = "Exterior" + Public Const K_DELTAT As String = "DeltaT" + Public Const K_THICKNESSHEAD As String = "ThicknessHead" + + Public Const S_PART As String = "Part" + Public Const K_TOPJAMB As String = "TopJamb" + Public Const K_LEFTJAMB As String = "LeftJamb" + Public Const K_BOTTOMJAMB As String = "BottomJamb" + Public Const K_RIGHTJAMB As String = "RightJamb" + + Public Const S_DOORSNUMBER As String = "DoorsNumber" + Public Const K_DOORSLISTNUMBER As String = "DoorsNumberList" + Public Const K_DOORSELECTEDTNUMBER As String = "DoorsNumberSelected" + End Module diff --git a/DdfFile.vb b/DdfFile.vb index 70b3692..968e59f 100644 --- a/DdfFile.vb +++ b/DdfFile.vb @@ -7,7 +7,6 @@ Friend Module DdfFile ' lista ordinata delle componenti da stampare Friend CompoListOrder As New List(Of String) - Friend UnitMeasure As String #Region "SCRITTURA DDF" @@ -18,24 +17,16 @@ Friend Module DdfFile ' pulisco lista prima di iniziare a scrivere Dim DdfFileContent As New List(Of String) ' quindi significa che non è mai stato caricato il valore - If IsNothing(Part.Measure) Then - Part.Measure = OptionModule.m_SelectedMeasureUnit - End If DdfFileContent.Add("#EGTDOORCREATOR") If Not IsNothing(Part.TypePart) Then DdfFileContent.Add("#" & PrintTitleDDFPart(Part.TypePart)) - If Part.IsActive Then - DdfFileContent.Add("produce: " & "true") - Else - DdfFileContent.Add("produce: " & "false") - End If End If DdfFileContent.Add("") + DdfFileContent.Add("produce: " & If(Part.IsActive, "true", "false")) 'Genero una lista di stringhe - If Part.Measure = "Inches" Then - Part.Measure = "inches" - End If - DdfFileContent.Add(ConstCompo.K_MEASURES & ": " & Part.Measure) + DdfFileContent.Add("") + If IsNothing(Part.Measure) Then Part.Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit) + DdfFileContent.Add(ConstCompo.S_MEASURES & ": " & Part.Measure) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then @@ -43,15 +34,15 @@ Friend Module DdfFile If Part.Code.Contains("*") Then Part.Code = Part.Code.Replace("*", "") End If - DdfFileContent.Add(ConstCompo.K_CODE & ": " & Part.Code) + DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) DdfFileContent.Add("") ElseIf Not IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then Part.Code = " " & PrintTitleDDFPart(Part.TypePart) - DdfFileContent.Add(ConstCompo.K_CODE & ": " & Part.Code) + DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") ElseIf IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then - DdfFileContent.Add(ConstCompo.K_CODE & ": " & "1111") + DdfFileContent.Add(ConstCompo.S_CODE & ": " & "1111") ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") End If @@ -59,33 +50,33 @@ Friend Module DdfFile DdfFileContent.Add(ConstCompo.S_ORDER & ":") ' Probabilmente da cambiare If Not IsNothing(Part.Customer) Then - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_CUSTOMER & ": " & Part.Customer) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": " & Part.Customer) Else - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_CUSTOMER & ": ") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": ") End If If Not IsNothing(Part.Elevation) Then - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_ELEVATION & ": " & Part.Elevation) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": " & Part.Elevation) Else - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_ELEVATION & ": ") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": ") End If If Not IsNothing(Part.Project) Then - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PROJECT & ": " & Part.Project) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": " & Part.Project) Else - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PROJECT & ": ") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": ") End If If Not IsNothing(Part.PO) Then - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PO & ": " & Part.PO) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": " & Part.PO) Else - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PO & ": ") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": ") End If If Not IsNothing(Part.Line) Then - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LINE & ": " & Part.Line) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": " & Part.Line) Else - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LINE & ": ") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": ") End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") - DdfFileContent.Add(ConstCompo.K_DATE & ":" & " " & System.DateTime.Now.ToString("dd/MM/yyyy")) + DdfFileContent.Add(ConstCompo.S_DATE & ":" & " " & System.DateTime.Now.ToString("dd/MM/yyyy")) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") ' è specificato il tipo significa che abbiamo un assemblato @@ -97,9 +88,9 @@ Friend Module DdfFile ' il posizionamento della prima porta sta nell'origine If Part.TypePart = "DO_1" Then DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & "0") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & "0") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & "0") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & "0") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & "0") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & "0") ElseIf Part.TypePart = "DO_2" Then ' si trova traslata verso destra dello spessore DO_1 sommato a LightLock" Dim x_DO_1 As Double @@ -108,103 +99,104 @@ Friend Module DdfFile StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightLock, dLightLock) Dim x As String = DoubleToString(x_DO_1 + dLightLock, 4) DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & x) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & "0") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & "0") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & x) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & "0") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & "0") ' Jamb Sinistro serratura ElseIf Part.TypePart.Contains("FL_") Then Dim x As String = PositionJamb_X(Part) Dim y As String = PositionJamb_Y(Part) Dim z As String = PositionJamb_Z(Part) DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & x) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & y) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & z) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & x) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & y) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & z) ElseIf Part.TypePart.Contains("FR_") Then DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains("FT_") Then DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains("FB_") Then DdfFileContent.Add("position: ") - DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) End If DdfFileContent.Add("") End If End If Dim dVal As Double = 0 - DdfFileContent.Add(ConstCompo.K_SIZE & ":") + DdfFileContent.Add(ConstCompo.S_SIZE & ":") If Not StringToDouble(Part.Width, dVal) Then 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)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & DoubleToString(dVal, 5)) If Not StringToDouble(Part.Height, dVal) Then 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)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & DoubleToString(dVal, 5)) If Not StringToDouble(Part.Thickness, dVal) Then 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)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5)) ' aggiungo il peso della porta If Part.IsCheckedWeight = Visibility.Visible Then If Not StringToDouble(Part.Weight, dVal) Then - MessageBox.Show(EgtMsg(50106) & K_WEIGHT, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(EgtMsg(50106) & S_WEIGHT, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_WEIGHT & ": " & Part.Weight) + DdfFileContent.Add("") + DdfFileContent.Add(ConstCompo.S_WEIGHT & ": " & Part.Weight) End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") - DdfFileContent.Add("" & ConstCompo.K_SWING & ": " & Part.Swing) + DdfFileContent.Add("" & ConstCompo.S_SWING & ": " & Part.Swing) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- ' aggiungo il secure nullo al DDF - DdfFileContent.Add("" & ConstCompo.K_SECURE & ": " & SetSecure(Part.Swing, Part.DispositionItem.Name)) + DdfFileContent.Add("" & ConstCompo.S_SECURE & ": " & SetSecure(Part.Swing, Part.DispositionItem.Name)) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- - DdfFileContent.Add("" & ConstCompo.K_PROFILES & ":") - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & SetBevel(Part.LockEdgeType.Name, Part.DispositionItem.Name, Part.Swing)) - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.LockEdgeMachining)) + DdfFileContent.Add("" & ConstCompo.S_PROFILES & ":") + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & SetBevel(Part.LockEdgeType.Name, Part.DispositionItem.Name, Part.Swing)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.LockEdgeMachining)) If Not StringToDouble(Part.LockEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_LOCKEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & SetBevel(Part.HingeEdgeType.Name, Part.DispositionItem.Name, Part.Swing)) - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.HingeEdgeMachining)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & SetBevel(Part.HingeEdgeType.Name, Part.DispositionItem.Name, Part.Swing)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.HingeEdgeMachining)) If Not StringToDouble(Part.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_HINGEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_TOP & ": " & SetBevel(Part.TopType.Name, Part.DispositionItem.Name, Part.Swing)) - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.TopMachining)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_TOP & ": " & SetBevel(Part.TopType.Name, Part.DispositionItem.Name, Part.Swing)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.TopMachining)) If Not StringToDouble(Part.TopOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_TOPOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_BOTTOM & ": " & SetBevel(Part.BottomType.Name, Part.DispositionItem.Name, Part.Swing)) - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.BottomMachining)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_BOTTOM & ": " & SetBevel(Part.BottomType.Name, Part.DispositionItem.Name, Part.Swing)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.BottomMachining)) If Not StringToDouble(Part.BottomOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_BOTTOMOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) ' Riordino e stampo le compo SearchCompo(DdfFileContent, Part, bIsDDF) @@ -414,7 +406,7 @@ Friend Module DdfFile ' se esiste il template If Not String.IsNullOrWhiteSpace(Compo.TemplateDDFName) Then ' aggiungo " - nomeTemplate: TemplateSelezionato" - CompoListDDF.Add(K_SCORE & Compo.TemplateDDFName & ": " & Compo.TemplateSelItem) + CompoListDDF.Add(DDF_HYPHEN & Compo.TemplateDDFName & ": " & Compo.TemplateSelItem) End If ' creo l'indice dei parametri della compo Dim ParamIndex As Integer @@ -435,7 +427,7 @@ Friend Module DdfFile If IndexDDF >= 0 AndAlso IndexDDF < cbParam.ItemListDDF.Count() Then ' restituisco il valore DDF della lista associato all'indice passato Dim SelItemDDF As String = Trim(cbParam.ItemListDDF(IndexDDF)) - CompoListDDF.Add(K_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) + CompoListDDF.Add(DDF_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) Else ' se non è selezionato nessun elemento (cosa impossibile...) If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine @@ -454,7 +446,7 @@ Friend Module DdfFile If IndexDDF >= 0 AndAlso IndexDDF < cbParam.ItemListDDF.Count() Then ' restituisco il valore DDF della lista associato all'indice passato Dim SelItemDDF As String = Trim(cbParam.ItemListDDF(IndexDDF)) - CompoListDDF.Add(K_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) + CompoListDDF.Add(DDF_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) Else ' se non è selezionato nessun elemento (cosa impossibile...) If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine @@ -468,12 +460,12 @@ Friend Module DdfFile If tboParam.ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), tboParam.Name, CurrCompoParam.DDFName) - CompoListDDF.Add(K_SPACE5 & tboParam.DDFName & ": ") + CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": ") Else If bIsDDF Then - CompoListDDF.Add(K_SPACE5 & tboParam.DDFName & ": " & tboParam.ToolTipValue) + CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": " & tboParam.ToolTipValue) Else - CompoListDDF.Add(K_SPACE5 & tboParam.DDFName & ": " & tboParam.Value) + CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": " & tboParam.Value) End If End If ElseIf Not String.IsNullOrWhiteSpace(tboParam.ToolTipValue) AndAlso Not tboParam.IsActive Then @@ -487,12 +479,12 @@ Friend Module DdfFile If tbParam.ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), tbParam.Name, CurrCompoParam.DDFName) - CompoListDDF.Add(K_SPACE5 & tbParam.DDFName & ": ") + CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": ") Else If bIsDDF Then - CompoListDDF.Add(K_SPACE5 & tbParam.DDFName & ": " & tbParam.ToolTipValue) + CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": " & tbParam.ToolTipValue) Else - CompoListDDF.Add(K_SPACE5 & tbParam.DDFName & ": " & tbParam.Value) + CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": " & tbParam.Value) End If End If Else @@ -505,10 +497,10 @@ Friend Module DdfFile If Not IsNothing(Compo.refJambCompo) Then Compo.IdCode = CStr(IdIndex) Compo.refJambCompo.IdCode = Compo.IdCode - CompoListDDF.Add(K_SPACE5 & "##IdCodeComponent : " & IdIndex) + CompoListDDF.Add(DDF_SPACE5 & "##IdCodeComponent : " & IdIndex) IdIndex += 1 ElseIf Not String.IsNullOrEmpty(Compo.IdCode) Then - CompoListDDF.Add(K_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) + CompoListDDF.Add(DDF_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) IdIndex += 1 End If Return CompoListDDF @@ -560,14 +552,14 @@ Friend Module DdfFile ' verifico esistenza assemblato If IsNothing(CurrAssembly) Then Return False - ' serve per capire se almeno una Part è stata inserita e quindi inserire il separatore + ' serve per capire se almeno un Part è stato inserito e quindi inserire il separatore Dim bSplit As Boolean = False Dim SplitPart As New List(Of String) SplitPart.Add("") - SplitPart.Add("---") + SplitPart.Add(DDF_PARTIALEND) Dim EndAssebly As New List(Of String) EndAssebly.Add("") - EndAssebly.Add("...") + EndAssebly.Add(DDF_END) Dim FirstPart As Boolean = False Dim GeneralAssembly As New List(Of String) @@ -741,115 +733,115 @@ Friend Module DdfFile GeneralAssembly.Add("#EGTDOORCREATOR") GeneralAssembly.Add("#GENERAL ASSEMBLY") GeneralAssembly.Add("#") - GeneralAssembly.Add(ConstCompo.K_METADATA & "Size : ") + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Size : ") If StringToDouble(CurrAssembly.Thickness, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "thickness : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "thickness : " & DoubleToString(dVal, 5)) Else - MessageBox.Show(ConstCompo.K_METADATA & EgtMsg(50106) & "thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.Width, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "width : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "width : " & DoubleToString(dVal, 5)) Else - MessageBox.Show(ConstCompo.K_METADATA & EgtMsg(50106) & "width", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "width", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add("##") - GeneralAssembly.Add(ConstCompo.K_METADATA & "Light : ") + GeneralAssembly.Add(DDF_METADATA) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Light : ") If StringToDouble(CurrAssembly.LightUp, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "up : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "up : " & DoubleToString(dVal, 5)) Else - MessageBox.Show(ConstCompo.K_METADATA & EgtMsg(50106) & "LightUp", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "LightUp", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightLock, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "lock : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "lock : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightLock", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightHinge, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "hinge : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "hinge : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightHinge", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightBottom, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "bottom : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "bottom : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightBottom", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add(ConstCompo.K_METADATA) - GeneralAssembly.Add(ConstCompo.K_METADATA & "Overlap : ") + GeneralAssembly.Add(ConstCompo.DDF_METADATA) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Overlap : ") If StringToDouble(CurrAssembly.ThicknessHead, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "thickness : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "thickness : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "ThicknessHead", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.OverlapHinge, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "hinge : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "hinge : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Hinge", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.OverlapLock, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "lock : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "lock : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Lock", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.DeltaThickness, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "deltaT : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "deltaT : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Delta Thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If ' i parametri associatia alla condizione di Exterior sono stampati solo se Exterior è true If CurrAssembly.Exterior Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "Exterior :") + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Exterior :") If StringToDouble(CurrAssembly.OverlapTop, dVal) Then - GeneralAssembly.Add(ConstCompo.K_METADATA & "top : " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & "top : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Top", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If End If - GeneralAssembly.Add(ConstCompo.K_METADATA) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_PROFILES & ":") - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_LOCKEDGE & ": " & CurrAssembly.LockEdgeType.Name) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.LockEdgeMachining)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.S_PROFILES & ":") + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_LOCKEDGE & ": " & CurrAssembly.LockEdgeType.Name) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.LockEdgeMachining)) If Not StringToDouble(CurrAssembly.LockEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_LOCKEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_HINGEEDGE & ": " & CurrAssembly.HingeEdgeType.Name) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.HingeEdgeMachining)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_HINGEEDGE & ": " & CurrAssembly.HingeEdgeType.Name) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.HingeEdgeMachining)) If Not StringToDouble(CurrAssembly.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_HINGEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_TOP & ": " & CurrAssembly.TopType.Name) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.TopMachining)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_TOP & ": " & CurrAssembly.TopType.Name) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.TopMachining)) If Not StringToDouble(CurrAssembly.TopOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_TOPOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_BOTTOM & ": " & CurrAssembly.BottomType.Name) - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.BottomMachining)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_BOTTOM & ": " & CurrAssembly.BottomType.Name) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.BottomMachining)) If Not StringToDouble(CurrAssembly.BottomOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_BOTTOMOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If - GeneralAssembly.Add(ConstCompo.K_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) + GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) - GeneralAssembly.Add(K_METADATA) + GeneralAssembly.Add(DDF_METADATA) If Not IsNothing(CurrAssembly.DoorNumber) Then - GeneralAssembly.Add(K_METADATA & "doors : " & CurrAssembly.DoorNumber) + GeneralAssembly.Add(DDF_METADATA & "doors : " & CurrAssembly.DoorNumber) Else MessageBox.Show(EgtMsg(50106) & "Number of Doors", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False diff --git a/DoorParameters/Compo.vb b/DoorParameters/Compo.vb index 9666f5e..7a69a6f 100644 --- a/DoorParameters/Compo.vb +++ b/DoorParameters/Compo.vb @@ -117,7 +117,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 = K_NGEEXTENSION Then + If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = NGE_EXTENSION Then ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return m_TemplateSelItem = value @@ -126,12 +126,12 @@ Public Class Compo Dim ConfigDefault As String = String.Empty Dim NewCompoParam As CompoParam = Nothing EgtUILib.GetPrivateProfileString(S_NGECONFIG, K_DEFAULT, "", ConfigDefault, CurrConfig) - ' ricerco la parola chiave Param nella stringa nel file Cinfig.ini + ' ricerco la parola chiave Param nella stringa nel file Config.ini ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault) Else - ' se il file non ha estensione allora creo l'estensione .lua - If Not Path.GetExtension(CurrItemPath).ToLower = K_LUAEXTENSION Then - CurrItemPath &= K_LUAEXTENSION + ' se il file non ha estensione allora aggiungo l'estensione .lua + If Not Path.GetExtension(CurrItemPath).ToLower = LUA_EXTENSION Then + CurrItemPath &= LUA_EXTENSION End If ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return @@ -225,7 +225,7 @@ Public Class Compo ' sostituisco il vecchio CompoType con quello corretto If File.Exists(CurrCompoPath) Then 'GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, FrameCompoNameDDF, FrameCompoName, CurrCompoPath) - 'GetPrivateProfileJambSide("PositionSide", "Side", Side, CurrCompoPath) + 'GetPrivateProfileJambSide(S_POSITIONSIDE, K_SIDE, Side, CurrCompoPath) 'If String.IsNullOrEmpty(Side) Then ' ' cerco nell'eleco dei parametri il parametro di nome side ' For IndexCompoParam As Integer = 0 To Me.CompoParamList.Count - 1 @@ -332,7 +332,7 @@ Public Class Compo End If Dim ErrorList As String = String.Empty ' se il file ha estensione nge - If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = K_NGEEXTENSION Then + If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = NGE_EXTENSION Then ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return CurrRefCompo.TemplateSelItem = value @@ -345,8 +345,8 @@ Public Class Compo ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault) Else ' se il file non ha estensione allora creo l'estensione .lua - If Not Path.GetExtension(CurrItemPath).ToLower = K_LUAEXTENSION Then - CurrItemPath &= K_LUAEXTENSION + If Not Path.GetExtension(CurrItemPath).ToLower = LUA_EXTENSION Then + CurrItemPath &= LUA_EXTENSION End If ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return diff --git a/DoorParameters/Part.vb b/DoorParameters/Part.vb index c63016e..d69683d 100644 --- a/DoorParameters/Part.vb +++ b/DoorParameters/Part.vb @@ -580,7 +580,7 @@ Public Class Part Dim DDFName As String = String.Empty IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME) Dim TemplateList As New List(Of String) - IniFile.OpenDirectory(CurrCompoType.Path, TemplateList) + GetDirectoryCompoFiles(CurrCompoType.Path, TemplateList) ' aggiungo il template come parametro NewCompo.TemplateDDFName = DDFName NewCompo.TemplateName = Name @@ -599,7 +599,7 @@ Public Class Part NewCompo.SetTemplateSelItem(NewCompo.TemplateItemList(SelItemindex)) End If End If - ' se non c'è il template + ' se non c'è il template Else ' nascondo il template NewCompo.TemplateVisibility = Visibility.Collapsed @@ -619,7 +619,7 @@ Public Class Part ' raggruppo tutte le componenti che hanno lo stesso nome vicine If Not IsNothing(NewCompo) Then '----------------------------------------------------------------------------------------------------------------------------------------------- - ' questa parte qui viene ignorata se l'oggetto chiamente è un Frame o una Porta Inattiva + ' questa parte viene ignorata se l'oggetto chiamante è un Frame o una Porta Inattiva If Not IsNothing(Me.m_TypePart) AndAlso Not Me.m_TypePart.Contains("F") Then If Not IsNothing(Map.refAssemblyPageVM.CurrAssembly.LeftJamb) Then ' costruisco un riferimnto in locale dell'assemblato @@ -642,7 +642,7 @@ Public Class Part End If End If '----------------------------------------------------------------------------------------------------------------------------------------------- - ' se trova già una componente allora l'inserimento avvien nel ciclo for + ' se trova già una componente allora l'inserimento avviene nel ciclo for Dim bInsert = False Dim CompoIndex = 0 For CompoIndex = 0 To m_CompoList.Count - 1 @@ -680,7 +680,7 @@ Public Class Part Dim CurrCompoPath As String = FrameCompoFileConfig If File.Exists(CurrCompoPath) Then GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, FrameCompoNameDDF, FrameCompoName, CurrCompoPath) - GetPrivateProfileJambSide("PositionSide", "Side", Side, CurrCompoPath) + GetPrivateProfileJambSide(S_POSITIONSIDE, K_SIDE, Side, CurrCompoPath) If String.IsNullOrEmpty(Side) Then ' controllo nell'elenco dei parametri se esiste un parametro di tipo Side For IndexParam As Integer = 0 To NewCompo.CompoParamList.Count - 1 @@ -775,7 +775,7 @@ Public Class Part Dim DDFName As String = String.Empty IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME) Dim TemplateList As New List(Of String) - IniFile.OpenDirectory(CurrCompoType.Path, TemplateList) + GetDirectoryCompoFiles(CurrCompoType.Path, TemplateList) ' aggiungo il template come parametro NewCompo.TemplateDDFName = DDFName NewCompo.TemplateName = Name @@ -891,233 +891,132 @@ Public Class Part End Sub #Region "LETTURA DDF" - ' Genero una nuova porta da usare nella lettura di un DDF Private FileContent As String() + ' Genero una nuova porta da usare nella lettura di un DDF Shared Sub ReadDDFPartDoor(ArrayFile() As String, ByRef LineIndex As Integer, ByRef ReadDoor As Part) - Dim InvalidValue As String = String.Empty - ' controllo se esiste il file DDF + ' Inizializzazioni ReadDoor.FileContent = ArrayFile - ' se il file esiste ma è vuoto + ReadDoor.m_TypePart = "DO_1" + ' Se il file DDF è vuoto If ReadDoor.FileContent.Count = 0 Then MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) End If - ' assegno tipo di default - ReadDoor.m_TypePart = "DO_1" - Dim CurrOrder As New OrderVM - Dim bSecure As Boolean = False - Dim sCurrCompoNameDDF As String = String.Empty - ' leggo riga per riga - While LineIndex < ReadDoor.FileContent.Count - 1 OrElse Not Search3Score(ReadDoor.FileContent(LineIndex)) OrElse Not Search3Dots(ReadDoor.FileContent(LineIndex)) - ' leggo il produce - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), "produce") Then - LineIndex = ReadDoor.GetProduce(LineIndex) - ' se manca una parola chiave nel DDF + ' Leggo riga per riga + Dim sErrorInfo As String = String.Empty + While LineIndex < ReadDoor.FileContent.Count + Dim sLine As String = RemoveComment(ReadDoor.FileContent(LineIndex)) + ' Se linea vuota o solo commento, vado oltre + If String.IsNullOrWhiteSpace(sLine) Then + LineIndex += 1 + Continue While + End If + ' Controllo fine pezzo o fine file + If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While + ' Processo la sezione + Dim sSection As String = GetName(sLine) + Select Case sSection + Case S_PRODUCE + LineIndex = ReadDoor.GetProduce(LineIndex) + Case S_MEASURES + LineIndex = ReadDoor.GetMeasure(LineIndex) + Case S_CODE + LineIndex = ReadDoor.GetCode(LineIndex) + ' Se manca il codice, errore + If LineIndex = -1 Then + ' carico il messaggio di errore + sErrorInfo &= String.Format(EgtMsg(50102), S_CODE) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + ' interrompo la lettura del file + Exit While End If - Else - Exit While - End If - ' Leggo le unità di misura - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_MEASURES) Then - LineIndex = ReadDoor.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 While - End If + Case S_ORDER + LineIndex = ReadDoor.GetOrder(ReadDoor.NextIndex(LineIndex)) + ' Se mancano i dati dell'ordine, errore + If LineIndex = -1 Then + ' carico il messaggio di errore + sErrorInfo &= String.Format(EgtMsg(50102), S_ORDER) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + ' interrompo la lettura del file + Exit While End If - Else - Exit While - End If - ' Leggo il codice - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_CODE) Then - LineIndex = ReadDoor.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 While - End If + Case S_DATE + LineIndex = ReadDoor.GetDate(LineIndex) + Case S_PIECE + LineIndex = ReadDoor.GetPiece(LineIndex) + Case S_POSITION + LineIndex = ReadDoor.GetPosition(ReadDoor.NextIndex(LineIndex)) + ' Se mancano i dati di posizione, errore + If LineIndex = -1 Then + ' carico il messaggio di errore + sErrorInfo &= String.Format(EgtMsg(50102), S_POSITION) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + ' interrompo la lettura del file + Exit While End If - Else - Exit While - End If - ' Leggo l'ordine - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), S_ORDER) Then - LineIndex = ReadDoor.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 While - End If + Case S_SIZE + LineIndex = ReadDoor.GetSize(ReadDoor.NextIndex(LineIndex)) + ' Se mancano i dati di size, errore + If LineIndex = -1 Then + ' carico il messaggio di errore + sErrorInfo &= String.Format(EgtMsg(50102), S_SIZE) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + ' interrompo la lettura del file + Exit While End If - Else - Exit While - End If - ' Leggo la data - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_DATE) Then - LineIndex = ReadDoor.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 While - End If + Case S_WEIGHT + LineIndex = ReadDoor.GetWeight(LineIndex) + Case S_SWING + LineIndex = ReadDoor.GetSwing(LineIndex) + If LineIndex = -1 Then + sErrorInfo &= String.Format(EgtMsg(50102), S_SWING) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + Exit While End If - Else - Exit While - End If - ' piece (Non necessario, quinidi se viene trovato salta alla riga successiva) - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), "piece") Then - LineIndex = ReadDoor.GetPiece(LineIndex) - LineIndex += 1 + Case S_SECURE + LineIndex = ReadDoor.GetSecure(LineIndex) + Case S_PROFILES + LineIndex = ReadDoor.GetProfiles(ReadDoor.NextIndex(LineIndex), ReadDoor.TypePart) + If LineIndex = -1 Then + sErrorInfo &= String.Format(EgtMsg(50102), S_PROFILES) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + Exit While End If - End If - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), "position") Then - LineIndex = ReadDoor.GetPoint(LineIndex + 1) + Case Else 'COMPONENTS + ' Se sezione senza nome o altro errore + If String.IsNullOrWhiteSpace(sSection) Then + sErrorInfo &= String.Format(EgtMsg(50130), LineIndex) & vbCrLf + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + Exit While End If - End If - ' size - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_SIZE) Then - LineIndex = ReadDoor.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 While - End If + ' Lettura del componente + LineIndex = ReadDoor.GetCompo(ReadDoor.NextIndex(LineIndex), sSection, sErrorInfo) + If LineIndex = -1 Then + ' assegno una porta vuota ed esco dal ciclo + ReadDoor = Nothing + Exit While End If - Else - Exit While - End If - - ' leggo il peso della porta - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_WEIGHT) Then - LineIndex = ReadDoor.GetWeight(LineIndex) - If LineIndex = -1 Then - InvalidValue += String.Format(EgtMsg(50102), K_WEIGHT + vbCrLf) - ' assegno una porta vuota ed esco dal ciclo - ReadDoor = Nothing - Exit While - End If - End If - Else - Exit While - End If - - ' swing - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_SWING) Then - LineIndex = ReadDoor.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 While - End If - End If - Else - Exit While - End If - ' secure - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_SECURE) Then - LineIndex = ReadDoor.GetSecure(LineIndex) - If LineIndex = -1 Then - InvalidValue += String.Format(EgtMsg(50102), K_SECURE + vbCrLf) - ' assegno una porta vuota ed esco dal ciclo - ReadDoor = Nothing - Exit While - End If - End If - End If - ' profiles - If LineIndex < ReadDoor.FileContent.Count - 1 Then - If SearchKey(ReadDoor.FileContent(LineIndex), K_PROFILES) Then - LineIndex = ReadDoor.GetProfiles(LineIndex + 1, ReadDoor.TypePart) - If LineIndex = -1 Then - InvalidValue += String.Format(EgtMsg(50102), K_PROFILES + vbCrLf) - ' assegno una porta vuota ed esco dal ciclo - ReadDoor = Nothing - Exit While - End If - End If - Else - Exit While - End If - ' Compo - ' siccome dopo ogni lettura restituisco la riga successiva: controllo che veramente esiste nel file - If LineIndex < ReadDoor.FileContent.Count - 1 Then - ' se trovo un nome seguito dai due punti - Dim sTemp As String = ReadDoor.SearchName(ReadDoor.FileContent(LineIndex)) - If Not String.IsNullOrWhiteSpace(sTemp) Then - ' carico la stringa letta come nome DDF - If ReadDoor.FileContent(LineIndex)(0) <> " "c Then sCurrCompoNameDDF = sTemp - ' passo la riga successiva e il nome DDF alla funzione che controlla se esiste la compo e restituisce la riga successiva - LineIndex = ReadDoor.GetNewCompo(LineIndex + 1, sCurrCompoNameDDF, InvalidValue) - ' se restituisco una riga scommentata ma non interpretabile - ElseIf Not String.IsNullOrWhiteSpace(Utility.FindComments(ReadDoor.FileContent(LineIndex))) Then - ' interrompi la lettura quando arriva ad altri trattini o ai tre punti - If Search3Score(ReadDoor.FileContent(LineIndex)) Then - Exit While - End If - If Search3Dots(ReadDoor.FileContent(LineIndex)) Then - Exit While - End If - If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine - InvalidValue &= String.Format(EgtMsg(50130), LineIndex) - End If - Else - Exit While - End If - ' interrompi la lettura quando arrivia ad altri trattini o a ai tre punti - If LineIndex > ReadDoor.FileContent.Count - 1 OrElse Search3Score(ReadDoor.FileContent(LineIndex)) Then - Exit While - End If - If LineIndex > ReadDoor.FileContent.Count - 1 OrElse Search3Dots(ReadDoor.FileContent(LineIndex)) Then - Exit While - End If - LineIndex += 1 - If LineIndex > ReadDoor.FileContent.Count - 1 Then Exit While + End Select End While - ' aggiorno - Map.refPartPageVM.CurrPart = ReadDoor - Map.refOptionsVM.RefreshEdgeTypeList() - ' quando finisce la lettura di tutte le righe esci dal ciclo - ' se la stringa dei messaggi contiene delle informazioni allora stampa - If Not String.IsNullOrWhiteSpace(InvalidValue) Then - MessageBox.Show(InvalidValue, EgtMsg(50101) & " in " & ReadDoor.TypePart, MessageBoxButton.OK, MessageBoxImage.Error) + + ' Aggiorno + If Not IsNothing(ReadDoor) Then + Map.refPartPageVM.CurrPart = ReadDoor + Map.refOptionsVM.RefreshEdgeTypeList() + End If + + ' se la stringa dei messaggi contiene delle informazioni allora visualizzo + If Not String.IsNullOrWhiteSpace(sErrorInfo) Then + Dim sTitle As String = EgtMsg(50101) + If Not IsNothing(ReadDoor) Then sTitle &= " in " & ReadDoor.TypePart + MessageBox.Show(sErrorInfo, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) Else - '' se non è stata trovata nessun Secure allora aggiorno subito il file - 'If Not bSecure Then - ' DdfFile.WriteDDF(ReadDoor, sPathDDF, True) - 'End If If String.IsNullOrEmpty(ReadDoor.m_Weight) Then If m_IsCheckedWeight = Visibility.Visible Then ' se il valore è acceso ma non è presente nel ddf chiedo se spegnere @@ -1135,259 +1034,168 @@ Public Class Part End If End Sub - ' restituisce il valore della stringa che precede i due punti - Friend Function SearchName(sLine As String) As String - 'Dim x As String = Regex.Match(FindComments(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value - Return Regex.Match(FindComments(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value + ' Passaggio controllato alla prossima linea del file + Private Function NextIndex(Index As Integer) As Integer + Return SkipWhiteSpace(FileContent, Index + 1) 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 - -#Region "Carica il General della porta" ' Leggo il frame - Public Function GetProduce(Index As Integer) As Integer - Dim sProduce As String = SearchKeyValue(FileContent(Index), "produce") - ' se il valore restituito è nullo o vuoto + Private Function GetProduce(Index As Integer) As Integer + Dim sProduce As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_PRODUCE) If String.IsNullOrWhiteSpace(sProduce) Then - ' assegno la riga successiva m_IsActive = True - Index += 1 Else - m_IsActive = CBool(sProduce) - Index += 1 + m_IsActive = (sProduce.ToLower() = "true") End If - ' restituisco la riga successiva all'ultimo valore letto - Return Index + ' passo alla riga successiva + Return NextIndex(Index) End Function ' 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 + Private Function GetMeasure(Index As Integer) As Integer + Dim sMeasure As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_MEASURES) + If String.IsNullOrWhiteSpace(sMeasure) Then ' 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_Measure = "inches" - Else - m_Measure = "mm" - End If + m_Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit) Else - ' carico il valore nella porta corrente - m_Measure = Measure - ' passo alla riga successiva - Index += 1 + m_Measure = ConvertMmUnitsToString(ConvertStringToMmUnits(sMeasure)) End If - ' restituisco la riga successiva all'ultimo valore letto - Return Index + ' passo alla riga successiva + Return NextIndex(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 + Private Function GetCode(Index As Integer) As Integer + Dim Code As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_CODE) If String.IsNullOrWhiteSpace(Code) Then - ' assegno la riga successiva - Index += 1 - ' assegna il valore di default caricato nell'OptionModule - m_Code = "124-AA-657" + ' Errore + Return -1 Else m_Code = Code - Index += 1 End If - ' restituisco la riga successiva all'ultimo valore letto + ' passo alla riga successiva + Return NextIndex(Index) + End Function + + ' Leggo i dati della sezione order + Private Function GetOrder(ByRef Index As Integer) As Integer + ' Recupero dati customer + If Index > FileContent.Count() - 1 Then Return -1 + Dim Customer As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_CUSTOMER) + If Not String.IsNullOrWhiteSpace(Customer) Then m_Customer = Customer + Index = NextIndex(Index) + ' Recupero dati elevation + If Index > FileContent.Count() - 1 Then Return -1 + Dim Elevation As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_ELEVATION) + If Not String.IsNullOrWhiteSpace(Elevation) Then m_Elevation = Elevation + Index = NextIndex(Index) + ' Recupero dati project + If Index > FileContent.Count() - 1 Then Return -1 + Dim Project As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PROJECT) + If Not String.IsNullOrWhiteSpace(Project) Then m_Project = Project + Index = NextIndex(Index) + ' Recupero dati PO (purchase order) + If Index > FileContent.Count() - 1 Then Return -1 + Dim PO As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PO) + If Not String.IsNullOrWhiteSpace(PO) Then m_PO = PO + Index = NextIndex(Index) + ' Recupero dati line + If Index > FileContent.Count() - 1 Then Return -1 + Dim Line As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_LINE) + If Not String.IsNullOrWhiteSpace(Line) Then m_Line = Line + Index = NextIndex(Index) + ' Passo alla fine della sezione + While Index < FileContent.Count() AndAlso Not SearchName(RemoveComment(FileContent(Index)), S_DATE) + Index = NextIndex(Index) + End While 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_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_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_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_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_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 piece - Public Function GetPiece(Index As Integer) As Integer - Dim sType As String = SearchKeyValue(FileContent(Index), "piece") - ' se il valore restituito è nullo o vuoto - If String.IsNullOrWhiteSpace(sType) Then - ' assegno la riga successiva - Index += 1 - Else - m_TypePart = sType - Index += 1 - End If - ' restituisco la riga successiva all'ultimo valore letto - Return Index - End Function - - Public Function GetPoint(Index As Integer) As Integer - Dim X As String = SearchKeyValue(FileContent(Index), "x") - ' se il valore restituito è nullo o vuoto - If String.IsNullOrWhiteSpace(X) Then - ' se non c'è la parola chiave allora esci - If SearchKey(FileContent(Index), "x") Then - Index += 1 - End If - Else - Index += 1 - End If - Dim Y As String = SearchKeyValue(FileContent(Index), "y") - If String.IsNullOrWhiteSpace(Y) Then - If SearchKey(FileContent(Index), "y") Then - Index += 1 - End If - Else - Index += 1 - End If - Dim Z As String = SearchKeyValue(FileContent(Index), "z") - If String.IsNullOrWhiteSpace(Z) Then - If SearchKey(FileContent(Index), "z") Then - Index += 1 - End If - Else - Index += 1 - End If - ' restituisco la riga successiva all'ultimo valore letto - 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 + ' Leggo la data + Private Function GetDate(Index As Integer) As Integer + Dim sDate As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_DATE) If String.IsNullOrWhiteSpace(sDate) Then - ' assegno la riga successiva - Index += 1 ' assegna il valore di default caricato nell'OptionModule m_Date = System.DateTime.Now.ToString("dd/MM/yyyy") Else m_Date = sDate - Index += 1 End If - ' restituisco la riga successiva all'ultimo valore letto + ' passo alla riga successiva + Return NextIndex(Index) + End Function + + ' Leggo il piece + Private Function GetPiece(Index As Integer) As Integer + Dim sType As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_PIECE) + If Not String.IsNullOrWhiteSpace(sType) Then + m_TypePart = sType + End If + ' passo alla riga successiva + Return NextIndex(Index) + End Function + + ' Leggo i dati di position + Private Function GetPosition(Index As Integer) As Integer + If Index > FileContent.Count() - 1 Then Return -1 + Dim sX As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_X) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + Dim sY As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_Y) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + Dim sZ As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_Z) + Index = NextIndex(Index) 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 + ' Leggo i dati di size + Private Function GetSize(Index As Integer) As Integer + ' Width + If Index > FileContent.Count() - 1 Then Return -1 + Dim sLine As String = RemoveComment(FileContent(Index)) + Dim Width As String = GetValueWithKey(sLine, K_WIDTH) If String.IsNullOrWhiteSpace(Width) Then - ' se non c'è la parola chiave allora esci - If Not SearchKey(FileContent(Index), K_WIDTH) Then Return -1 + If Not SearchKey(sLine, K_WIDTH) Then Return -1 ' altrimenti lascia il valore vuoto - Index += 1 Else - ' carico il valore nella porta corrente m_Width = Width - ' passo alla riga successiva - Index += 1 End If - Dim Height As String = SearchKeyValue(FileContent(Index), K_HEIGHT) + Index = NextIndex(Index) + ' Height + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim Height As String = GetValueWithKey(sLine, K_HEIGHT) If String.IsNullOrWhiteSpace(Height) Then - If Not SearchKey(FileContent(Index), K_HEIGHT) Then Return -1 - Index += 1 + If Not SearchKey(sLine, K_HEIGHT) Then Return -1 + ' altrimenti lascia il valore vuoto Else m_Height = Height - Index += 1 End If - Dim Thickness As String = SearchKeyValue(FileContent(Index), K_THICKNESS) + Index = NextIndex(Index) + ' Thickness + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim Thickness As String = GetValueWithKey(sLine, K_THICKNESS) If String.IsNullOrWhiteSpace(Thickness) Then - If Not SearchKey(FileContent(Index), K_THICKNESS) Then Return -1 - Index += 1 + If Not SearchKey(sLine, K_THICKNESS) Then Return -1 + ' altrimenti lascia il valore vuoto Else m_Thickness = Thickness - Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly() - 'SetVarSize() - Index += 1 End If - ' restituisco la riga successiva all'ultimo valore letto - Return Index + Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly() + ' passo alla riga successiva + Return NextIndex(Index) End Function - ' carico il valore del peso - Public Function GetWeight(Index As Integer) As Integer + ' Leggo il valore del peso + Private Function GetWeight(Index As Integer) As Integer ' se sono arrivato fino a qui significa che è stato scritto nel ddf - Dim Weight As String = SearchKeyValue(FileContent(Index), K_WEIGHT) + Dim sLine As String = RemoveComment(FileContent(Index)) + Dim Weight As String = GetValueWithKey(sLine, S_WEIGHT) ' se il valore restituito è nullo o vuoto If String.IsNullOrWhiteSpace(Weight) Then ' se non c'è la parola chiave significa che il valore è spento - If Not SearchKey(FileContent(Index), K_WEIGHT) Then + If Not SearchKey(sLine, S_WEIGHT) Then ' confronto con il dato che è stato salvato nell'option page, se il valore è acceso If m_IsCheckedWeight = Visibility.Visible Then ' se il valore è acceso ma non è presente nel ddf chiedo se spegnere @@ -1402,8 +1210,7 @@ Public Class Part VisibilityWeight = Visibility.Visible End If End If - - ' se la parola chiave esiste ma non è associato nessun valore + ' altrimenti la parola chiave esiste ma non è associato nessun valore Else If m_IsCheckedWeight = Visibility.Collapsed Then If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then @@ -1421,8 +1228,7 @@ Public Class Part m_Weight = OptionModule.m_Weight End If End If - - ' se il valore esiste Weight + ' altrimenti è assegnato il valore del peso Else If m_IsCheckedWeight = Visibility.Collapsed Then If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then @@ -1439,34 +1245,29 @@ Public Class Part m_Weight = Weight End If End If - Index += 1 - ' restituisco la riga successiva all'ultimo valore letto - Return Index + ' passo alla riga successiva + Return NextIndex(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 + ' Leggo swing + Private Function GetSwing(Index As Integer) As Integer + Dim sLine As String = RemoveComment(FileContent(Index)) + Dim Swing As String = GetValueWithKey(sLine, S_SWING) If String.IsNullOrWhiteSpace(Swing) Then ' se non c'è la parola chiave allora esci - If Not SearchKey(FileContent(Index), K_SWING) Then Return -1 + If Not SearchKey(sLine, S_SWING) Then Return -1 ' altrimenti lascia il valore vuoto - Index += 1 Else ' carico il valore nella porta corrente m_Swing = Swing - ' passo alla riga successiva - Index += 1 End If - ' restituisco la riga successiva all'ultimo valore letto - Return Index + ' passo alla riga successiva + Return NextIndex(Index) End Function - ' attivo e disattivo il posizionamento in macchina della porta - Public Function GetSecure(Index As Integer) As Integer - Dim sSecure As String = SearchKeyValue(FileContent(Index), K_SECURE) - ' riaggiorno la lista dei bevel con quello che è stato settato nel Confi.ini + ' Leggo il posizionamento in macchina della porta + Private Function GetSecure(Index As Integer) As Integer + ' Riaggiorno la lista dei bevel con quello che è stato settato nel Config.ini If OptionModule.m_sDisposition.Contains("BU") Then Part.m_DispositionList(0).IsActive = Visibility.Visible OptionModule.m_bBevelUp = Visibility.Visible @@ -1480,16 +1281,17 @@ Public Class Part Part.m_DispositionList(2).IsActive = Visibility.Collapsed OptionModule.m_bBevelDown = Visibility.Visible End If - ' creo l'oggetto OptionsVM per la prima volta se non esiste If IsNothing(Map.refOptionsVM) Then Dim OptionsPage As OptionsVM = Map.refMainWindowVM.OptionPage End If + ' Recupero il valore di secure + Dim sLine As String = RemoveComment(FileContent(Index)) + Dim sSecure As String = GetValueWithKey(sLine, S_SECURE) If String.IsNullOrWhiteSpace(sSecure) Then ' se non c'è la parola chiave allora esci - If Not SearchKey(FileContent(Index), K_SECURE) Then Return -1 + If Not SearchKey(sLine, S_SECURE) Then Return -1 ' altrimenti lascia il valore vuoto - Index += 1 Else ' carico il valore nella porta corrente m_Secure = sSecure @@ -1583,9 +1385,7 @@ Public Class Part SetDispositionItem(OptionModule.m_Disposition) Part.FirstReadingEdge = True End If - End If - ElseIf OptionModule.m_Disposition.Name = "BU" Then If m_Swing.Contains("HR") Then SetDispositionItem(m_DispositionList(0)) @@ -1604,23 +1404,22 @@ Public Class Part SetDispositionItem(Part.m_DispositionList(2)) End If End If - ' passo alla riga successiva - Index += 1 End If - Return Index + ' passo alla riga successiva + Return NextIndex(Index) End Function - ' carico valori profiles - Public Function GetProfiles(Index As Integer, TypePart As String) As Integer - + ' Leggo i dati dei profili + Private Function GetProfiles(Index As Integer, TypePart As String) As Integer Dim bError As Boolean = False - ' Lock + If Index > FileContent.Count() - 1 Then Return -1 + Dim sLine As String = RemoveComment(FileContent(Index)) m_LockEdgeType = m_EdgeTypeList(0) - Dim LockEdgeType As String = SearchKeyValue(FileContent(Index), K_LOCKEDGE) + Dim LockEdgeType As String = GetValueWithKey(sLine, K_LOCKEDGE) If String.IsNullOrWhiteSpace(LockEdgeType) Then ' se non c'è la parola chiave allora esco con errore - If Not SearchKey(FileContent(Index), K_LOCKEDGE) Then Return -1 + If Not SearchKey(sLine, K_LOCKEDGE) Then Return -1 Else ' se valore nella lista If EdgeTypeControl(LockEdgeType) Then @@ -1638,33 +1437,33 @@ Public Class Part bError = True End If End If - ' passo alla riga successiva - Index += 1 - - Dim LockEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim LockEdgeMachining As String = GetValueWithKey(sLine, K_MACHINING) If String.IsNullOrWhiteSpace(LockEdgeMachining) Then - If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1 + If Not SearchKey(sLine, K_MACHINING) Then Return -1 Else m_LockEdgeMachining = Utility.ConvertOnOffToBoolean(LockEdgeMachining) End If - ' passo alla riga successiva - Index += 1 - - Dim LockEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim LockEdgeOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL) If String.IsNullOrWhiteSpace(LockEdgeOverMaterial) Then - If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1 + If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1 Else m_LockEdgeOverMaterial = LockEdgeOverMaterial End If - ' passo alla riga successiva - Index += 1 - + Index = NextIndex(Index) ' Hinge + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) m_HingeEdgeType = m_EdgeTypeList(0) - Dim HingeEdgeType As String = SearchKeyValue(FileContent(Index), K_HINGEEDGE) + Dim HingeEdgeType As String = GetValueWithKey(sLine, K_HINGEEDGE) If String.IsNullOrWhiteSpace(HingeEdgeType) Then ' se non c'è la parola chiave allora esco con errore - If Not SearchKey(FileContent(Index), K_HINGEEDGE) Then Return -1 + If Not SearchKey(sLine, K_HINGEEDGE) Then Return -1 Else ' se valore nella lista If EdgeTypeControl(HingeEdgeType) Then @@ -1682,32 +1481,32 @@ Public Class Part bError = True End If End If - ' passo alla riga successiva - Index += 1 - - Dim HingeEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim HingeEdgeMachining As String = GetValueWithKey(sLine, K_MACHINING) If String.IsNullOrWhiteSpace(HingeEdgeMachining) Then - If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1 + If Not SearchKey(sLine, K_MACHINING) Then Return -1 Else m_HingeEdgeMachining = ConvertOnOffToBoolean(HingeEdgeMachining) End If - ' passo alla riga successiva - Index += 1 - - Dim HingeEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim HingeEdgeOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL) If String.IsNullOrWhiteSpace(HingeEdgeOverMaterial) Then - If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1 + If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1 Else m_HingeEdgeOverMaterial = HingeEdgeOverMaterial End If - ' passo alla riga successiva - Index += 1 - + Index = NextIndex(Index) ' Top + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) m_TopType = m_EdgeTypeList(0) - Dim TopType As String = SearchKeyValue(FileContent(Index), K_TOP) + Dim TopType As String = GetValueWithKey(sLine, K_TOP) If String.IsNullOrWhiteSpace(TopType) Then - If Not SearchKey(FileContent(Index), K_TOP) Then Return -1 + If Not SearchKey(sLine, K_TOP) Then Return -1 Else ' se valore nella lista If EdgeTypeControl(TopType) Then @@ -1725,32 +1524,32 @@ Public Class Part bError = True End If End If - ' passo alla riga successiva - Index += 1 - - Dim TopMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim TopMachining As String = GetValueWithKey(sLine, K_MACHINING) If String.IsNullOrWhiteSpace(TopMachining) Then - If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1 + If Not SearchKey(sLine, K_MACHINING) Then Return -1 Else m_TopMachining = ConvertOnOffToBoolean(TopMachining) End If - ' passo alla riga successiva - Index += 1 - - Dim TopOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim TopOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL) If String.IsNullOrWhiteSpace(TopOverMaterial) Then - If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1 + If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1 Else m_TopOverMaterial = TopOverMaterial End If - ' passo alla riga successiva - Index += 1 - + Index = NextIndex(Index) ' Bottom + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) m_BottomType = m_EdgeTypeList(0) - Dim BottomType As String = SearchKeyValue(FileContent(Index), K_BOTTOM) + Dim BottomType As String = GetValueWithKey(sLine, K_BOTTOM) If String.IsNullOrWhiteSpace(BottomType) Then - If Not SearchKey(FileContent(Index), K_BOTTOM) Then Return -1 + If Not SearchKey(sLine, K_BOTTOM) Then Return -1 Else ' se valore nella lista If EdgeTypeControl(BottomType) Then @@ -1768,33 +1567,28 @@ Public Class Part bError = True End If End If - ' passo alla riga successiva - Index += 1 - - Dim BottomMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim BottomMachining As String = GetValueWithKey(sLine, K_MACHINING) If String.IsNullOrWhiteSpace(BottomMachining) Then - If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1 + If Not SearchKey(sLine, K_MACHINING) Then Return -1 Else m_BottomMachining = ConvertOnOffToBoolean(BottomMachining) End If - ' passo alla riga successiva - Index += 1 - - Dim BottomOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL) + Index = NextIndex(Index) + If Index > FileContent.Count() - 1 Then Return -1 + sLine = RemoveComment(FileContent(Index)) + Dim BottomOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL) If String.IsNullOrWhiteSpace(BottomOverMaterial) Then - If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1 + If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1 Else m_BottomOverMaterial = BottomOverMaterial End If - ' passo alla riga successiva - Index += 1 - - Return Index + Return NextIndex(Index) End Function -#End Region ' Carica il General della porta - - ' controllo che i valori passati come spigoli siano presenti nella lista corrente (lettura DDF) + ' Controllo che i valori passati come spigoli siano presenti nella lista corrente (lettura DDF) Public Function EdgeTypeControl(Edge As String) As Boolean Dim bFound As Boolean = False For Index = 0 To EdgeTypeList.Count - 1 @@ -1814,365 +1608,281 @@ Public Class Part End If End Function - ' 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_CompoList.Count > 0 Then - CompoNameDDF = m_CompoList.Last.CompoType.DDFName - Index -= 1 - Else - Index -= 1 - Return Index - End If - End If - For CompoListIndex = 0 To CompoPanelVM.CompoTypeList.Count() - 1 - ' eseguo il confronto con il nome delle componenti che è stato acricato nel file Default.ini - If CompoPanelVM.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 - 1 AndAlso Not Search3Score(FileContent(Index)) AndAlso Not Search3Dots(FileContent(Index)) 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(CompoPanelVM.CompoTypeList(CompoListIndex), Me) - ' Leggo il file ini del componente per vedere se c'è il template: se c'è - Dim CurrCompoTypePath As String = CompoPanelVM.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(CompoPanelVM.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.SetTemplateSelItem(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 in line {0} does not exist", Index + 1) - ' ed esci dal ciclo while - Exit While - End If - ' eseguo un confronto tra il nome del file scritto nel ddf e quello presente nel direttorio - For CurrIndex = 0 To m_CurrCompo.TemplateItemList.Count - 1 - Dim FileNemaRead As String = Path.GetFullPath(CurrCompoTypePath & "\" & m_CurrCompo.TemplateSelItem & ".lua").ToLower - Dim FileNameInDir As String = Path.GetFullPath(CurrCompoTypePath & "\" & m_CurrCompo.TemplateItemList(CurrIndex) & ".lua").ToLower - If File.Exists(FileNemaRead) Then - If FileNemaRead = FileNameInDir Then - m_CurrCompo.SetTemplateSelItem(m_CurrCompo.TemplateItemList(CurrIndex)) - Exit For - End If - End If - Next - '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("-->" & 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 - m_CurrCompo.SetTemplateSelItem(sTemplateName) - ReadParam(m_CurrCompo, InvalidValue, Index) - ' se creo la compo allora assegno vero - bCompo = True - End If - End If - m_CompoList.Add(m_CurrCompo) - '------------------------------------------------------------------------------------------------------------------------------------------------------ - ' qui leggo se esite un dato di tipo "##IdCodeComponent : 12 - If Index < FileContent.Count - 1 AndAlso SearchName(FileContent(Index)) = "IdCodeComponent" Then - Dim IdCode As String = String.Empty - IdCode = SearchKeyValue(Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*$").Groups(1).Value, "IdCodeComponent") - If Not String.IsNullOrEmpty(IdCode) Then - ' ho trovato il riferimento - m_CurrCompo.IdCode = IdCode - End If - Index += 1 - End If - '------------------------------------------------------------------------------------------------------------------------------------------------------ - End If - ' se la stringa non ha i due punti - End While + ' Leggo i dati del componente + Private Function GetCompo(Index As Integer, CompoNameDDF As String, ByRef sErrorInfo As String) As Integer + ' Controllo esistenza del componente + Dim CompoListIndex As Integer = -1 + For CmpInd = 0 To CompoPanelVM.CompoTypeList.Count() - 1 + ' eseguo il confronto con il nome dei componenti che è stato caricato dal file Default.ini + If CompoPanelVM.CompoTypeList(CmpInd).DDFName = CompoNameDDF Then + CompoListIndex = CmpInd 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 + ' Se non esiste + If CompoListIndex = -1 Then + ' il componente non esiste + sErrorInfo &= String.Format(EgtMsg(50136), CompoNameDDF, Index - 1) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf + Return -1 End If + ' Passo alla lettura delle linee con eventuali - shape/- template e con i parametri + While Index < FileContent.Count + Dim sLine As String = RemoveComment(FileContent(Index)) + ' se stringa vuota o tutto commento, vado oltre + If String.IsNullOrWhiteSpace(sLine) Then + Index += 1 + Continue While + End If + ' se fine pezzo o fine file, esco dal ciclo + If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While + ' se nome, esco dal ciclo + If Not String.IsNullOrWhiteSpace(GetName(sLine)) Then Exit While + ' cerco una chiave + Dim sKey As String = GetKey(sLine) + If String.IsNullOrWhiteSpace(sKey) Then + sErrorInfo &= String.Format(EgtMsg(50131), CompoNameDDF, Index + 1) + sErrorInfo &= Environment.NewLine & CompoNameDDF & " has not been created." & vbCrLf + ' esco dalla lettura del compo + Exit While + End If + ' Creo il componente + Dim m_CurrCompo = New Compo(CompoPanelVM.CompoTypeList(CompoListIndex), Me) + ' Se previsto template o shape da configurazione + Dim CurrCompoTypePath As String = CompoPanelVM.CompoTypeList(CompoListIndex).Path + If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME) <> 0 Then + ' leggo se template o shape + Dim Name As String = String.Empty + Dim DDFName As String = String.Empty + IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME) + m_CurrCompo.TemplateDDFName = DDFName + m_CurrCompo.TemplateName = Name + ' creo la lista dei possibili template del componente + Dim TemplateList As New List(Of String) + GetDirectoryCompoFiles(CurrCompoTypePath, TemplateList) + m_CurrCompo.TemplateItemList = TemplateList + ' Se c'è "- " iniziale + If sKey.StartsWith("- ") Then + ' leggo il template effettivamente utilizzato + Dim sTemplate As String = GetValueWithoutKey(sLine) + m_CurrCompo.SetTemplateSelItem(sTemplate) + ' se il template non compare nella lista + If String.IsNullOrWhiteSpace(m_CurrCompo.TemplateSelItem) Then + ' elimina il compo appena creato + m_CurrCompo = Nothing + sErrorInfo &= String.Format("Template in line {0} does not exist", Index + 1) & vbCrLf + ' salto tutti i suoi parametri + Index = NextIndex(Index) + SkipParams(Index) + ' continuo nel ciclo while + Continue While + End If + ' mi sposto alla riga successiva + Index = NextIndex(Index) + ' leggo i parametri del componente + ReadParams(m_CurrCompo, sErrorInfo, Index) + ' altrimenti non c'è il trattino nel file DDF + Else + sErrorInfo &= String.Format(EgtMsg(50132), DDFName, Index + 1) + sErrorInfo &= String.Format("-->" & EgtMsg(50133), CompoNameDDF) & vbCrLf + ' salto tutti i suoi parametri + Index = NextIndex(Index) + SkipParams(Index) + ' continuo nel ciclo while + Continue While + End If + ' il 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 + sErrorInfo &= String.Format(EgtMsg(50134), CurrCompoTypePath, CONFIGINI_FILE_NAME) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf + m_CurrCompo = Nothing + ElseIf Not File.Exists(CurrCompoTypePath & "\" & sTemplateName & LUA_EXTENSION) Then + sErrorInfo &= String.Format(EgtMsg(50135), CurrCompoTypePath, CONFIGINI_FILE_NAME, sTemplateName) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf + Else + ' assegno il nome del tipo di componente + m_CurrCompo.SetTemplateSelItem(sTemplateName) + ReadParams(m_CurrCompo, sErrorInfo, Index) + End If + End If + ' se esiste riferimento ad identificativo, lo leggo + If Index < FileContent.Count Then + ' tolgo l'indicazione di metacomando "##" + sLine = RemoveComment(FileContent(Index).Replace(DDF_METADATA, "")) + If GetKey(sLine) = K_IDCODECOMPONENT Then + Dim IdCode As String = String.Empty + IdCode = GetValueWithKey(sLine, K_IDCODECOMPONENT) + If Not String.IsNullOrEmpty(IdCode) Then m_CurrCompo.IdCode = IdCode + Index = NextIndex(Index) + End If + End If + ' Inserisco il componente in lista + m_CompoList.Add(m_CurrCompo) + End While 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 + ' Salto i parametri del componente + Private Sub SkipParams(ByRef IndexLine As Integer) + ' passo alla lettura delle righe + While IndexLine < FileContent.Count + Dim sLine As String = RemoveComment(FileContent(IndexLine)) + ' se stringa vuota o tutto commento, vado oltre + If String.IsNullOrWhiteSpace(sLine) Then + IndexLine += 1 + Continue While + End If + ' se fine pezzo o fine file, esco dal ciclo + If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While + ' se nome, esco dal ciclo + If Not String.IsNullOrWhiteSpace(GetName(sLine)) Then Exit While + ' se chiave con '-' iniziale, esco dal ciclo + Dim sKey As String = GetKey(sLine) + If sKey.StartsWith("- ") Then Exit While + ' passo alla linea successiva + IndexLine += 1 + End While + End Sub + + ' Leggo i parametri del componente + Private Sub ReadParams(ByRef CompoTemplateItem As Compo, ByRef sErrorInfo As String, ByRef IndexLine As Integer) + ' questo è l'indice dei parametri del componente + Dim IndexParam As Integer = 0 + While IndexParam < CompoTemplateItem.CompoParamList.Count ' carico la lista dei parametri della componente parametro per parametro 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 AndAlso - Not TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam 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 + If IndexLine < FileContent.Count Then + Dim sLine As String = RemoveComment(FileContent(IndexLine)) + ' se stringa vuota o tutto commento, vado oltre + If String.IsNullOrWhiteSpace(sLine) Then + IndexLine += 1 + Continue While + End If + ' se fine pezzo o fine file o nome o metacomando, esco dal ciclo + If Search3Hyphens(sLine) OrElse Search3Dots(sLine) OrElse + Not String.IsNullOrWhiteSpace(GetName(sLine)) OrElse + sLine.Trim().StartsWith(DDF_METADATA) Then + sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName)) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf + Exit While + End If + ' Se è di tipo obbligatorio (non è OnOff) + If Not (TypeOf CurrCompoParam Is TextBoxOnOffParam OrElse TypeOf CurrCompoParam Is ComboBoxOnOffParam) Then + Dim sKey As String = GetKey(sLine) + ' se il nome del parametro è lo stesso di quello presente nel componente + If String.Equals(Trim(CurrCompoParam.DDFName), sKey) Then 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 + Dim sVal As String = GetValueWithoutKey(sLine) ' 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)) + ' riscrivo i valori della lista DDF senza spazi all'inizio e alla fine e in minuscolo + For IndexListDDF As Integer = 0 To ListDDF.Count - 1 + ListDDF(IndexListDDF) = Trim(ListDDF(IndexListDDF)).ToLower() Next ' carico il valore IndexName come indice del valore selezionato dalla lista DDF - IndexName = ListDDF.IndexOf(sVal) + Dim IndexName As Integer = ListDDF.IndexOf(sVal.ToLower()) 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)) + SelItem = 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)) + sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf SelItem = List(0) End If - ' assegno al parametro della compnente il valore "filtrato" + ' assegno al parametro del componente il valore "filtrato" DirectCast(CurrCompoParam, ComboBoxParam).SetSelItem(SelItem) - ' assegno il valore letto alla textbox + ' assegno il valore letto alla textbox ElseIf TypeOf CurrCompoParam Is TextBoxParam Then - Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName)) + Dim sVal As String = GetValueWithoutKey(sLine) ' per ora non esegue nessun tipo di controllo sui valori letti dal file DDF DirectCast(CurrCompoParam, TextBoxParam).m_Value = sVal End If - ' se il nome esiste ma è sabgliato - ElseIf Not String.IsNullOrWhiteSpace(SearchName(FileContent(IndexLine + IndexParam))) Then + ' se il nome esiste ma è sbagliato + ElseIf Not String.IsNullOrWhiteSpace(sKey) Then ' se il nome non è preceduto dal trattino - If String.IsNullOrWhiteSpace(Score(FileContent(IndexLine + IndexParam))) Then + If Not sKey.StartsWith("- ") 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)) + sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName)) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf + ' passo al parametro successivo senza cambiare linea del file DDF + IndexParam += 1 + Continue While 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 + ' istanzio tutti i valori che mancano al compo corrente di default + sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName)) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf + ' esco dal ciclo + Exit While 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 End If - '-------------------------------------------------------------------------------------------------------------------------------------------------------------- - ' se è una TextBoxOnOff + ' Se altrimenti è una TextBoxOnOff + ElseIf TypeOf CurrCompoParam Is TextBoxOnOffParam Then + ' se il nome del parametro è lo stesso di quello presente nel componente + If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), GetKey(sLine)) Then + ' se la stringa c'è nel DDF vuol dire che è stata selezionata + Dim sVal As String = GetValueWithKey(sLine, Trim(CurrCompoParam.DDFName)) + DirectCast(CurrCompoParam, TextBoxOnOffParam).m_Value = sVal + DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(True) + ' se il nome esiste ma è sbagliato + ElseIf Not String.IsNullOrWhiteSpace(GetKey(sLine)) Then + ' significa che la TextBoxOnOff è stata disattivata + DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False) + ' passo al parametro successivo senza cambiare linea del file DDF + IndexParam += 1 + Continue While + End If + ' Altrimenti è una ComboBoxOnOffParam Else - ' prima verifico che ci sia veramnte la stringa nel file DDF - If IndexLine + IndexParam < FileContent.Count Then - If TypeOf CurrCompoParam Is TextBoxOnOffParam 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).m_Value = sVal - DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(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).SetIsActive(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).SetIsActive(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).SetIsActive(False) - 'IndexLine = IndexLine - 1 - Exit For - End If - End If - Else - DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False) - IndexLine = IndexLine - 1 - End If - ' se è una ComboBoxOnOffParam + ' se il nome del parametro è lo stesso di quello presente nel componente + If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(GetKey(sLine))) Then + ' leggo il valore DDF dal file + Dim sVal As String = GetValueWithKey(sLine, Trim(CurrCompoParam.DDFName)) + Dim IndexName As Integer = 0 + ' carico la lista dei valori (messaggi) + Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).ItemList + Dim IndexListDDF As Integer = 0 + ' carico la lista dei valori DDF + Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).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 file 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 - If Not String.IsNullOrWhiteSpace(Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then - If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) 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, ComboBoxOnOffParam).ItemList - Dim IndexListDDF As Integer = 0 - ' carico la lista dei valori DDF - Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).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 file 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, ComboBoxOnOffParam).SetSelItem(SelItem) - Else - ' vai avanti alla riga successiva - 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, ComboBoxOnOffParam).SetIsActive(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, ComboBoxOnOffParam).SetIsActive(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, ComboBoxOnOffParam).SetIsActive(False) - IndexLine = IndexLine - 1 - End If - End If - Else - ' se la textBoxOnOff/ComboBoxOnOffParam è l'ultima della lista (quindi seguita da uno psazio vuoto) allora considero che sia disattivata - If TypeOf CurrCompoParam Is TextBoxOnOffParam Then - DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False) - Exit For - Else - DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(False) - Exit For - End If - 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).SetIsActive(False) - ElseIf TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam Then - DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(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)) + ' il nome DDF non è corretto + sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf + SelItem = List(0) End If + ' assegno al parametro della compnente il valore "filtrato" + DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetSelItem(SelItem) + ' se il nome esiste ma è sbagliato + ElseIf Not String.IsNullOrWhiteSpace(GetKey(sLine)) Then + ' significa che la TextBoxOnOff è stata disattivata + DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(False) + ' passo al parametro successivo senza cambiare linea del file DDF + IndexParam += 1 + Continue While End If End If Else @@ -2181,25 +1891,14 @@ Public Class Part ElseIf TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam Then DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(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)) + sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName)) + sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf End If End If - If IndexLine + IndexParam < FileContent.Count Then - If Search3Score(FileContent(IndexLine + IndexParam)) Then - Exit For - End If - If Search3Dots(FileContent(IndexLine + IndexParam)) Then - Exit For - End If - Else - Exit For - End If - - Next - ' terminata la lettura dei parametri - IndexLine += IndexParam + ' Avanzo nell'elenco dei parametri e nel file DDF + IndexParam += 1 + IndexLine = NextIndex(IndexLine) + End While End Sub #End Region ' Lettura ddf diff --git a/IniFile.vb b/IniFile.vb index 37c136c..c98123d 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -32,7 +32,7 @@ Friend Module IniFile Friend m_sIniFile As String = String.Empty ' Path Temp directory Friend m_sTempDir As String = String.Empty - ' Path Compo.ini file + ' Path Default.ini file in Compodi Doors Friend m_DefaultIniFile As String = String.Empty ' Path MyProject directory Friend m_MyProjectDir As String = String.Empty @@ -49,8 +49,7 @@ Friend Module IniFile ' Path Doors directory Friend m_sDoorsDirPath As String = String.Empty - ' IniFile - + ' EgtDoorCreator.ini Public Function GetPrivateProfileLanguage(ByVal lpAppName As String, ByVal lpKeyName As String) As Language Dim sVal As String = String.Empty GetMainPrivateProfileString(lpAppName, lpKeyName, "", sVal) @@ -61,6 +60,7 @@ Friend Module IniFile Return Nothing End Function + ' Default.ini in Compo di Doors Public Function DefaultGetPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_DefaultIniFile) End Function @@ -128,36 +128,16 @@ Friend Module IniFile Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_DefaultIniFile) End Function - Friend Sub OpenDirectory(DirectoryPath As String, ByRef ComboList As List(Of String)) - RecursiveOpenDirectory(DirectoryPath, ComboList, DirectoryPath) - End Sub - - Friend Sub RecursiveOpenDirectory(DirectoryPath As String, ByRef ComboList As List(Of String), InitialDirectory As String) - Dim SubDir() As String = Directory.GetDirectories(DirectoryPath) - For Index = 0 To SubDir.Count - 1 - RecursiveOpenDirectory(SubDir(Index), ComboList, InitialDirectory) - Next - Dim Files() As String = Directory.GetFiles(DirectoryPath) - For Index = 0 To Files.Count - 1 - Dim CurrFileExtension As String = Path.GetExtension(Files(Index)) - If CurrFileExtension = ".lua" Or CurrFileExtension = ".nge" Then - If Not Files(Index).Contains("Matching.lua") Then - ComboList.Add(If(CurrFileExtension.ToLower = ".lua", Files(Index).Replace(CurrFileExtension, "").Replace(InitialDirectory & "\", ""), Files(Index).Replace(InitialDirectory & "\", ""))) - End If - End If - Next - End Sub - - ' Funzione che legge valori del file Config.ini passando la path del file da leggere + ' Config.ini di ciascun direttorio dei componenti (deve ricevere anche la path completa del file) Public Function GetPrivateProfileCompoName(IpAppName As String, IpKeyName As String, ByRef DDFName As String, ByRef Name As String, CompoIniPath As String) As Boolean Dim sVal As String = String.Empty - ' Carico il valore della stringa nel parametro sVal EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sVal, CompoIniPath) Dim sItems() As String = sVal.Split("/"c) If sItems.Count() >= 2 Then DDFName = sItems(0) - If IsNumeric(sItems(1)) Then - Name = EgtMsg(CInt(sItems(1))) + Dim nMsg As Integer + If Integer.TryParse(sItems(1), nMsg) Then + Name = EgtMsg(nMsg) Else Name = DDFName End If @@ -168,9 +148,7 @@ Friend Module IniFile Public Function GetPrivateProfileJambSide(IpAppName As String, IpKeyName As String, ByRef Side As String, CompoIniPath As String) As Boolean Dim sVal As String = String.Empty - ' Carico il valore della stringa nel parametro sVal EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sVal, CompoIniPath) - Dim sItems() As String = sVal.Split("/"c) Side = sVal Return True End Function diff --git a/MainWindow/MainWindowModel.vb b/MainWindow/MainWindowModel.vb index 8d89197..9227bd6 100644 --- a/MainWindow/MainWindowModel.vb +++ b/MainWindow/MainWindowModel.vb @@ -74,7 +74,7 @@ Friend Class MainWindowModel ' Assegno direttorio componenti IniFile.m_CompoDir = IniFile.m_sDoorsDirPath & "\Compo" ' Assegno path file di Default - IniFile.m_DefaultIniFile = IniFile.m_sDoorsDirPath & "\Compo\Default.ini" + IniFile.m_DefaultIniFile = IniFile.m_CompoDir & "\" & DEFAULT_INI_FILE_NAME If Not File.Exists(IniFile.m_DefaultIniFile) Then MessageBox.Show("Doors Compo Default.ini not found", "Error", MessageBoxButton.OK, MessageBoxImage.Error) End diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 2e9b464..f0081b7 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -72,5 +72,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/OptionsWindow/OptionModule.vb b/OptionsWindow/OptionModule.vb index 0672ed7..5815870 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -59,8 +59,8 @@ Friend Module OptionModule Friend m_ConfigurationSoftware As ConfigType - Friend m_Disposition As New EdgeType("", Visibility.Visible) - Friend m_sDisposition As String + Friend m_Disposition As New EdgeType("BySwing", Visibility.Visible) + Friend m_sDisposition As String = "BySwing" Friend m_ThicknessJamb As String Friend m_WidthJamb As String @@ -130,7 +130,7 @@ Friend Module OptionModule End If 'i valori della pagina dell'assemblato - Dim Config As Integer = GetMainPrivateProfileInt(S_GENERAL, S_RUNAS, 0) + Dim Config As Integer = GetMainPrivateProfileInt(S_GENERAL, K_RUNAS, 0) m_ConfigurationSoftware = If(Config = 0, ConfigType.Door, ConfigType.Assembly) ' imposto unità di misura per interfaccia utente @@ -197,45 +197,49 @@ Friend Module OptionModule DefaultGetPrivateProfilesBevel(S_EDGE, K_BEVELD_INI, BevelDown) m_bBevelDown = BevelDown - 'disposizione in macchina delle porte - Dim Disp As String = String.Empty - GetMainPrivateProfileString(S_GENERAL, "Disposition", "0", Disp) - ' questa variabile sarà chiamata in tutto il programma per avere una lettura globale del bevel dela porta - m_Disposition.Name = Disp + 'disposizione in macchina delle porte (variabile globale) + Select Case GetMainPrivateProfileInt(S_GENERAL, K_DISPOSITION, 0) + Case 0 + m_Disposition.Name = "BySwing" + Case 1 + m_Disposition.Name = "BD" + Case 2 + m_Disposition.Name = "BU" + End Select ' questa variabile deve essere usata solo in locale per settare la visibilità della optionpage dei bevel - m_sDisposition = Disp - ' se esizte una selezione allora non mostrare a video - If Not IsNothing(m_Disposition) And m_Disposition.Name.Contains("BU") Then + m_sDisposition = m_Disposition.Name + ' se esiste una selezione allora non mostrare a video + If m_Disposition.Name.Contains("BU") Then m_bBevelUp = Visibility.Visible m_bBevelDown = Visibility.Collapsed - ElseIf Not IsNothing(m_Disposition) And m_Disposition.Name.Contains("BD") Then + ElseIf m_Disposition.Name.Contains("BD") Then m_bBevelUp = Visibility.Collapsed m_bBevelDown = Visibility.Visible End If ' Leggo le dimensioni della porta dal file Default.ini Dim Width As String = String.Empty - DefaultGetPrivateProfileString(S_SIZE, K_WIDTH_INI, "33.125", Width) + DefaultGetPrivateProfileString(S_SIZE_INI, K_WIDTH_INI, "32", Width) m_Width = Width Dim Height As String = String.Empty - DefaultGetPrivateProfileString(S_SIZE, K_HEIGHT_INI, "88.2656", Height) + DefaultGetPrivateProfileString(S_SIZE_INI, K_HEIGHT_INI, "80", Height) m_Height = Height Dim Thickness As String = String.Empty - DefaultGetPrivateProfileString(S_SIZE, K_THICKNESS_INI, "1.8125", Thickness) + DefaultGetPrivateProfileString(S_SIZE_INI, K_THICKNESS_INI, "1.75", Thickness) m_Thickness = Thickness ' carico i valori associati allo swing della porta Dim SwingTypeList As New List(Of String) - DefaultGetPrivateProfileList(S_SIZE, K_SWING_LIST_INI, SwingTypeList) + DefaultGetPrivateProfileList(S_SIZE_INI, K_SWING_LIST_INI, SwingTypeList) m_SwingTypeList = SwingTypeList Dim Swing As String = String.Empty - DefaultGetPrivateProfileString(S_SIZE, K_SWING_INI, "RH", Swing) + DefaultGetPrivateProfileString(S_SIZE_INI, K_SWING_INI, "RH", Swing) m_Swing = Swing LoadSwingList() Dim Weight As String = String.Empty - DefaultGetPrivateProfileString(S_SIZE, K_WEIGHT_INI, "25", Weight) + DefaultGetPrivateProfileString(S_SIZE_INI, K_WEIGHT_INI, "25", Weight) m_Weight = Weight Dim WeightVisibility As Visibility = Visibility.Collapsed - DefaultGetPrivateProfilesVisibility(S_SIZE, K_WEIGHTISCHECKED_INI, WeightVisibility) + DefaultGetPrivateProfilesVisibility(S_SIZE_INI, K_WEIGHTISCHECKED_INI, WeightVisibility) Part.IsCheckedWeight = WeightVisibility ' carico il valori associati al tipo di spigolo Dim EdgeTypeList As New ObservableCollection(Of String) @@ -244,12 +248,13 @@ Friend Module OptionModule OptionsVM.CreateEdgeTypeList() ' carico i valori associati agli spigoli Dim LockEdgeType As String = String.Empty - DefaultGetPrivateProfileString(S_EDGE, K_LOCKEDGE, "", LockEdgeType) + DefaultGetPrivateProfileString(S_EDGE, K_LOCKEDGE_INI, "", LockEdgeType) For Index = 0 To OptionsVM.EdgeTypeList.Count - 1 If OptionsVM.EdgeTypeList(Index).Name = LockEdgeType Then m_LockEdgeType = OptionsVM.EdgeTypeList(Index) End If Next + If String.IsNullOrWhiteSpace(m_LockEdgeType.Name) Then m_LockEdgeType = OptionsVM.EdgeTypeList(0) Dim HingeEdgeType As String = String.Empty DefaultGetPrivateProfileString(S_EDGE, K_HINGEDGE_INI, "SQ", HingeEdgeType) For Index = 0 To OptionsVM.EdgeTypeList.Count - 1 @@ -257,6 +262,7 @@ Friend Module OptionModule m_HingeEdgeType = OptionsVM.EdgeTypeList(Index) End If Next + If String.IsNullOrWhiteSpace(m_HingeEdgeType.Name) Then m_HingeEdgeType = OptionsVM.EdgeTypeList(0) Dim TopType As String = String.Empty DefaultGetPrivateProfileString(S_EDGE, K_TOPEDGE_INI, "SQ", TopType) For Index = 0 To OptionsVM.EdgeTypeList.Count - 1 @@ -264,6 +270,7 @@ Friend Module OptionModule m_TopType = OptionsVM.EdgeTypeList(Index) End If Next + If String.IsNullOrWhiteSpace(m_TopType.Name) Then m_TopType = OptionsVM.EdgeTypeList(0) Dim BottomType As String = String.Empty DefaultGetPrivateProfileString(S_EDGE, K_BOTTOMEDGE_INI, "SQ", BottomType) For Index = 0 To OptionsVM.EdgeTypeList.Count - 1 @@ -271,6 +278,7 @@ Friend Module OptionModule m_BottomType = OptionsVM.EdgeTypeList(Index) End If Next + If String.IsNullOrWhiteSpace(m_BottomType.Name) Then m_BottomType = OptionsVM.EdgeTypeList(0) ' Carico i valori booleani associati alla lavorazione Dim LockEdgeMachining As Boolean = False diff --git a/OptionsWindow/OptionsViewModel.vb b/OptionsWindow/OptionsViewModel.vb index 76c6e05..9465d90 100644 --- a/OptionsWindow/OptionsViewModel.vb +++ b/OptionsWindow/OptionsViewModel.vb @@ -40,16 +40,10 @@ Public Class OptionsVM End Get Set(value As String) If value IsNot OptionModule.m_SelectedMeasureUnit Then - OptionModule.m_SelectedMeasureUnit = value - ' inizializzo il valore dell'unità di misura - DdfFile.UnitMeasure = value - If value = OptionModule.m_MeasureUnitList(0) Then - OptionModule.m_bIsMmUnit = True - ElseIf value = OptionModule.m_MeasureUnitList(1) Then - OptionModule.m_bIsMmUnit = False - End If + OptionModule.m_bIsMmUnit = (value = OptionModule.m_MeasureUnitList(0)) EgtSetUiUnits(OptionModule.m_bIsMmUnit) - WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, If(OptionModule.m_bIsMmUnit, 1, 0).ToString) + WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, If(OptionModule.m_bIsMmUnit, "1", "0")) + OptionModule.m_SelectedMeasureUnit = value End If m_Chapter = "unit_measure" End Set diff --git a/ProjectManager/ProjectManagerVM.vb b/ProjectManager/ProjectManagerVM.vb index 4abed19..120e428 100644 --- a/ProjectManager/ProjectManagerVM.vb +++ b/ProjectManager/ProjectManagerVM.vb @@ -493,9 +493,9 @@ Public Class ProjectManagerVM If Not IsNothing(Map.refPartPageVM.CurrPart) Then ' Stampo il file correte nella cartella Template Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog - SaveFileDialog.Title = K_NEWTEMPLATE + SaveFileDialog.Title = "New Template" SaveFileDialog.Directory = IniFile.m_TemplateDir & "\" - SaveFileDialog.Extension = K_DDTEXTENSION + SaveFileDialog.Extension = DDT_EXTENSION 'SaveFileDialog.FileName = m_CurrProject.Name & "\" ' se decido di chiuedere la finestra If Not SaveFileDialog.EgtShowDialog Then @@ -504,11 +504,11 @@ Public Class ProjectManagerVM ' 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 = K_DDTEXTENSION Then - SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, K_DDTEXTENSION) + If Not sExtension.ToLower = DDT_EXTENSION Then + SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, DDT_EXTENSION) End If Else - SaveFileDialog.FileName &= K_DDTEXTENSION + SaveFileDialog.FileName &= DDT_EXTENSION End If If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then DdfFile.WriteDDFPart(Map.refPartPageVM.CurrPart, SaveFileDialog.FileName, False, False) @@ -614,19 +614,19 @@ Public Class ProjectManagerVM ' Creo nuovo assembly ' Lancio la finestra per chiedere il nome dell'assemblato Dim SaveFileDialog As New EgtWPFLib5.EgtSaveFileDialog - SaveFileDialog.Title = K_NEWDOOR + SaveFileDialog.Title = "New Door" SaveFileDialog.Directory = LocalCurrProject.Name - SaveFileDialog.Extension = K_DDFEXTENSION + SaveFileDialog.Extension = DDF_EXTENSION ' Se annullo esco If Not SaveFileDialog.EgtShowDialog Then Return ' Controllo se il nome della porta ha estensione If Path.HasExtension(SaveFileDialog.FileName) Then Dim sExtension As String = Path.GetExtension(SaveFileDialog.FileName) - If Not sExtension.ToLower = K_DDFEXTENSION Then - SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, K_DDFEXTENSION) + If Not sExtension.ToLower = DDF_EXTENSION Then + SaveFileDialog.FileName = SaveFileDialog.FileName.Replace(sExtension, DDF_EXTENSION) End If Else - SaveFileDialog.FileName &= K_DDFEXTENSION + SaveFileDialog.FileName &= DDF_EXTENSION End If ' controllo che il nome non sia presente nella lista degli assemblati Dim bNameExist As Boolean = False diff --git a/RegexFunction.vb b/RegexFunction.vb index 0336d5b..dc49a50 100644 --- a/RegexFunction.vb +++ b/RegexFunction.vb @@ -3,10 +3,7 @@ Module RegexFunction ' restituisce vero se trova il capitoletto [Graphic parameters] Friend Function IsGraphicParametersTitle(sLine As String) As Boolean - If Regex.Match(sLine, "\s*--\s*(\[Graphic parameters\])\s*$").Groups(1).Value = "[Graphic parameters]" Then - Return True - End If - Return False + Return Regex.Match(sLine, "\s*--\s*(\[Graphic parameters\])\s*$").Groups(1).Value = "[Graphic parameters]" End Function ' restituisce quello che segue l'uguale assegnata una parola chiave tra i due trattini e 'uguale @@ -14,18 +11,12 @@ Module RegexFunction Return Regex.Match(sLine, "\s*--\s*(" & sKey & ")\s*=\s*(.*)\s*$").Groups(2).Value End Function - ' restituisca la stringa di commento - Friend Function SearchComments(sLine As String) As Boolean - If String.IsNullOrEmpty(Regex.Match(sLine, "\s*#\s*(.*?\b)\s*$").Groups(1).Value) Then - Return False - Else - Return True - End If - End Function - - ' restituisce la stringa che precede i commenti - Friend Function SearchStringBeforeComments(sLine As String) As String - Return Regex.Match(sLine, "\s*(.*?)\s*#.*$").Groups(1).Value + ' toglie il commento da una riga (conservando i metacomandi) + Friend Function RemoveComment(sLine As String) As String + sLine = sLine.Replace(DDF_METADATA, "§") + If sLine.Contains("#"c) Then sLine = Regex.Match(sLine, "\s*(.*?)\s*#.*$").Groups(1).Value + sLine = sLine.Replace("§", DDF_METADATA) + Return sLine End Function ' restituisce quello che segue l'uguale assegnata la parola chiave Err @@ -38,7 +29,6 @@ Module RegexFunction ' altrimenti restituisco il valore zero (non errore) Return 0 End If - End Function Friend Function ParamExpression(sLine As String) As String @@ -46,28 +36,59 @@ Module RegexFunction End Function ' Cerca la stringa con 3 trattini - Friend Function Search3Score(sLine As String) As Boolean - If Regex.Match(FindComments(sLine), "\s*(---).*$").Groups(1).Value = "---" Then Return True - Return False + Friend Function Search3Hyphens(sLine As String) As Boolean + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return False + Return Regex.Match(sTmp, "\s*(---).*$").Groups(1).Value = "---" End Function ' Cerca la stringa con 3 puntini Friend Function Search3Dots(sLine As String) As Boolean - If Regex.Match(FindComments(sLine), "\s*(...).*$").Groups(1).Value = "..." Then Return True - Return False + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return False + Return Regex.Match(sTmp, "\s*(...).*$").Groups(1).Value = "..." End Function - ' restituisce il valore 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 + ' Cerca la chiave 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 + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return False + Return Regex.Match(sTmp, "\s*(" & sKey & ")\s*:.*$").Groups(1).Value = sKey + End Function + + ' Restituisce la chiave che precede i due punti (elimina gli spazi prima della chiave) + Friend Function GetKey(sLine As String) As String + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return "" + Return Regex.Match(RemoveComment(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value + End Function + + ' Restituisce il valore associato alla chiave ( key: value) + Friend Function GetValueWithKey(sLine As String, sKey As String) As String + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return "" + Return Regex.Match(sTmp, "\s*-*\s*" & sKey & "\s*:\s*(.*?\b)\s*$").Groups(1).Value + End Function + + ' Restituisce il valore associato ad una chiave non specificata ( unknown_key: value) + Friend Function GetValueWithoutKey(sLine As String) As String + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) Then Return "" + Return Regex.Match(sTmp, "\s*:\s*(.*?\b)\s*$").Groups(1).Value + End Function + + ' Cerca il nome che precede i due punti (tutti i caratteri dall'inizio della stringa) + Friend Function SearchName(sLine As String, sName As String) As Boolean + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) OrElse Char.IsWhiteSpace(sTmp, 0) Then Return False + Return Regex.Match(sTmp, "\s*(" & sName & ")\s*:.*$").Groups(1).Value = sName + End Function + + ' Restituisce il nome che precede i due punti (tutti i caratteri dall'inizio della stringa) + Friend Function GetName(sLine As String) As String + Dim sTmp As String = RemoveComment(sLine) + If String.IsNullOrWhiteSpace(sTmp) OrElse Char.IsWhiteSpace(sTmp, 0) Then Return "" + Return Regex.Match(RemoveComment(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value End Function End Module diff --git a/StatusBar/StatusBarVM.vb b/StatusBar/StatusBarVM.vb index f66d370..8b66f8e 100644 --- a/StatusBar/StatusBarVM.vb +++ b/StatusBar/StatusBarVM.vb @@ -33,7 +33,7 @@ Public Class StatusBarVM Return m_UnitMeasure End Get Set(value As String) - If value = Trim("Inches") Then value = "in" + If Trim(value) = "Inches" Then value = "in" m_UnitMeasure = value NotifyPropertyChanged("UnitMeasure") End Set diff --git a/Utility.vb b/Utility.vb index 8f6224a..67b75ee 100644 --- a/Utility.vb +++ b/Utility.vb @@ -42,12 +42,13 @@ Public Module Utility End If Return value End Function + ' elimina l'asterisco dal nome dell'assemblato Public Function SetNameCurrAssemblyAsSaved(ByVal value As String) As String If Not IsNothing(value) Then If value.Contains("*") Then value = value.Remove(value.IndexOf("*")) - value &= K_DDFEXTENSION + value &= DDF_EXTENSION End If End If Return value @@ -96,48 +97,37 @@ Public Module Utility End If End Function - ' restituice la riga scommentata - Public Function FindComments(sLine As String) As String - ' se riapplicando la lettura della riga commentata ottengo che esite almeno un # allora - If SearchComments(sLine) Then - If Regex.Match(sLine, "\s*##\s*(.*?\b)\s*$").Groups(1).Value.Contains("#") Then - ' è ancora un commento, quindi restituisco una riga vuota - Return SearchStringBeforeComments(sLine) - Return String.Empty - Else - Return Regex.Match(sLine, "\s*##\s*(.*?\b)\s*$").Groups(1).Value - End If - Else - ' altrimenti restituisci la stringa che precede il commento - Return sLine - End If - End Function - ' salto gli spazi vuoti fino alla prima riga piena - Public Function SkipWhiteSpace(Array() As String, ByRef Index As Integer) As Integer - Array(Index) = FindComments(Array(Index)) - While String.IsNullOrWhiteSpace(Array(Index)) And Index < Array.Count - 1 + Friend Function SkipWhiteSpace(Array() As String, ByRef Index As Integer) As Integer + While Index < Array.Count + Dim sTmp As String = RemoveComment(Array(Index)) + If Not String.IsNullOrWhiteSpace(sTmp) Then Exit While Index += 1 - Array(Index) = FindComments(Array(Index)) End While Return Index End Function - 'Converte il valore Boolean in una stringa ON/OFF (attributo machining) - Public Function ConvertBooleanToOnOff(bValue As Boolean) As String - If bValue Then - Return K_ON - Else - Return K_OFF - End If + ' Converte il valore Boolean in una stringa ON/OFF (attributo machining) + Friend Function ConvertBooleanToOnOff(bValue As Boolean) As String + Return If(bValue, DDF_ON, DDF_OFF) End Function ' converto una stringa in boolean - Public Function ConvertOnOffToBoolean(sItem As String) As Boolean - If sItem = K_ON Then + Friend Function ConvertOnOffToBoolean(sItem As String) As Boolean + Return (sItem = DDF_ON) + End Function + + Friend Function ConvertMmUnitsToString(bMmUnit As Boolean) As String + Return If(bMmUnit, "mm", "inches") + End Function + + Friend Function ConvertStringToMmUnits(sUnit As String) As Boolean + If Trim(sUnit) = "mm" Then Return True - Else + ElseIf Trim(sUnit) = "inches" Then Return False + Else + Return OptionModule.m_bIsMmUnit End If End Function @@ -158,6 +148,34 @@ Public Module Utility Ob.RemoveAt(Index) Next End Sub + + Friend Sub GetDirectoryCompoFiles(DirectoryPath As String, ByRef FileList As List(Of String)) + GetDirectoryCompoFiles(DirectoryPath, DirectoryPath, FileList) + End Sub + + Private Sub GetDirectoryCompoFiles(DirectoryPath As String, BaseDirectory As String, ByRef FileList As List(Of String)) + Dim SubDir() As String = Directory.GetDirectories(DirectoryPath) + For Index = 0 To SubDir.Count - 1 + GetDirectoryCompoFiles(SubDir(Index), BaseDirectory, FileList) + Next + Dim Files() As String = Directory.GetFiles(DirectoryPath) + For Index = 0 To Files.Count - 1 + Dim FileExt As String = Path.GetExtension(Files(Index)).ToLower() + ' Se file lua o disegni nge + If FileExt = LUA_EXTENSION Or FileExt = NGE_EXTENSION Then + ' Salto il file di Matching tra componenti + If Not Files(Index).Contains(MATCHING_FILE_NAME) Then + ' Elimino il direttorio base dei componenti + Dim sFile As String = Files(Index).Replace(BaseDirectory & "\", "") + ' Elimino estensione lua + If FileExt = LUA_EXTENSION Then sFile = Path.ChangeExtension(sFile, Nothing) + ' Inserisco in lista + FileList.Add(sFile) + End If + End If + Next + End Sub + End Module Public Class SplitConverter