diff --git a/Constants/ConstCompo.vb b/Constants/ConstCompo.vb index f468284..1021a2c 100644 --- a/Constants/ConstCompo.vb +++ b/Constants/ConstCompo.vb @@ -44,6 +44,7 @@ Module ConstCompo Public Const K_HEIGHT As String = "height" Public Const K_THICKNESS As String = "thickness" Public Const K_SWING As String = "swing" + 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" diff --git a/DdfFile.vb b/DdfFile.vb index 3731af9..84a6309 100644 --- a/DdfFile.vb +++ b/DdfFile.vb @@ -69,6 +69,10 @@ Friend Module DdfFile DdfFileContent.Add("" & ConstCompo.K_SWING & ": " & Door.Swing) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") + ' aggiungo il secure nullo al DDF + DdfFileContent.Add("" & ConstCompo.K_SECURE & ": " & "0") + ' aggiungo una riga vuota per separare la lista successiva + DdfFileContent.Add("") DdfFileContent.Add("" & ConstCompo.K_PROFILES & ":") DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & Door.LockEdgeType) DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Door.LockEdgeMachining)) diff --git a/DoorParameters/Door.vb b/DoorParameters/Door.vb index 52884d9..c7c395c 100644 --- a/DoorParameters/Door.vb +++ b/DoorParameters/Door.vb @@ -214,13 +214,14 @@ Public Class Door #Region "TypeEdge" Friend Shared m_EdgeTypeList As New ObservableCollection(Of String) - Public Shared Property EdgeTypeList As ObservableCollection(Of String) + Public Property EdgeTypeList As ObservableCollection(Of String) Get ' restituisco il valore della lista che è stato creato all'avvio Return m_EdgeTypeList End Get Set(value As ObservableCollection(Of String)) m_EdgeTypeList = value + End Set End Property @@ -230,6 +231,9 @@ Public Class Door Return m_LockEdgeType End Get Set(value As String) + If value = String.Empty Then + value = m_EdgeTypeList(0) + End If m_LockEdgeType = value m_IsModifyDoor = True SetTitle() @@ -242,10 +246,10 @@ Public Class Door Return m_HingeEdgeType End Get Set(value As String) + If value = Nothing Then + value = m_EdgeTypeList(0) + End If m_HingeEdgeType = value - 'If SetChange <> 0 Then - ' SetChange += 1 - 'End If m_IsModifyDoor = True SetTitle() End Set @@ -584,6 +588,7 @@ Public Class Door If ReadDoor.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 For LineIndex As Integer = 0 To ReadDoor.FileContent.Count - 1 @@ -690,6 +695,13 @@ Public Class Door Else Exit For End If + ' secure + If LineIndex < ReadDoor.FileContent.Count - 1 Then + If ReadDoor.SearchKey(ReadDoor.FileContent(LineIndex), K_SECURE) Then + bSecure = True + LineIndex += 1 + End If + End If ' profiles If LineIndex < ReadDoor.FileContent.Count - 1 Then If ReadDoor.SearchKey(ReadDoor.FileContent(LineIndex), K_PROFILES) Then @@ -723,11 +735,15 @@ Public Class Door Exit For End If Next - + ' quando finisce la lettura di tutte le righe esci dal ciclo If Not String.IsNullOrWhiteSpace(InvalidValue) Then MessageBox.Show(InvalidValue, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) - End If + Else + If Not bSecure Then + DdfFile.WriteDDF(ReadDoor, sPathDDF) + End If + End If End Sub ' restituice la riga scommentata @@ -969,8 +985,12 @@ Public Class Door ' se il valore restituito è nullo o vuoto If String.IsNullOrWhiteSpace(LockEdgeType) Then ' se non c'è la parola chiave allora esci - If Not SearchKey(FileContent(Index), K_LOCKEDGE) Then Return -1 - ' altrimenti lascia il valore vuoto + If Not SearchKey(FileContent(Index), K_LOCKEDGE) Then + ' restituisco il valore -1 + Return -1 + Else + m_LockEdgeType = m_EdgeTypeList(0) + End If Index += 1 Else ' controllo che il valore sia nella lista @@ -1003,7 +1023,12 @@ Public Class Door ' Hinge Dim HingeEdgeType As String = SearchKeyValue(FileContent(Index), K_HINGEEDGE) If String.IsNullOrWhiteSpace(HingeEdgeType) Then - If Not SearchKey(FileContent(Index), K_HINGEEDGE) Then Return -1 + If Not SearchKey(FileContent(Index), K_HINGEEDGE) Then + Return -1 + Else + m_HingeEdgeType = m_EdgeTypeList(0) + End If + Index += 1 Else If EdgeTypeControl(HingeEdgeType) Then @@ -1097,9 +1122,9 @@ Public Class Door #End Region ' Carica il General della porta - ' controllo che i valori passati come spigoli siano presenti nella lista corrente + ' controllo che i valori passati come spigoli siano presenti nella lista corrente (lettura DDF) Public Function EdgeTypeControl(Edge As String) As Boolean - If Door.EdgeTypeList.IndexOf(Edge) = -1 Then + If Door.m_EdgeTypeList.IndexOf(Edge) = -1 Then MessageBox.Show(Edge & " is not a member of the current list of EdgeType. Check Bevel in option page.", "Caution", MessageBoxButton.OK, MessageBoxImage.Asterisk) Return False Else diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 6365d7e..34cf0f2 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 c254ae0..fb44e08 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -125,8 +125,8 @@ Friend Module OptionModule ' carico il valori associati al tipo di spigolo Dim EdgeTypeList As New ObservableCollection(Of String) DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, EdgeTypeList) - Door.EdgeTypeList = EdgeTypeList - SetEdgeTypeList(Door.EdgeTypeList, m_bBevelUp, m_bBevelDown) + Door.m_EdgeTypeList = EdgeTypeList + SetEdgeTypeList(Door.m_EdgeTypeList, m_bBevelUp, m_bBevelDown) Dim LockEdgeType As String = String.Empty DefaultGetPrivateProfileString(S_EDGE, K_LOCKEDGE, "", LockEdgeType) m_LockEdgeType = LockEdgeType diff --git a/OptionsWindow/OptionsView.xaml b/OptionsWindow/OptionsView.xaml index 7f4cd80..d58bd97 100644 --- a/OptionsWindow/OptionsView.xaml +++ b/OptionsWindow/OptionsView.xaml @@ -186,9 +186,9 @@ + + - - + diff --git a/OptionsWindow/OptionsViewModel.vb b/OptionsWindow/OptionsViewModel.vb index 6c78ad2..396dc0f 100644 --- a/OptionsWindow/OptionsViewModel.vb +++ b/OptionsWindow/OptionsViewModel.vb @@ -4,6 +4,9 @@ Imports EgtUILib Public Class OptionsViewModel Implements INotifyPropertyChanged + + Dim m_rfCurrDoor As Door + Public ReadOnly Property LanguageList As ObservableCollection(Of Language) Get Return OptionModule.m_LanguageList @@ -80,13 +83,17 @@ Public Class OptionsViewModel Return OptionModule.m_bBevelUp End Get Set(value As Boolean) - OptionModule.m_bBevelUp = value - If value Then - DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "1") + If QuestionSetBevel(CheckBevel(OptionModule.m_bBevelUp, value)) Then + OptionModule.m_bBevelUp = value + If value Then + DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "1") + Else + DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "0") + End If + RefreshEdgeTypeList() Else - DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "0") + Return End If - RefreshEdgeTypeList() End Set End Property @@ -95,13 +102,17 @@ Public Class OptionsViewModel Return OptionModule.m_bBevelDown End Get Set(value As Boolean) - OptionModule.m_bBevelDown = value - If value Then - DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "1") + If QuestionSetBevel(CheckBevel(OptionModule.m_bBevelDown, value)) Then + OptionModule.m_bBevelDown = value + If value Then + DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "1") + Else + DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "0") + End If + RefreshEdgeTypeList() Else - DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "0") + Return End If - RefreshEdgeTypeList() End Set End Property @@ -154,11 +165,21 @@ Public Class OptionsViewModel Public Property EdgeTypeList As ObservableCollection(Of String) Get - Return Door.EdgeTypeList + Return Door.m_EdgeTypeList End Get Set(value As ObservableCollection(Of String)) - Door.EdgeTypeList = value + ' carico la lista degli EdgeType appena aggiornata + Door.m_EdgeTypeList = value + ' aggiorno le lista pressenti nella pagina delle impostazioni NotifyPropertyChanged("EdgeTypeList") + ' verifico che esista una porta + If Not IsNothing(m_rfCurrDoor) Then + ' Aggiorno le liste degli elementi + m_rfCurrDoor.NotifyPropertyChanged("EdgeTypeList") + 'EdgeDoorControl(m_rfCurrDoor.LockEdgeType) + m_rfCurrDoor.NotifyPropertyChanged("LockEdgeType") + m_rfCurrDoor.NotifyPropertyChanged("HingeEdgeType") + End If End Set End Property @@ -496,16 +517,67 @@ Public Class OptionsViewModel End Get End Property + Public ReadOnly Property MachinePositionMsg As String + Get + Return EgtMsg(50222) + End Get + End Property + #End Region - ' Aggiorno la lista deli bevel + ' Aggiorno la lista dei bevel Private Sub RefreshEdgeTypeList() + ' creo una variabile locale di tipo ObservableCollection Dim rEdgeTypeList As New ObservableCollection(Of String) + ' Carico questa lista leggendo il file Default.ini DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, rEdgeTypeList) + ' Confronto la lista appena creata con le indicazioni raccolte nell'OptionModule (verifico se i bevel up e down sono selezionati) + ' quindi aggiorno la lista eliminando se serve i bevel SetEdgeTypeList(rEdgeTypeList, OptionModule.m_bBevelUp, OptionModule.m_bBevelDown) + ' richiamo la proprietà pubblica di questa classe EdgeTypeList = rEdgeTypeList End Sub + ' Controllo di eliminare un bevel dalla lista + Private Function CheckBevel(bBevel As Boolean, bValue As Boolean) As Integer + Dim bAnser As Integer + If bBevel And Not bValue Then + ' significa che sta togliendo dalla lista + bAnser = 1 + ElseIf Not bBevel And bValue Then + bAnser = 2 + Else + bAnser = -1 + End If + Return bAnser + End Function + + ' chiedo se vuole continuare + Private Function QuestionSetBevel(bCheckBevel As Integer) As Boolean + If bCheckBevel = 1 Then + If m_rfCurrDoor.LockEdgeType = "BU" Or m_rfCurrDoor.LockEdgeType = "BD" Or m_rfCurrDoor.HingeEdgeType = "BU" Or m_rfCurrDoor.HingeEdgeType = "BD" Then + If MessageBox.Show("It is a bevel of the current door. Do You want to proced?", "Caution", MessageBoxButton.YesNo, MessageBoxImage.Asterisk, MessageBoxResult.No) = MessageBoxResult.No Then + Return False + Else + ' se decido di continuare + Return True + End If + Else + Return True + End If + ElseIf bCheckBevel = 2 Then + Return True + Else + Return False + End If + End Function + + + Sub New(rCurrDoor As Door) + m_rfCurrDoor = rCurrDoor + + End Sub + #Region "COMMANDS" #Region "CloseOptionsCommand" diff --git a/ProjectManager/ProjectManagerViewModel.vb b/ProjectManager/ProjectManagerViewModel.vb index c4b4149..d327686 100644 --- a/ProjectManager/ProjectManagerViewModel.vb +++ b/ProjectManager/ProjectManagerViewModel.vb @@ -339,7 +339,8 @@ Public Class ProjectManagerViewModel Dim OptionsWindow As New OptionsView OptionsWindow.Height = 550 OptionsWindow.Width = 550 - OptionsWindow.DataContext = New OptionsViewModel + + OptionsWindow.DataContext = New OptionsViewModel(DirectCast(m_rfMainWindowViewModel.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor) OptionsWindow.Owner = Application.Current.MainWindow OptionsWindow.ShowDialog() End Sub