diff --git a/DoorParameters/Part.vb b/DoorParameters/Part.vb index 58f10be..784d7c8 100644 --- a/DoorParameters/Part.vb +++ b/DoorParameters/Part.vb @@ -1099,6 +1099,7 @@ Public Class Part 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 bPressure As Boolean = False ' tutti i parametri fino a profiles devono essere caricati Dim ReadDoorCompleted As Boolean = False ' passo alla pagina vuota in attesa del caricamneto della prossima @@ -1180,6 +1181,7 @@ Public Class Part End If Case S_WEIGHT LineIndex = ReadDoor.GetWeight(LineIndex) + bPressure = True Case S_SWING LineIndex = ReadDoor.GetSwing(LineIndex) If LineIndex = -1 Then @@ -1244,18 +1246,20 @@ Public Class Part Dim sTitle As String = EgtMsg(50101) If Not IsNothing(ReadDoor) Then sTitle &= " in " & ReadDoor.TypePart MessageBox.Show(sErrorInfo, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) + ' quando non passa dalla funzione GetWeight (perchè il ddf non ha il peso) Else - If String.IsNullOrEmpty(ReadDoor.m_Weight) Then + If Not bPressure Then If m_IsCheckedWeight = Visibility.Visible Then - ' se il valore è acceso ma non è presente nel ddf chiedo se spegnere + ' ACCESO e NON presenet nel ddf If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then ' decido di spegnere - OptionsVM.IsCheckedWeight = False + OptionsVM.SetIsCheckedWeight(False) Else ' decido di accendere - OptionsVM.IsCheckedWeight = True + OptionsVM.SetIsCheckedWeight(True) ReadDoor.m_Weight = OptionModule.m_Weight ReadDoor.VisibilityWeight = Visibility.Visible + Part.FirstReadingEdge = True End If End If End If @@ -1437,59 +1441,109 @@ Public Class Part ' se sono arrivato fino a qui significa che è stato scritto nel ddf 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(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 - If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then - ' decido di spegnere - OptionsVM.IsCheckedWeight = False - Else - ' decido di accendere - OptionsVM.IsCheckedWeight = True - m_Weight = OptionModule.m_Weight - ' questo richiamo serve per avvisare che il ddf sta cambiando forma - VisibilityWeight = Visibility.Visible - End If - End If - ' altrimenti la parola chiave esiste ma non è associato nessun valore + '' 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(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 + ' If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then + ' ' decido di spegnere + ' OptionsVM.IsCheckedWeight = False + ' Else + ' ' decido di accendere + ' OptionsVM.IsCheckedWeight = True + ' m_Weight = OptionModule.m_Weight + ' ' questo richiamo serve per avvisare che il ddf sta cambiando forma + ' VisibilityWeight = Visibility.Visible + ' End If + ' End If + ' ' 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 + ' ' decido di accendere + ' OptionsVM.IsCheckedWeight = True + ' m_Weight = OptionModule.m_Weight + ' Else + ' ' decido di spegnere + ' OptionsVM.IsCheckedWeight = False + ' ' questo richiamo serve ad avvisare che sta avvenendo un cambiamento nel ddf + ' VisibilityWeight = Visibility.Collapsed + ' End If + ' Else + ' ' valore è acceso quindi posso salvarlo direttamente + ' m_Weight = OptionModule.m_Weight + ' End If + ' End If + + '' 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 + ' ' decido di accendere + ' m_IsCheckedWeight = Visibility.Visible + ' OptionsVM.IsCheckedWeight = True + ' m_Weight = Weight + ' Else + ' ' decido di spegnere + ' m_IsCheckedWeight = Visibility.Collapsed + ' Part.FirstReadingEdge = True + ' End If + ' Else + ' ' valore è acceso quindi posso salvarlo direttamente + ' m_Weight = Weight + ' End If + 'End If + + '-------------------------------------------------------------------------------------------------------------- + Dim bPressureIsInDDF As Boolean = False + ' inizio eseguendo la lettura della stringa del ddf + ' se la stringa contiene il MESSAGGIO Pressure + If SearchKey(sLine, S_WEIGHT) Then + bPressureIsInDDF = True + ' allora passo alla lettura del VALORE Pressure + Weight = GetValueWithKey(sLine, S_WEIGHT) + If String.IsNullOrWhiteSpace(Weight) Then + ' cairco di default il VALORE + m_Weight = OptionModule.m_Weight + ' ? inserisco un messaggio o una avvenuta modifica ? Else - If m_IsCheckedWeight = Visibility.Collapsed Then - If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then - ' decido di accendere - OptionsVM.IsCheckedWeight = True - m_Weight = OptionModule.m_Weight - Else - ' decido di spegnere - OptionsVM.IsCheckedWeight = False - ' questo richiamo serve ad avvisare che sta avvenendo un cambiamento nel ddf - VisibilityWeight = Visibility.Collapsed - End If - Else - ' valore è acceso quindi posso salvarlo direttamente - m_Weight = OptionModule.m_Weight - End If - End If - ' 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 - ' decido di accendere - m_IsCheckedWeight = Visibility.Visible - OptionsVM.IsCheckedWeight = True - m_Weight = Weight - Else - ' decido di spegnere - m_IsCheckedWeight = Visibility.Collapsed - End If - Else - ' valore è acceso quindi posso salvarlo direttamente + ' caricol il VALORE m_Weight = Weight End If End If + + ' eseguo il confronto con le impostanzioni della option page + ' nella option page è ACCESSO ma NON è presnte nel ddf + If m_IsCheckedWeight = Visibility.Visible And Not bPressureIsInDDF Then + ' Weight is setted in OptionPage. Do you want to remove? + If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then + ' SPENTO + OptionsVM.SetIsCheckedWeight(False) + Else + OptionsVM.SetIsCheckedWeight(True) + m_Weight = OptionModule.m_Weight + VisibilityWeight = Visibility.Visible + ' notifico una avvenuta modifica + Part.FirstReadingEdge = True + End If + End If + + ' nella option page è SPENTO ma è presnte nel ddf + If m_IsCheckedWeight = Visibility.Collapsed And bPressureIsInDDF Then + If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then + ' ACCESO + OptionsVM.SetIsCheckedWeight(True) + Else + OptionsVM.SetIsCheckedWeight(False) + VisibilityWeight = Visibility.Collapsed + ' notifico una avvenuta modifica + Part.FirstReadingEdge = True + End If + End If + ' passo alla riga successiva Return NextIndex(Index) End Function @@ -2107,7 +2161,10 @@ Public Class Part DirectCast(CurrCompoParam, TextBoxParam).m_Value = sVal ' avviso che il file è modificato (in caso di chiusura del programma obbligo a passare dal salvataggio) Dim dVal As Double - If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then Part.FirstReadingEdge = True : CompoTemplateItem.LoadByDefault = True + If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then + Part.FirstReadingEdge = True + CompoTemplateItem.LoadByDefault = True + End If End If ' se il nome esiste ma è sbagliato ElseIf Not String.IsNullOrWhiteSpace(sKey) Then diff --git a/HardwareManager/Hardware.vb b/HardwareManager/Hardware.vb index 5b710c0..178edb3 100644 --- a/HardwareManager/Hardware.vb +++ b/HardwareManager/Hardware.vb @@ -10,6 +10,7 @@ Public Class Hardware Dim bTypeListExist As Boolean = False Dim m_GroupChapterName As New ObservableCollection(Of String) Dim ErrorReading As String = String.Empty + Dim BackupDir As String = IniFile.m_CompoDir & "\BackupCompo" ' Path StdTemplate.ini Private m_StdTemplate As String = String.Empty ' il percorso viene aggiornato ad ogni scelta dell'hardware in LoadType() @@ -1038,6 +1039,7 @@ Public Class Hardware Public Function DeleteHardware() As Boolean Dim CurrDirPath As String = CurrPath() + BackupDeletingFile(CurrDirPath) For Each ItemFile In m_TemplateList If ItemFile = m_SelTemplate Then Dim IndexList As Integer = m_TemplateList.IndexOf(m_SelTemplate) @@ -1063,12 +1065,33 @@ Public Class Hardware Return True End Function + ' salvo nella cartella di Backup + Public Function BackupDeletingFile(DeletingFileName As String) As Boolean + Dim sCurrTime As String = Date.UtcNow.ToString.Replace(" ", "_") + sCurrTime = sCurrTime.Replace("/", "-") + sCurrTime = sCurrTime.Replace(":", "-") + Dim BackupFileName As String = Path.GetFileNameWithoutExtension(DeletingFileName) & " " & sCurrTime + If Not Directory.Exists(BackupDir) Then + Directory.CreateDirectory(BackupDir) + End If + BackupFileName = BackupDir & "\" & BackupFileName & LUA_EXTENSION + ' copio il file + Try + File.Copy(DeletingFileName, BackupFileName, True) + Catch ex As System.IO.IOException + MessageBox.Show("Error in copying: " & ex.Message) + ' interrompo la copia e la creazione + Return False + End Try + Return True + End Function + #End Region ' Salvataggio, Duplica, Nuovo, Aggiorna Public Function CurrPath() As String Dim ModelDir As String = String.Empty 'If m_SelBrand.ModelDir <> RegexFunction.ModelTemplate(m_HardwareGeneral.Path) Then ModelDir = m_SelBrand.ModelDirGraphic & "\" - If m_SelBrand.ModelDir <> RAD_DIR Then ModelDir = m_SelBrand.ModelDirGraphic & "\" + If m_SelBrand.ModelDirGraphic <> RAD_DIR Then ModelDir = m_SelBrand.ModelDirGraphic & "\" Return m_HardwareGeneral.Path & "\" & ModelDir & m_SelTemplate & LUA_EXTENSION End Function diff --git a/OptionsWindow/OptionsViewModel.vb b/OptionsWindow/OptionsViewModel.vb index f4dd427..d40c2bd 100644 --- a/OptionsWindow/OptionsViewModel.vb +++ b/OptionsWindow/OptionsViewModel.vb @@ -199,8 +199,20 @@ Public Class OptionsVM End If End If End If + If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then + Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True + End If End Set End Property + Public Shared Sub SetIsCheckedWeight(IsChecked As Boolean) + If IsChecked Then + Part.IsCheckedWeight = Visibility.Visible + DefaultWritePrivateProfileString(S_SIZE, K_WEIGHTISCHECKED_INI, "1") + Else + Part.IsCheckedWeight = Visibility.Collapsed + DefaultWritePrivateProfileString(S_SIZE, K_WEIGHTISCHECKED_INI, "0") + End If + End Sub Public ReadOnly Property SwingTypeList As List(Of String) Get