diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index ebd286a..603b0d4 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -98,6 +98,7 @@ Module ConstIni Public Const S_EDGE As String = "Edge" Public Const S_EDGEASSEMBLY = "EdgeAssembly" Public Const K_EDGETYPE_LIST_INI As String = "EdgeTypeList" + Public Const K_EDGETYPE_INI As String = "EdgeType" Public Const K_LOCKEDGE_INI As String = "LockEdge" Public Const K_HINGEDGE_INI As String = "HingeEdge" Public Const K_TOPEDGE_INI As String = "TopEdge" diff --git a/DoorParameters/Part.vb b/DoorParameters/Part.vb index 0541348..6bf1fab 100644 --- a/DoorParameters/Part.vb +++ b/DoorParameters/Part.vb @@ -1192,13 +1192,20 @@ Public Class Part bProperties = True LineIndex = ReadDoor.GetProperties(LineIndex) Case ConstCompo.S_PROFILES - LineIndex = ReadDoor.GetProfiles(ReadDoor.NextIndex(LineIndex), ReadDoor.TypePart) + Dim LocalMsg As String = String.Empty + LineIndex = ReadDoor.GetProfiles(ReadDoor.NextIndex(LineIndex), ReadDoor.TypePart, LocalMsg) If LineIndex = -1 Then sErrorInfo &= String.Format(EgtMsg(50102), ConstCompo.S_PROFILES) & vbCrLf + If Not String.IsNullOrEmpty(LocalMsg) Then + sErrorInfo &= LocalMsg + End If ' assegno una porta vuota ed esco dal ciclo ReadDoor = Nothing Exit While End If + If Not String.IsNullOrEmpty(LocalMsg) Then + sErrorInfo &= LocalMsg + End If ReadDoorCompleted = True Case Else 'COMPONENTS ' Se sezione senza nome o altro errore @@ -1694,7 +1701,7 @@ Public Class Part End Sub ' Leggo i dati dei profili - Private Function GetProfiles(Index As Integer, TypePart As String) As Integer + Private Function GetProfiles(Index As Integer, TypePart As String, Optional ByRef sErrorMsg As String = "") As Integer ' ricalcolo la lista da mostrare a video If IsNothing(Map.refOptionsVM) Then Dim OptionsPage As OptionsVM = Map.refMainWindowVM.OptionPage @@ -1708,7 +1715,12 @@ Public Class Part 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(sLine, K_LOCKEDGE) Then Return -1 + If Not SearchKey(sLine, K_LOCKEDGE) Then + Return -1 + Else + FirstReadingEdge = True + sErrorMsg = String.Format(EgtMsg(50523), SIDE_LOCK) + End If Else ' se valore nella lista 'If EdgeTypeControl(LockEdgeType) Then @@ -1733,9 +1745,12 @@ Public Class Part End Try End If End Try - ' Else - ' bError = True - 'End If + + If Not ControlProfileInList(LockEdgeTypeList, LockEdgeType) Then + ' 50522=The profile {0} is not a member of the {1} list. + sErrorMsg = String.Format(EgtMsg(50522), LockEdgeType, SIDE_LOCK) + Return -1 + End If End If Index = NextIndex(Index) If Index > FileContent.Count() - 1 Then Return -1 @@ -1764,7 +1779,12 @@ Public Class Part 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(sLine, K_HINGEEDGE) Then Return -1 + If Not SearchKey(sLine, K_HINGEEDGE) Then + Return -1 + Else + FirstReadingEdge = True + sErrorMsg = String.Format(EgtMsg(50523), SIDE_HINGE) + End If Else ' se valore nella lista 'If EdgeTypeControl(HingeEdgeType) Then @@ -1785,6 +1805,11 @@ Public Class Part ' Else ' bError = True 'End If + If Not ControlProfileInList(HingeEdgeTypeList, HingeEdgeType) Then + ' 50522=The profile {0} is not a member of the {1} list. + sErrorMsg = String.Format(EgtMsg(50522), HingeEdgeType, SIDE_HINGE) + Return -1 + End If End If Index = NextIndex(Index) If Index > FileContent.Count() - 1 Then Return -1 @@ -1811,7 +1836,12 @@ Public Class Part m_TopType = m_TopEdgeTypeList(0) Dim TopType As String = GetValueWithKey(sLine, K_TOP) If String.IsNullOrWhiteSpace(TopType) Then - If Not SearchKey(sLine, K_TOP) Then Return -1 + If Not SearchKey(sLine, K_TOP) Then + Return -1 + Else + FirstReadingEdge = True + sErrorMsg = String.Format(EgtMsg(50523), SIDE_TOP) + End If Else ' se valore nella lista 'If EdgeTypeControl(TopType) Then @@ -1832,6 +1862,11 @@ Public Class Part ' Else ' bError = True 'End If + If Not ControlProfileInList(TopEdgeTypeList, TopType) Then + ' 50522=The profile {0} is not a member of the {1} list. + sErrorMsg = String.Format(EgtMsg(50522), TopType, SIDE_TOP) + Return -1 + End If End If Index = NextIndex(Index) If Index > FileContent.Count() - 1 Then Return -1 @@ -1881,7 +1916,12 @@ Public Class Part m_BottomType = m_BottomEdgeTypeList(0) Dim BottomType As String = GetValueWithKey(sLine, K_BOTTOM) If String.IsNullOrWhiteSpace(BottomType) Then - If Not SearchKey(sLine, K_BOTTOM) Then Return -1 + If Not SearchKey(sLine, K_BOTTOM) Then + Return -1 + Else + FirstReadingEdge = True + sErrorMsg = String.Format(EgtMsg(50523), SIDE_BOTTOM) + End If Else ' se valore nella lista 'If EdgeTypeControl(BottomType) Then @@ -1902,6 +1942,11 @@ Public Class Part ' Else ' bError = True 'End If + If Not ControlProfileInList(BottomEdgeTypeList, BottomType) Then + ' 50522=The profile {0} is not a member of the {1} list. + sErrorMsg = String.Format(EgtMsg(50522), BottomType, SIDE_BOTTOM) + Return -1 + End If End If Index = NextIndex(Index) If Index > FileContent.Count() - 1 Then Return -1 @@ -2467,6 +2512,16 @@ Public Class Part End If End Sub + ' verifico che il parametro letto da ddf esista + Private Function ControlProfileInList(ByRef Local_ListEdgeType As ObservableCollection(Of EdgeType), ByRef sEdgeType As String) As Boolean + For IndexList As Integer = 0 To Local_ListEdgeType.Count - 1 + If sEdgeType = Local_ListEdgeType(IndexList).Name OrElse sEdgeType = Local_ListEdgeType(IndexList).BevelDDF Then + Return True + End If + Next + Return False + End Function + #End Region ' Lettura ddf #Region "COSTRUTTORE" diff --git a/IniFile.vb b/IniFile.vb index 2b0dea3..64e74e1 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -87,10 +87,61 @@ Friend Module IniFile For Index = 0 To sItems.Count() - 1 List.Add(Trim(sItems(Index))) Next + Else + Return False End If Return True End Function + ' Edge, EgdgeType_n, ObservableCollection + Public Function DefaultGetPrivateProfileNewVersion(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal List As ObservableCollection(Of String), + ByVal ListLock As ObservableCollection(Of EdgeType), + ByVal ListHinge As ObservableCollection(Of EdgeType), + ByVal ListTop As ObservableCollection(Of EdgeType), + ByVal ListBottm As ObservableCollection(Of EdgeType)) As Boolean + Dim sVal As String = String.Empty + Dim IndexBevelType As Integer = 1 + Dim EndOfList As Boolean = False + Dim bSideExists As Boolean = False + While Not EndOfList + Dim CurrlpKeyName = lpKeyName & DoubleToString(IndexBevelType, 0) + DefaultGetPrivateProfileString(lpAppName, CurrlpKeyName, "", sVal) + If String.IsNullOrEmpty(sVal) Then + EndOfList = True + Continue While + End If + Dim Item() As String = sVal.Split("/"c) + ' verifico che lo split abbia dato il risultato atteso + If Item.Count <> 2 Then Return False + List.Add(Item(0)) + If Item(1).ToLower.Contains(SIDE_LOCK) Then + ListLock.Add(New EdgeType(Trim(Item(0)), Visibility.Visible)) + bSideExists = True + End If + If Item(1).ToLower.Contains(SIDE_HINGE) Then + ListHinge.Add(New EdgeType(Trim(Item(0)), Visibility.Visible)) + bSideExists = True + End If + If Item(1).ToLower.Contains(SIDE_TOP) Then + ListTop.Add(New EdgeType(Trim(Item(0)), Visibility.Visible)) + bSideExists = True + End If + If Item(1).ToLower.Contains(SIDE_BOTTOM) Then + ListBottm.Add(New EdgeType(Trim(Item(0)), Visibility.Visible)) + bSideExists = True + End If + ' verifico che esista un'associazione + If Not bSideExists Then + Return False + Else + bSideExists = False + End If + IndexBevelType = IndexBevelType + 1 + End While + + Return True + End Function + Public Function DefaultGetPrivateProfilesMachining(ByVal lpAppName As String, ByVal lpKeyName As String, ByRef IpBoolean As Boolean) As Boolean Dim sVal As String = String.Empty DefaultGetPrivateProfileString(lpAppName, lpKeyName, "", sVal) diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index eed7f96..e827db1 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -31,8 +31,8 @@ Imports System.Windows #End If - - + + @@ -72,5 +72,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/OptionsWindow/OptionModule.vb b/OptionsWindow/OptionModule.vb index 6974d96..2e2f1d2 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -315,10 +315,15 @@ Friend Module OptionModule Dim WeightVisibility As Visibility = Visibility.Collapsed 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) - DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, EdgeTypeList) - m_StaticEdgeTypeList = EdgeTypeList + If DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, EdgeTypeList) Then + m_StaticEdgeTypeList = EdgeTypeList + Else + DefaultGetPrivateProfileNewVersion(S_EDGE, K_EDGETYPE_INI, EdgeTypeList, Part.m_LockEdgeTypeList, Part.m_HingeEdgeTypeList, Part.m_TopEdgeTypeList, Part.m_BottomEdgeTypeList) + m_StaticEdgeTypeList = EdgeTypeList + End If OptionsVM.CreateEdgeTypeList() ' carico i valori associati agli spigoli Dim LockEdgeType As String = String.Empty diff --git a/OptionsWindow/OptionsViewModel.vb b/OptionsWindow/OptionsViewModel.vb index b7d45b6..4196cab 100644 --- a/OptionsWindow/OptionsViewModel.vb +++ b/OptionsWindow/OptionsViewModel.vb @@ -1348,12 +1348,20 @@ Public Class OptionsVM Public Shared Sub CreateEdgeTypeList() '---------------------------------------------------------------------------------------------------------- ' carico la lista dei bevel da mostrare sugli spigoli Lock, Hinge - LockHingeEdge(Part.m_LockEdgeTypeList) - LockHingeEdge(Part.m_HingeEdgeTypeList) + If Part.m_LockEdgeTypeList.Count = 0 Then + LockHingeEdge(Part.m_LockEdgeTypeList) + End If + If Part.m_HingeEdgeTypeList.Count = 0 Then + LockHingeEdge(Part.m_HingeEdgeTypeList) + End If '---------------------------------------------------------------------------------------------------------- ' caricare gli spigoli top e bottom - TopBottomEdge(Part.m_TopEdgeTypeList) - TopBottomEdge(Part.m_BottomEdgeTypeList) + If Part.m_TopEdgeTypeList.Count = 0 Then + TopBottomEdge(Part.m_TopEdgeTypeList) + End If + If Part.m_BottomEdgeTypeList.Count = 0 Then + TopBottomEdge(Part.m_BottomEdgeTypeList) + End If '---------------------------------------------------------------------------------------------------------- ' caricare gli spigoli dei frame TopBottomEdge(Assembly.m_FrameEdgeTypeList)