diff --git a/DoorParameters/Part.vb b/DoorParameters/Part.vb index c38d5e6..03f5899 100644 --- a/DoorParameters/Part.vb +++ b/DoorParameters/Part.vb @@ -18,6 +18,9 @@ Public Class Part ' costruisco il riferimento con l'oggetto PartDoor che ospita il Part Private m_refPartDoor As PartDoor + ' blocco il processo di avanzamente di lettura delle righe + Private m_StopNextIndexLine As Boolean = False + Public Property refPartDoor As PartDoor Get Return m_refPartDoor @@ -186,11 +189,11 @@ Public Class Part #Region "PROPERTIES and MATERIAL" ' la lista dei materiali è caricta nell'init dell'OptionPage Friend Shared m_MaterilaList As ObservableCollection(Of MaterialType) - Public Property MaterialsList As ObservableCollection(of MaterialType) - Get - Return m_MaterilaList + Public Property MaterialsList As ObservableCollection(Of MaterialType) + Get + Return m_MaterilaList End Get - Set (value As ObservableCollection(of MaterialType)) + Set(value As ObservableCollection(Of MaterialType)) m_MaterilaList = value End Set End Property @@ -202,23 +205,23 @@ Public Class Part End Get Set(value As MaterialType) m_SelectedMaterial = value - If Not IsNothing(value) then + If Not IsNothing(value) Then ' ogni volta che cambio la selezione del materiale azzero tutte le selezioni delle proprietà - If Not IsNothing(m_SelectedMaterial.PropertiesList) then + If Not IsNothing(m_SelectedMaterial.PropertiesList) Then For Each ItemProperty In m_SelectedMaterial.PropertiesList ItemProperty.IsChecked = False Next PropertiesList = m_SelectedMaterial.PropertiesList 'm_SelectedProperty = m_PropertiesList(0) - PropertiesIsVisible = Visibility.Visible + PropertiesIsVisible = Visibility.Visible Else - PropertiesIsVisible = Visibility.Collapsed - End if + PropertiesIsVisible = Visibility.Collapsed + End If NotifyPropertyChanged("SelectedMaterial") OptionModule.m_CurrMaterial = m_SelectedMaterial Map.refSceneManagerVM.RefreshBtn() Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True - End if + End If End Set End Property @@ -251,7 +254,7 @@ Public Class Part Public ReadOnly Property ShowPropeperty As Visibility Get - If OptionModule.m_MaterialIsVisible <> Visibility.Visible and m_PropertiesIsVisible = Visibility.Visible then + If OptionModule.m_MaterialIsVisible <> Visibility.Visible And m_PropertiesIsVisible = Visibility.Visible Then Return Visibility.Visible Else Return Visibility.Collapsed @@ -266,8 +269,8 @@ Public Class Part End Get Set(value As ObservableCollection(Of PropertyItem)) m_PropertiesList = value - If Not IsNothing(m_PropertiesList) andalso m_PropertiesList.Count >0 Then - Try + If Not IsNothing(m_PropertiesList) AndAlso m_PropertiesList.Count > 0 Then + Try m_SelectedProperty = m_PropertiesList.First(Function(x) x.Name = NONE_DDF) Catch ex As Exception m_SelectedProperty = m_PropertiesList(0) @@ -916,7 +919,7 @@ Public Class Part End Property Private m_CutDirectionList As New List(Of String) From {"Horizontal", "Vertical"} - Public ReadOnly Property CutDirectionList As List (of String) + Public ReadOnly Property CutDirectionList As List(Of String) Get Return m_CutDirectionList End Get @@ -972,10 +975,10 @@ Public Class Part End Get Set(value As TopShape) m_SelectedShape = value - If value.Name.Trim() = m_TopShapeList(0).Name.Trim then + If value.Name.Trim() = m_TopShapeList(0).Name.Trim Then TopArcIsChecked = True TopAngleIsChecked = False - ElseIf value.Name.Trim() = m_TopShapeList(1).Name.Trim then + ElseIf value.Name.Trim() = m_TopShapeList(1).Name.Trim Then TopAngleIsChecked = True TopArcIsChecked = False End If @@ -1039,8 +1042,8 @@ Public Class Part End Get Set(value As Boolean) m_TopArcIsChecked = value - If m_TopAngleIsChecked and m_TopArcIsChecked then - m_TopAngleIsChecked = Not Value + If m_TopAngleIsChecked And m_TopArcIsChecked Then + m_TopAngleIsChecked = Not value NotifyPropertyChanged("TopAngleIsChecked") End If NotifyPropertyChanged("TopArcIsChecked") @@ -1052,7 +1055,7 @@ Public Class Part Private m_VisibilityTopArch As Visibility = Visibility.Visible Public ReadOnly Property VisibilityTopArch As Visibility Get - If m_TopArcIsChecked then + If m_TopArcIsChecked Then m_VisibilityTopArch = Visibility.Visible Else m_VisibilityTopArch = Visibility.Hidden @@ -1118,10 +1121,10 @@ Public Class Part End Get Set(value As Boolean) m_TopAngleIsChecked = value - If m_TopArcIsChecked and m_TopAngleIsChecked then - m_TopArcIsChecked = Not Value + If m_TopArcIsChecked And m_TopAngleIsChecked Then + m_TopArcIsChecked = Not value NotifyPropertyChanged("TopArcIsChecked") - End If + End If NotifyPropertyChanged("TopAngleIsChecked") Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True Map.refSceneManagerVM.RefreshBtn() @@ -1131,7 +1134,7 @@ Public Class Part Private m_VisibilityTopAngle As Visibility = Visibility.Hidden Public ReadOnly Property VisibilityTopAngle As Visibility Get - If m_TopAngleIsChecked then + If m_TopAngleIsChecked Then m_VisibilityTopAngle = Visibility.Visible Else m_VisibilityTopAngle = Visibility.Hidden @@ -1416,7 +1419,7 @@ Public Class Part For IndexFile As Integer = 0 To NewCompo.CompoType.FolderList(IndexFolder).ModelFileList.Count - 1 If Trim(SelFile) = NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile) Then NewCompo.SetSelBrand(NewCompo.CompoType.FolderList(IndexFolder).ModelDirGraphic) - NewCompo.SetSelFile(NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile)) + NewCompo.SetSelFile(NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile)) Return End If Next @@ -1786,6 +1789,10 @@ Public Class Part ' Passaggio controllato alla prossima linea del file Private Function NextIndex(Index As Integer) As Integer + If m_StopNextIndexLine Then + m_StopNextIndexLine = False + Return Index + End If Return SkipWhiteSpace(FileContent, Index + 1) End Function @@ -2069,65 +2076,65 @@ Public Class Part Return NextIndex(Index) End Function - ' leggo il materiale + ' leggo il materiale Private Function GetMaterial(Index As Integer) As Integer ' se non trovo la lista dei materiali o la lista è vuota allora errore - If IsNothing(OptionModule.m_MaterialList) orelse OptionModule.m_MaterialList.Count < 1 then + If IsNothing(OptionModule.m_MaterialList) OrElse OptionModule.m_MaterialList.Count < 1 Then Return -1 End If - Dim bMaterialExists = false - Dim sLine As String = RemoveComment(FileContent(Index)) - Dim sMaterial As String = GetValueWithKey(sLine, S_MATERIAL) - If Not String.IsNullOrWhiteSpace(sMaterial) Then + Dim bMaterialExists = False + Dim sLine As String = RemoveComment(FileContent(Index)) + Dim sMaterial As String = GetValueWithKey(sLine, S_MATERIAL) + If Not String.IsNullOrWhiteSpace(sMaterial) Then sNameDDFMaterial = sMaterial For Each MaterialItem In OptionModule.m_MaterialList ' se trovo il materiale allora carico la sua lista di proprietà ed esco - If Trim(MaterialItem.NameDDF) = Trim(sMaterial) Then + If Trim(MaterialItem.NameDDF) = Trim(sMaterial) Then 'm_SelectedMaterial = MaterialItem SetMaterial(MaterialItem) OptionModule.m_CurrMaterial = m_SelectedMaterial - If Not IsNothing (MaterialItem.PropertiesList) Then + If Not IsNothing(MaterialItem.PropertiesList) Then 'PropertiesList = MaterialItem.PropertiesList SetPropertiesList(MaterialItem.PropertiesList) 'SelectedProperty = m_PropertiesList(0) SetProperty(m_PropertiesList(0)) Else PropertiesIsVisible = Visibility.Collapsed - End if - bMaterialExists = true - Return NextIndex(Index) - End If - Next + End If + bMaterialExists = True + Return NextIndex(Index) + End If + Next End If ' se il materiale non è nell'elenco dei materiali - If Not bMaterialExists then + If Not bMaterialExists Then Return -2 End If - Return NextIndex(Index) - End Function + Return NextIndex(Index) + End Function ' leggo le proprietà Private Function GetProperties(Index As Integer) As Integer ' se esiste l'elenco dei materiali (nuova configurazione) ma il ddf è senza: allora passo come materiale di default il primo della lista (wood) - If IsNothing(m_SelectedMaterial) andalso OptionModule.m_MaterialList.Count > 0 Then + If IsNothing(m_SelectedMaterial) AndAlso OptionModule.m_MaterialList.Count > 0 Then 'SelectedMaterial = OptionModule.m_MaterialList(0) SetMaterial(OptionModule.m_MaterialList(0)) 'PropertiesList = OptionModule.m_MaterialList(0).PropertiesList SetPropertiesList(OptionModule.m_MaterialList(0).PropertiesList) End If - ' devo verificare se esite la lista dei materiali - Dim bPropertyExists = false + ' devo verificare se esite la lista dei materiali + Dim bPropertyExists = False Dim sLine As String = RemoveComment(FileContent(Index)) ' se esiste la proprietà, ma non è selezionata allora comunico la modifica If PropertiesIsVisible = Visibility.Collapsed Then - bModifyProperties = True + bModifyProperties = True End If Dim sProperties As String = GetValueWithKey(sLine, ConstCompo.S_PROPERTIES) If Not String.IsNullOrWhiteSpace(sProperties) Then ' carico il valore nella porta corrente Dim sItem() As String = sProperties.Split(","c) ' se la lista contiene più di una proprietà - If sItem.Count > 1 then + If sItem.Count > 1 Then Return -1 End If For Each Item In m_PropertiesList @@ -2137,21 +2144,21 @@ Public Class Part m_SelectedProperty = Item Item.IsChecked = True bPropertyExists = True - End If + End If Next Next ' se la proprietà non appartiene alla lista allora esco e non carico la porta - If Not bPropertyExists then + If Not bPropertyExists Then sNameDDFProperty = sProperties Return -2 End If Else - For Each Item In m_PropertiesList - If Item.Name = NONE_DDF then + For Each Item In m_PropertiesList + If Item.Name = NONE_DDF Then SelectedProperty = Item - Exit for + Exit For End If - next + Next End If Return NextIndex(Index) End Function @@ -2493,8 +2500,8 @@ Public Class Part End If ' If Not m_TopArcIsChecked then - If Not m_TopShapeIsChecked then - Dim PosxAngle As String = GetValueWithKey(sLine, ConstCompo.K_POSX) + If Not m_TopShapeIsChecked Then + Dim PosxAngle As String = GetValueWithKey(sLine, ConstCompo.K_POSX) If Not String.IsNullOrEmpty(PosxAngle) Then Index = NextIndex(Index) If Index > FileContent.Count() - 1 Then Return -1 @@ -2861,8 +2868,8 @@ Public Class Part End If ' 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 < FileContent.Count Then + ' Controllo che il file non sia terminato e non è il nome di una nuova componente + If IndexLine < FileContent.Count And Not IsNameCompo(IndexLine) Then Dim sLine As String = RemoveComment(FileContent(IndexLine)) ' se stringa vuota o tutto commento, vado oltre If String.IsNullOrWhiteSpace(sLine) Then @@ -2947,7 +2954,7 @@ Public Class Part Dim dVal As Double If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then ' Part.FirstReadingEdge = True - CompoTemplateItem.MissingParameter = true + CompoTemplateItem.MissingParameter = True CompoTemplateItem.ErrorValue = True CurrCompoParam.ErrorInReading = True End If @@ -2998,7 +3005,7 @@ Public Class Part DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False) Else DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(True) - End If + End If ' se il nome esiste ma è sbagliato ElseIf Not String.IsNullOrWhiteSpace(GetKey(sLine)) Then ' significa che la TextBoxOnOff è stata disattivata @@ -3056,11 +3063,11 @@ Public Class Part End If End If Else - If TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then + If Not IsNameCompo(IndexLine) And TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then CurrCompoParam.ErrorInReading = False CompoTemplateItem.ErrorValue = False DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False) - ElseIf TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam Then + ElseIf Not IsNameCompo(IndexLine) And TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam Then CurrCompoParam.ErrorInReading = False CompoTemplateItem.ErrorValue = False DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(False) @@ -3084,6 +3091,21 @@ Public Class Part End If End Sub + ' verifcio che la riga sia il nome di una componente (esempio: "hinges:") + Private Function IsNameCompo(ByRef IndexLine As Integer) As Boolean + ' verifico che il file non sia terminato + If IndexLine > FileContent.Count - 1 Then + Return False + End If + ' per riconoscere una componente: no spazi ad inizio riga, dopo i ":" riga vuota + If FileContent(IndexLine) = FileContent(IndexLine).Trim AndAlso + GetValueWithoutKey(FileContent(IndexLine)) = String.Empty Then + m_StopNextIndexLine = True + Return True + End If + Return False + End Function + ' controllo che tutti i bevel siano dello stesso tipo Private Function ControlBevel(BLock As String, BHinge As String, BTop As String, BBottom As String) As String Dim BBevel As String = String.Empty @@ -3222,7 +3244,7 @@ Public Class Part Me.m_Height = OptionModule.m_Height Me.m_Thickness = OptionModule.m_Thickness Me.SetSwing(OptionModule.m_Swing) - If Not IsNothing(OptionModule.m_CurrMaterial) then + If Not IsNothing(OptionModule.m_CurrMaterial) Then Try Me.SetMaterial(m_MaterialList.First(Function(x) x.Name = Trim(OptionModule.m_CurrMaterial.Name))) Catch ex As Exception diff --git a/MainWindow/MainWindowModel.vb b/MainWindow/MainWindowModel.vb index 7d4ca7c..16023f5 100644 --- a/MainWindow/MainWindowModel.vb +++ b/MainWindow/MainWindowModel.vb @@ -57,8 +57,8 @@ Friend Class MainWindowModel EgtUILib.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile) EgtSetKey(sKey) ' Recupero livello e opzioni della chiave - Dim bKey As Boolean = EgtGetKeyLevel(3279, 2306, 1, IniFile.m_nKeyLevel) And - EgtGetKeyOptions(3279, 2306, 1, IniFile.m_nKeyOptions) + Dim bKey As Boolean = EgtGetKeyLevel(3279, 2307, 1, IniFile.m_nKeyLevel) And + EgtGetKeyOptions(3279, 2307, 1, IniFile.m_nKeyOptions) 'Inizializzazione generale di EgtInterface m_nDebug = GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) Dim sLogFile As String = IniFile.m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 0a3a164..b448b7d 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -72,5 +72,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + +