diff --git a/Assembly/AssemblyPageV.xaml.vb b/Assembly/AssemblyPageV.xaml.vb index e07abc8..42dd631 100644 --- a/Assembly/AssemblyPageV.xaml.vb +++ b/Assembly/AssemblyPageV.xaml.vb @@ -1,9 +1,9 @@ Public Class AssemblyPageV - Private DoorButton_Static_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#FFD07606") - Private DoorButton_Static_Border As SolidColorBrush = New BrushConverter().ConvertFrom("#000000") - Private DoorButton_MouseOver_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#3CD07606") - Private DoorButton_MouseOver_Border As SolidColorBrush = New BrushConverter().ConvertFrom("#FF3C7FB1") + Private DoorButton_Static_Background As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#FFD07606"), SolidColorBrush) + Private DoorButton_Static_Border As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#000000"), SolidColorBrush) + Private DoorButton_MouseOver_Background As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#3CD07606"), SolidColorBrush) + Private DoorButton_MouseOver_Border As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#FF3C7FB1"), SolidColorBrush) Private Sub RightJamb_MouseEnter(sender As Object, e As Input.MouseEventArgs) Handles LeftRightJamb.MouseEnter, TopRightJamb.MouseEnter, RightRightJamb.MouseEnter TopRightJamb.BorderBrush = DoorButton_MouseOver_Border diff --git a/AssemblyManager/AssemblyManagerVM.vb b/AssemblyManager/AssemblyManagerVM.vb index 36a20b0..8631de9 100644 --- a/AssemblyManager/AssemblyManagerVM.vb +++ b/AssemblyManager/AssemblyManagerVM.vb @@ -138,7 +138,8 @@ Public Class AssemblyManagerVM ' in fase di scrittura del file dei messaggi leggo gli errori che sono stati comunicati Private Function ConfirmSaving(sMessages As String) As Boolean If Not String.IsNullOrEmpty(sMessages) Then - DdfFile.ErrorInWriting &= "Do you want to procede?" + ' 50503=Do you want to save? + DdfFile.ErrorInWriting &= vbCrLf & EgtMsg(50503) If MessageBox.Show(DdfFile.ErrorInWriting, EgtMsg(50101), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then DdfFile.DDFIsCorrect = True Else @@ -163,26 +164,26 @@ Public Class AssemblyManagerVM If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then Dim CurrPart As Part = CurrAssembly.ListPartDoor(0).Door Select Case Map.refMainWindowVM.selectedWatcher - + ' creazione di un file Case MainWindowVM.WatcherCalling.OnCreated ' in fase di creazione devo scorrere tutte le componenti che sono CompoDDFName e che hanno il LoadDefault = True If IsNothing(ErCompo) Then Dim IndexCompo As Integer = 0 For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1 - ' se non ricevo il nome del direttorio allora scorro su tutte le componeti che hanno il LoadDefault = True + ' se non ricevo il nome del direttorio allora scorro su tutte le componeti If Not String.IsNullOrEmpty(Map.refMainWindowVM.CompoDDFName) Then - If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName AndAlso - CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then + If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName Then + 'CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) 'RecreateCompoParm(ErrCompo, CurrPart) End If Else - If CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then - Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) - 'RecreateCompoParm(ErrCompo, CurrPart) - End If + 'If CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then + Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) + 'RecreateCompoParm(ErrCompo, CurrPart) + 'End If End If Next Else @@ -190,7 +191,7 @@ Public Class AssemblyManagerVM If ErCompo.LoadByDefault Then ReCreateCompo(ErCompo, CurrPart) 'RecreateCompoParm(ErCompo, CurrPart) End If - + ' eliminazione di un file Case MainWindowVM.WatcherCalling.OnDeleted ' in fase di eliminazione devo scorrere tutte le componenti che sono CompoDDFName e che hanno il LoadDefault = false If IsNothing(ErCompo) Then @@ -201,13 +202,13 @@ Public Class AssemblyManagerVM If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName AndAlso Not CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) 'RecreateCompoParm(ErrCompo, CurrPart) End If Else If Not CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).LoadByDefault Then Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) 'RecreateCompoParm(ErrCompo, CurrPart) End If End If @@ -217,7 +218,7 @@ Public Class AssemblyManagerVM If Not ErCompo.LoadByDefault Then ReCreateCompo(ErCompo, CurrPart) 'RecreateCompoParm(ErCompo, CurrPart) End If - + ' rinomina di un file Case MainWindowVM.WatcherCalling.OnRenamed ' in fase di eliminazione devo scorrere tutte le componenti che sono CompoDDFName If IsNothing(ErCompo) Then @@ -227,12 +228,12 @@ Public Class AssemblyManagerVM If Not String.IsNullOrEmpty(Map.refMainWindowVM.CompoDDFName) Then If Map.refMainWindowVM.CompoDDFName = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).CompoType.DDFName Then Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) 'RecreateCompoParm(ErrCompo, CurrPart) End If Else Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) 'RecreateCompoParm(ErrCompo, CurrPart) End If Next @@ -241,9 +242,9 @@ Public Class AssemblyManagerVM ReCreateCompo(ErCompo, CurrPart) 'RecreateCompoParm(ErCompo, CurrPart) End If - + ' cambiamento: questo metdod non è utlizzato Case MainWindowVM.WatcherCalling.OnChanged - + ' permette di rileggere il file temporaneo Case MainWindowVM.WatcherCalling.OnLoadTempFile LoadTempFile() @@ -252,16 +253,19 @@ Public Class AssemblyManagerVM ' ReCreateCompo(ErCompo, CurrPart) RecreateCompoParm(ErCompo, CurrPart) Else - Dim IndexCompo As Integer = 0 - For IndexCompo = 0 To CurrAssembly.ListPartDoor(0).Door.m_CompoList.Count - 1 - Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo) - ReCreateCompo(ErrCompo, CurrPart) + Dim IndexDoor As Integer = 0 + For IndexDoor = 0 To CurrAssembly.ListPartDoorOfDoor.Count - 1 + Dim IndexCompo As Integer = 0 + For IndexCompo = 0 To CurrAssembly.ListPartDoorOfDoor(IndexDoor).Door.m_CompoList.Count - 1 + Dim ErrCompo As Compo = CurrAssembly.ListPartDoorOfDoor(IndexDoor).Door.m_CompoList(IndexCompo) + ' ricevo l'inidice della componente per mantenere l'ordine + ReCreateCompo(ErrCompo, CurrPart, IndexCompo) + Next Next End If ' se sto forzando un ricalcolo completo di tutto faccio passare tutte le componenti senza pietà? End Select - ' comunico che nessun evento particolare è stato selezionato Map.refMainWindowVM.selectedWatcher = MainWindowVM.WatcherCalling.NoEvents Else @@ -270,11 +274,11 @@ Public Class AssemblyManagerVM Dim IndexCompo As Integer = 0 For IndexCompo = 0 To CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList.Count - 1 If CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList(IndexCompo).LoadByDefault Then + CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList(IndexCompo).CompoType.LoadListTemplate() Dim ErrCompo As Compo = CurrAssembly.ListPartDoor(IndexPart).Door.m_CompoList(IndexCompo) Dim CurrPart As Part = CurrAssembly.ListPartDoor(IndexPart).Door ReCreateCompo(ErrCompo, CurrPart) ElseIf CurrAssembly.ListPartDoor(0).Door.m_CompoList(IndexCompo).ErrorValue Then - End If Next Next @@ -296,7 +300,8 @@ Public Class AssemblyManagerVM End Function ' ricarica l'elenco dei file per la componnete selezionata - Private Function ReCreateCompo(ByRef ErrCompo As Compo, CurrPart As Part) As Boolean + Private Function ReCreateCompo(ByRef ErrCompo As Compo, CurrPart As Part, Optional ByVal IndexCompo As Integer = -1) As Boolean + Dim DDFIsModified As Boolean = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified ' Controllo esistenza del componente Dim CompoListIndex As Integer = -1 CompoListIndex = SearchCompotypeIndex(ErrCompo.CompoType.DDFName) @@ -331,6 +336,7 @@ Public Class AssemblyManagerVM For IndexBrand As Integer = 0 To m_CurrCompo.BrandListPart.Count - 1 If sBrand.ToLower = m_CurrCompo.BrandListPart(IndexBrand).ToLower Then m_CurrCompo.SelBrandPart = m_CurrCompo.BrandListPart(IndexBrand) + m_CurrCompo.MissingDirectory = False bBrandExists = True Exit For End If @@ -339,6 +345,7 @@ Public Class AssemblyManagerVM For IndexFile As Integer = 0 To m_CurrCompo.FileList.Count - 1 If ErrCompo.SelFile.ToLower = m_CurrCompo.FileList(IndexFile).ToLower Then m_CurrCompo.SelFile = m_CurrCompo.FileList(IndexFile) + m_CurrCompo.MissingFile = False bFileExists = True Exit For End If @@ -347,24 +354,65 @@ Public Class AssemblyManagerVM ' in caso sia fallita la ricera dei direttori o dei file If Not bBrandExists OrElse Not bFileExists Then + ' se la compoenente che sto caricando era corretta ErrCompo.LoadByDefault = True + ' se il brand non esiste, ma è selezionato + If Not bBrandExists Then + ErrCompo.MissingDirectory = True + ErrCompo.MissingFile = True + ' aggiungo alla lista dei file che esistono quelli sbagliati, ed elimino quelli che non sono in quel momento selezioanti + RefreshListFile(m_CurrCompo.BrandListPart, ErrCompo.BrandListPart) + For Each BrandItem In ErrCompo.BrandListPart + ' ricerco l'elemento selezionato + If BrandItem = ErrCompo.SelBrandPart Then + ' se il direttorio non esiste ne viene creato uno fasullo, o recupera i file che appartngono al direttorio fasullo + ErrCompo.SelBrandPart = BrandItem + If ErrCompo.FileList.Count < 1 Then + ErrCompo.FileList.Add(ErrCompo.SelFile) + End If + ErrCompo.SelFile = ErrCompo.FileList(ErrCompo.FileList.Count - 1) + End If + Next + Else + ErrCompo.MissingDirectory = False + End If + If Not bFileExists AndAlso bBrandExists Then + ErrCompo.MissingFile = True + 'If Map.refMainWindowVM.selectedWatcher = MainWindowVM.WatcherCalling.OnRenamed Then + RefreshListFile(m_CurrCompo.FileList, ErrCompo.FileList) + 'End If + End If + If Not DDFIsModified Then + Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = False + End If Return False End If - Dim s As String = String.Empty + + Dim sErrorInfo As String = String.Empty + CopyCompoParamList(m_CurrCompo.CompoParamList, ErrCompo.CompoParamList) m_CurrCompo.m_ParameterDDfList = ErrCompo.m_ParameterDDfList - ReadParams(m_CurrCompo, s) - ErrCompo.LoadByDefault = False + If Not ReadParams(m_CurrCompo, sErrorInfo) Then + m_CurrCompo.MissingParameter = ErrCompo.MissingParameter + m_CurrCompo.ErrorValue = ErrCompo.ErrorValue + End If m_CurrCompo.LoadByDefault = False - ErrCompo.CompoParamList = m_CurrCompo.CompoParamList - CurrPart.CompoList.Add(m_CurrCompo) - ErrCompo.Delete() + 'm_CurrCompo.ErrorColor = ErrCompo.ErrorColor + ErrCompo.Delete(False) + If IndexCompo > -1 Then + CurrPart.CompoList.Insert(IndexCompo, m_CurrCompo) + Else + CurrPart.CompoList.Add(m_CurrCompo) + End If + If Not DDFIsModified Then + Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = False + End If Return True End Function ' Leggo i parametri del componente - Private Sub ReadParams(ByRef CompoTemplateItem As Compo, ByRef sErrorInfo As String) + Public Function ReadParams(ByRef CompoTemplateItem As Compo, ByRef sErrorInfo As String) As Boolean Dim IndexLine As Integer = 0 - If CompoTemplateItem.m_ParameterDDfList.Count < 1 Then Return + If CompoTemplateItem.m_ParameterDDfList.Count < 1 Then Return False Dim FileContent As List(Of String) = CompoTemplateItem.m_ParameterDDfList ' questo è l'indice dei parametri del componente @@ -487,7 +535,7 @@ Public Class AssemblyManagerVM 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).Value = sVal + DirectCast(CurrCompoParam, TextBoxOnOffParam).SetValue(sVal) Dim dVal As Double If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then CompoTemplateItem.ErrorValue = True @@ -577,8 +625,111 @@ Public Class AssemblyManagerVM IndexParam += 1 IndexLine = SkipWhiteSpaceList(FileContent, IndexLine + 1) End While + CompoTemplateItem.m_ParameterDDfList.Clear() + Return True + End Function - End Sub + ' copia i valori delle textbox e delle combobox + Private Function CopyCompoParamList(NewList As ObservableCollection(Of CompoParam), OldList As ObservableCollection(Of CompoParam)) As Boolean + Dim IndexParam As Integer = 0 + For IndexParam = 0 To OldList.Count - 1 + + If TypeOf OldList(IndexParam) Is TextBoxOnOffParam Then + Dim OldParam As TextBoxOnOffParam = DirectCast(OldList(IndexParam), TextBoxOnOffParam) + Dim NewParam As TextBoxOnOffParam = DirectCast(NewList(IndexParam), TextBoxOnOffParam) + NewParam.m_Value = OldParam.m_Value + NewParam.SetIsActive(OldParam.IsActive) + Dim dVal As Double + If StringToDouble(OldParam.Value, dVal) Then + NewList(IndexParam).ErrorInReading = False + Else + NewList(IndexParam).ErrorInReading = True + End If + + ElseIf TypeOf OldList(IndexParam) Is TextBoxParam Then + Dim OldParam As TextBoxParam = DirectCast(OldList(IndexParam), TextBoxParam) + Dim NewParam As TextBoxParam = DirectCast(NewList(IndexParam), TextBoxParam) + NewParam.m_Value = OldParam.m_Value + NewParam.MissingParameterInReading = OldParam.MissingParameterInReading + Dim dVal As Double + If StringToDouble(OldParam.Value, dVal) Then + NewList(IndexParam).ErrorInReading = False + Else + NewList(IndexParam).ErrorInReading = True + End If + + ElseIf TypeOf OldList(IndexParam) Is ComboBoxParam Then + Dim OldParam As ComboBoxParam = DirectCast(OldList(IndexParam), ComboBoxParam) + Dim NewParam As ComboBoxParam = DirectCast(NewList(IndexParam), ComboBoxParam) + + If OldParam.ItemList.Count > OldParam.ItemListDDF.Count Then + NewParam.ItemList.Add(OldParam.ItemList.Last) + NewParam.SetSelItem(NewParam.ItemList.Last) + NewList(IndexParam).ErrorInReading = True + End If + Dim IndexItem As Integer = -1 + For IndexItem = 0 To OldParam.ItemListDDF.Count - 1 + If OldParam.SelItem = OldParam.ItemList(IndexItem) Then + NewList(IndexParam).ErrorInReading = False + NewParam.MissingParameterInReading = OldParam.MissingParameterInReading + NewParam.SetSelItem(NewParam.ItemList(IndexItem)) + If OldParam.ItemList.Count > OldParam.ItemListDDF.Count Then + OldParam.ItemList.RemoveAt(OldParam.ItemList.Count - 1) + NewParam.ItemList.RemoveAt(NewParam.ItemList.Count - 1) + End If + Exit For + End If + Next + 'ElseIf TypeOf ErrCompo.CompoParamList(IndexParam) Is ComboBoxOnOffParam Then + ' Dim Param As ComboBoxOnOffParam = DirectCast(ErrCompo.CompoParamList(IndexParam), ComboBoxOnOffParam) + ' For Each Item In Param.ItemListDDF + ' If Param.SelItem = Item Then + ' If Param.ItemList.Count > Param.ItemListDDF.Count Then + ' Param.ItemList.RemoveAt(Param.ItemList.Count - 1) + ' End If + ' Param.ErrorInReading = False + ' Exit For + ' End If + ' Next + End If + + Next + Return True + End Function + + ' aggiunge alla lista dei file esistenti quelli che non esistono più + Private Function RefreshListFile(CorrectList As ObservableCollection(Of String), ErrList As ObservableCollection(Of String)) As Boolean + Dim IndexC As Integer = 0 + Dim IndexErr As Integer = 0 + Dim bCommunFile As Boolean = False + Dim NewFileList As New ObservableCollection(Of String) + For IndexC = 0 To CorrectList.Count - 1 + bCommunFile = False + For IndexErr = 0 To ErrList.Count - 1 + If CorrectList(IndexC) = ErrList(IndexErr) Then + bCommunFile = True + Exit For + End If + Next + If Not bCommunFile Then + NewFileList.Add(CorrectList(IndexC)) + End If + Next + For Each Item In NewFileList + ErrList.Add(Item) + Next + Return True + End Function + + Private Function DeleteFileInList(SelFile As String, ByRef ErrFileList As ObservableCollection(Of String)) As Boolean + Dim IndexList As Integer = ErrFileList.Count - 1 + For Index As Integer = IndexList To 0 Step -1 + If SelFile.ToLower <> ErrFileList(Index).ToLower Then + ErrFileList.RemoveAt(Index) + End If + Next + Return True + End Function ' verifica che la componente non riceva un errore in fase di inserimento di un parametro Public Function RecreateCompoParm(ByRef ErrCompo As Compo, CurrPart As Part) As Boolean diff --git a/DdfFile.vb b/DdfFile.vb index cf8a947..07ef9a2 100644 --- a/DdfFile.vb +++ b/DdfFile.vb @@ -824,7 +824,8 @@ Friend Module DdfFile DdfFileContent.Add("") ' scrivo il messaggio di errore If Not String.IsNullOrEmpty(WritingError) Then - ErrorInWriting &= vbCrLf & WritingError & vbCrLf + WritingError &= Environment.NewLine + ErrorInWriting &= WritingError End If Return True End Function @@ -851,8 +852,8 @@ Friend Module DdfFile For Each ItemLine In Compo.m_ParameterDDfList CompoListDDF.Add(ItemLine) Next + Return CompoListDDF End If - Return CompoListDDF ParamInCompoIsCorrect = False Else CompoListDDF.Add(DDF_HYPHEN & Compo.TemplateDDFName & ": " & Compo.TemplateSelItem) @@ -953,7 +954,7 @@ Friend Module DdfFile End If End If Else - ' Error in reading {0} in compo {1}. + ' 50125 =Error in reading {0} in compo {1}. sErrorList &= String.Format(EgtMsg(50125), cbParam.Name, Compo.CompoType.DDFName) ParamInCompoIsCorrect = False If Compo.LoadByDefault And Not SaveErrorCompo Then @@ -1029,7 +1030,7 @@ Friend Module DdfFile End If End If ElseIf Not String.IsNullOrWhiteSpace(tbParam.ToolTipValue) And Compo.MissingParameter Then - If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine + ' If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine ' Missing parameter {0} in {1}. ' sErrorList &= String.Format("Missing parameter {0}.", tbParam.Name, Compo.CompoType.DDFName) If tbParam.ToolTipValue = EgtMsg(50143) Then diff --git a/DoorParameters/Compo.vb b/DoorParameters/Compo.vb index d962231..407b8da 100644 --- a/DoorParameters/Compo.vb +++ b/DoorParameters/Compo.vb @@ -30,7 +30,7 @@ Public Class Compo ' creo la stringa che contiene la lista degli errori Dim ErrorList As String = String.Empty - + Private m_ConfigurationParameters As String Public ReadOnly Property ConfigurationParameters As String Get @@ -112,6 +112,28 @@ Public Class Compo Public m_ParameterDDfList As New List(Of String) + Private m_MissingDirectory As Boolean = False + Public Property MissingDirectory As Boolean + Get + Return m_MissingDirectory + End Get + Set(value As Boolean) + m_MissingDirectory = value + NotifyPropertyChanged("MissingDirectory") + End Set + End Property + + Private m_MissingFile As Boolean = False + Public Property MissingFile As Boolean + Get + Return m_MissingFile + End Get + Set(value As Boolean) + m_MissingFile = value + NotifyPropertyChanged("MissingFile") + End Set + End Property + Private m_LoadByDefault As Boolean = False Public Property LoadByDefault As Boolean Get @@ -197,6 +219,9 @@ Public Class Compo ElseIf m_LoadByDefault And Not m_MissingParameter And Not m_ErrorValue Then ErrorColor = DirectCast(New BrushConverter().ConvertFrom(OptionModule.ColorLoadByDefault), SolidColorBrush) Return True + ElseIf m_LoadByDefault And (m_MissingParameter OrElse m_ErrorValue) Then + ErrorColor = DirectCast(New BrushConverter().ConvertFrom(OptionModule.ColorLoadByDefault), SolidColorBrush) + Return True ElseIf m_MissingParameter And m_ErrorValue Then ErrorColor = DirectCast(New BrushConverter().ConvertFrom(OptionModule.ColorErrorAndMissing), SolidColorBrush) Return True @@ -283,6 +308,9 @@ Public Class Compo End Set End Property + ' salvo nella compoenente il direttorio fasullo + Private FakeDir As CompoBrandDir + ' selezione del marchio Private m_SelBrandPart As String Public Property SelBrandPart As String @@ -296,33 +324,61 @@ Public Class Compo ' distinguo il caricamento della lista dei frame If m_BrandListPart(IndexModelList) = m_SelBrandPart Then If value.ToLower.Contains(".frame") Then - If IndexModelList > CompoType.FrameFolderList.Count - 1 Then + If Not Directory.Exists(CompoType.Path & "\" & m_SelBrandPart) Or IndexModelList > CompoType.FrameFolderList.Count - 1 Then ' se il direttorio che cerco non esiste allora ne creo uno fasullo con una lista di file vuota - Dim FakeDir As New CompoBrandDir(CompoType.Path & "\" & m_SelBrandPart, "") - If Not IsNothing(FakeDir) Then - ' se la creazione è andata a buon fine seleziono il direttorio - CompoType.FolderList.Add(FakeDir) - FileList = CompoType.FolderList(CompoType.FolderList.Count - 1).ModelFileList + If IsNothing(FakeDir) Then + FakeDir = New CompoBrandDir(CompoType.Path & "\" & m_SelBrandPart, "") + If Not IsNothing(FakeDir) Then + ' se la creazione è andata a buon fine seleziono il direttorio + CompoType.FolderList.Add(FakeDir) + End If + End If + ' se il direttorio già esiste allora lo carico con la lista finta + If Not IsNothing(FakeDir) Then + FileList = FakeDir.ModelFileList + End If + ' se la lista finta ha almeno un valore + If FileList.Count > 0 Then + SelFile = FileList(0) + Else + SelFile = String.Empty End If - SelFile = String.Empty ' quindi esco (non carico nessun file) Return End If m_FileList = CompoType.FrameFolderList(IndexModelList).ModelFileList Else - If IndexModelList > CompoType.FolderList.Count - 1 Then + If Not Directory.Exists(CompoType.Path & "\" & m_SelBrandPart) Then ' se il direttorio che cerco non esiste allora ne creo uno fasullo con una lista di file vuota - Dim FakeDir As New CompoBrandDir(CompoType.Path & "\" & m_SelBrandPart, "") - If Not IsNothing(FakeDir) Then - ' se la creazione è andata a buon fine seleziono il direttorio - CompoType.FolderList.Add(FakeDir) - FileList = CompoType.FolderList(CompoType.FolderList.Count - 1).ModelFileList + If IsNothing(FakeDir) Then + FakeDir = New CompoBrandDir(CompoType.Path & "\" & m_SelBrandPart, "") + If Not IsNothing(FakeDir) Then + ' se la creazione è andata a buon fine seleziono il direttorio + CompoType.FolderList.Add(FakeDir) + End If + End If + ' se il direttorio già esiste allora lo carico con la lista finta + If Not IsNothing(FakeDir) Then + FileList = New ObservableCollection(Of String) + FileList = FakeDir.ModelFileList + NotifyPropertyChanged("FileList") + End If + ' se la lista finta ha almeno un valore + If FileList.Count > 0 Then + SelFile = FileList(0) + Else + SelFile = String.Empty End If - SelFile = String.Empty ' quindi esco (non carico nessun file) Return End If - m_FileList = CompoType.FolderList(IndexModelList).ModelFileList + For Each ItemFolderCompo In CompoType.FolderList + If ItemFolderCompo.ModelDirGraphic.ToLower = m_SelBrandPart.ToLower Then + m_FileList = ItemFolderCompo.ModelFileList + Exit For + End If + Next + End If Exit For End If @@ -368,6 +424,7 @@ Public Class Compo End Get Set(value As ObservableCollection(Of String)) m_FileList = value + NotifyPropertyChanged("FileList") End Set End Property @@ -452,7 +509,7 @@ Public Class Compo End Get Set(value As String) SetTemplateSelItem(value) - LoadByDefault = False + ' LoadByDefault = False SetModified() Map.refSceneManagerVM.RefreshBtn() End Set @@ -502,8 +559,19 @@ Public Class Compo ' seleziono il nome, controllo che esista il file altrimenti esco m_TemplateSelItem = value If Not File.Exists(CurrItemPath) Then + If Directory.Exists(Path.GetDirectoryName(CurrItemPath)) Then + Me.MissingDirectory = False + Me.MissingFile = True + Else + Me.MissingDirectory = True + Me.MissingFile = True + End If + Me.LoadByDefault = True Return End If + Me.LoadByDefault = False + Me.MissingDirectory = False + Me.MissingFile = False ' carico un vettore con le stringhe del file corrente Dim ReadCurrCompo() As String = File.ReadAllLines(CurrItemPath) For LineIndex = 0 To ReadCurrCompo.Count - 1 @@ -522,6 +590,7 @@ Public Class Compo Next ReadParamConfig(ErrorList, ConfigDefault) ReadDefaultParamLua(CurrItemPath, Me) + Map.refAssemblyManagerVM.ReadParams(Me, "") End If If Not String.IsNullOrWhiteSpace(ErrorList) Then EgtOutLog(ErrorList) End Sub @@ -553,6 +622,12 @@ Public Class Compo End If ParamIndex += 1 End While + Me.ErrorValue = False + Me.MissingParameter = False + For Each ItemParam In Me.CompoParamList + If ItemParam.ErrorInReading Then Me.ErrorValue = True + If ItemParam.MissingParameterInReading Then Me.MissingParameter = True + Next End Sub ' inserisco il parametro letto nella lista dei paramtri senza modificare i parametri già esistenti @@ -1594,10 +1669,10 @@ Public Class Compo End Get End Property - Public Sub Delete() + Public Sub Delete(Optional RefreshDraw As Boolean = True) Dim DeleteNameHardware As String = Me.CompoType.Name Map.refPartPageVM.CurrPart.RemoveCompo(Me) - Map.refSceneManagerVM.RefreshBtn() + If RefreshDraw Then Map.refSceneManagerVM.RefreshBtn() SetModified() Dim bExist As Boolean = False ' aggiorno lista hardware di quotatura @@ -1980,7 +2055,7 @@ Public Class TextBoxOnOffParam m_IsActive = value SetModified() ' ErrorInReading = False - CurrCompo.MissingParameter = False + ' CurrCompo.MissingParameter = False ' CurrCompo.ErrorValue = False Map.refSceneManagerVM.RefreshBtn() End Set @@ -2180,7 +2255,7 @@ Public Class ComboBoxOnOffParam Set(value As Boolean) m_IsActive = value ' ErrorInReading = False - CurrCompo.MissingParameter = False + ' CurrCompo.MissingParameter = False ' CurrCompo.ErrorValue = False SetModified() Map.refSceneManagerVM.RefreshBtn() diff --git a/DoorParameters/Part.vb b/DoorParameters/Part.vb index f247757..e377f81 100644 --- a/DoorParameters/Part.vb +++ b/DoorParameters/Part.vb @@ -833,8 +833,8 @@ Public Class Part Dim FileNameComplete As String = String.Empty ' converto tutti gli sfondi in bianco dei nomi delle componenti For Each Compo In Map.refPartPageVM.CurrPart.CompoList - Compo.BorderColor = New BrushConverter().ConvertFrom("#DCDCDC") - Compo.BackGroundColor = New BrushConverter().ConvertFrom("#FFFFFF") + Compo.BorderColor = DirectCast(New BrushConverter().ConvertFrom("#DCDCDC"), SolidColorBrush) + Compo.BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("#FFFFFF"), SolidColorBrush) Compo.BorderThickness = 1 Next ' creo la stringa che contiene la lista degli errori @@ -912,8 +912,8 @@ Public Class Part NewCompo.ReadDefaultParamLua(FileNameComplete, NewCompo) End If ' evidenzio il nome della componente appena aggiunto - NewCompo.BorderColor = New BrushConverter().ConvertFrom("#DCDCDC") - NewCompo.BackGroundColor = New BrushConverter().ConvertFrom("#DCDCDC") + NewCompo.BorderColor = DirectCast(New BrushConverter().ConvertFrom("#DCDCDC"), SolidColorBrush) + NewCompo.BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("#DCDCDC"), SolidColorBrush) NewCompo.BorderThickness = 1 End If Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True @@ -1217,7 +1217,6 @@ Public Class Part If String.IsNullOrEmpty(sErrorInfo) Then sErrorInfo = EgtMsg(50156) ReadDoor = Nothing End If - ' Aggiorno If Not IsNothing(ReadDoor) And ReadDoorCompleted Then ' se la porta esiste allora mostro i suoi parametri @@ -2038,8 +2037,8 @@ Public Class Part If String.IsNullOrEmpty(BrandDir) Then BrandDir = RAD_DIR m_CurrCompo.BrandListPart.Add(BrandDir) m_CurrCompo.SelBrandPart = m_CurrCompo.BrandListPart(m_CurrCompo.BrandListPart.Count - 1) - 'm_CurrCompo = m_ErrCompo m_CurrCompo.LoadByDefault = True + m_CurrCompo.MissingDirectory = True End If If Not bFileExists Then m_CurrCompo.FileList.Add(sFile) @@ -2047,6 +2046,7 @@ Public Class Part ' File {0} in directory {1} has not been found. sErrorInfo &= String.Format(EgtMsg(50160), sFile, BrandDir) & vbCrLf m_CurrCompo.LoadByDefault = True + m_CurrCompo.MissingFile = True End If ' mi sposto alla riga successiva, anche se la componente è sbagliata carico comunque i suoi dati Index = NextIndex(Index) @@ -2144,7 +2144,8 @@ Public Class Part If CompoTemplateItem.LoadByDefault Then While IndexLine < FileContent.Count - 1 AndAlso Not (Search3Hyphens(RemoveComment(FileContent(IndexLine))) OrElse Search3Dots(RemoveComment(FileContent(IndexLine)))) AndAlso - Not Trim(RemoveComment(FileContent(IndexLine))).StartsWith("- ") + Not Trim(RemoveComment(FileContent(IndexLine))).StartsWith("- ") AndAlso + RemoveComment(FileContent(IndexLine)).StartsWith(ConstCompo.DDF_SPACE3) ' salvo i commenti If String.IsNullOrWhiteSpace(FileContent(IndexLine)) Then IndexLine += 1 @@ -2153,6 +2154,7 @@ Public Class Part ErrParamList.Add(RemoveComment(FileContent(IndexLine))) IndexLine += 1 End While + CompoTemplateItem.m_ParameterDDfList = ErrParamList Else While IndexParam < CompoTemplateItem.CompoParamList.Count diff --git a/DoorParameters/PartPageV.xaml b/DoorParameters/PartPageV.xaml index 6b94143..6d769cf 100644 --- a/DoorParameters/PartPageV.xaml +++ b/DoorParameters/PartPageV.xaml @@ -386,8 +386,19 @@ - + + + + + - + + + + + - - + + diff --git a/OptionsWindow/OptionModule.vb b/OptionsWindow/OptionModule.vb index c92ff75..6974d96 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -127,10 +127,10 @@ Friend Module OptionModule Friend m_TotalHeight As String Friend m_TotalWidth As String - Friend ColorErrorValue As String = "Yellow" - Friend ColorMissingParameter As String = "Pink" + Friend ColorErrorValue As String = "Red" + Friend ColorMissingParameter As String = "Yellow" Friend ColorLoadByDefault As String = "Red" - Friend ColorErrorAndMissing As String = "Orange" + Friend ColorErrorAndMissing As String = "Red" Friend m_CompoPaneOrder As List(Of String) = New List(Of String) @@ -384,6 +384,42 @@ Friend Module OptionModule DefaultGetPrivateProfileList(S_COMPOORDER, K_COMPOORDER_INI, DdfFile.CompoListOrder) ' carico l'ordinamento dei bottoni DefaultGetPrivateProfileList(S_COMPOOPANELORDER_INI, K_COMPOORDER_INI, m_CompoPaneOrder) + + 'carico i colori da associare agli errori + Dim sColor As String = String.Empty + Dim ColorConvert As SolidColorBrush + DefaultGetPrivateProfileString("Error", "Value", "Red", sColor) + If Not String.IsNullOrEmpty(sColor) Then + Try + ColorConvert = DirectCast(New BrushConverter().ConvertFrom(sColor), SolidColorBrush) + ColorErrorValue = sColor + Catch ex As Exception + End Try + End If + DefaultGetPrivateProfileString("Error", "MissingParameter", "Yellow", sColor) + If Not String.IsNullOrEmpty(sColor) Then + Try + ColorConvert = DirectCast(New BrushConverter().ConvertFrom(sColor), SolidColorBrush) + ColorMissingParameter = sColor + Catch ex As Exception + End Try + End If + DefaultGetPrivateProfileString("Error", "MissingFile", "Red", sColor) + If Not String.IsNullOrEmpty(sColor) Then + Try + ColorConvert = DirectCast(New BrushConverter().ConvertFrom(sColor), SolidColorBrush) + ColorLoadByDefault = sColor + Catch ex As Exception + End Try + End If + DefaultGetPrivateProfileString("Error", "ValueAndMissing", "Red", sColor) + If Not String.IsNullOrEmpty(sColor) Then + Try + ColorConvert = DirectCast(New BrushConverter().ConvertFrom(sColor), SolidColorBrush) + ColorErrorAndMissing = sColor + Catch ex As Exception + End Try + End If '----------------------------------------------------------------------------------------------------------------- Dim ThicknessJamb As String = String.Empty diff --git a/ProjectManager/ProjectManagerVM.vb b/ProjectManager/ProjectManagerVM.vb index 2b6f1d7..39bab09 100644 --- a/ProjectManager/ProjectManagerVM.vb +++ b/ProjectManager/ProjectManagerVM.vb @@ -240,7 +240,7 @@ Public Class ProjectManagerVM Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name ' Creo nuova porta Map.refAssemblyManagerVM.AddAssembly() - Map.refOptionsVM.MyProjectDir = CurrProject.Name + ' Map.refOptionsVM.MyProjectDir = CurrProject.Name Return End If @@ -252,6 +252,14 @@ Public Class ProjectManagerVM saveFileDialog1.Filter = "(*.ddf) |*.ddf" saveFileDialog1.FilterIndex = 2 saveFileDialog1.InitialDirectory = Map.refOptionsVM.MyProjectDir + ' carico l'ultimo direttorio aperto, se questo preocediento fallisce allora parto dal direttorio inserito di default + If File.Exists(OptionModule.m_sLastProject) Then + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject) + ElseIf Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(Path.GetDirectoryName(OptionModule.m_sLastProject)) Then + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject) + ElseIf Not Path.HasExtension(OptionModule.m_sLastProject) AndAlso Directory.Exists(OptionModule.m_sLastProject) Then + saveFileDialog1.InitialDirectory = OptionModule.m_sLastProject + End If ' apro la finestra di dialogo If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim FilePathComplete As String = saveFileDialog1.FileName @@ -363,12 +371,11 @@ Public Class ProjectManagerVM Dim fd As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog() fd.Title = "Open File Dialog" ' indirizzo la scelta verso una cartella - If Not String.IsNullOrEmpty(Map.refOptionsVM.MyProjectDir) Then - fd.InitialDirectory = Map.refOptionsVM.MyProjectDir + fd.InitialDirectory = Map.refOptionsVM.MyProjectDir + If Not String.IsNullOrWhiteSpace(Map.refAssemblyManagerVM.CurrProject.Name) Then + fd.InitialDirectory = Map.refAssemblyManagerVM.CurrProject.Name ElseIf Not String.IsNullOrEmpty(OptionModule.m_sLastProject) Then fd.InitialDirectory = Path.GetDirectoryName(OptionModule.m_sLastProject) - ElseIf Not String.IsNullOrWhiteSpace(Map.refAssemblyManagerVM.CurrProject.Name) Then - fd.InitialDirectory = Map.refAssemblyManagerVM.CurrProject.Name Else fd.InitialDirectory = IniFile.m_MyProjectDir End If @@ -476,7 +483,7 @@ Public Class ProjectManagerVM WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Map.refAssemblyManagerVM.CurrProject.Name) End If ' Aggiungo alla lista dei recenti/ verifico se esite anche se posso salvare un indirizzo comlpeto - Map.refOptionsVM.MyProjectDir = sFilePath + ' Map.refOptionsVM.MyProjectDir = sFilePath If bIsSingleDoor Then m_MruFiles.Add(CurrProject.SelAssemblyName.Name) Else @@ -519,10 +526,10 @@ Public Class ProjectManagerVM Public Sub ReloadCmd() If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then Map.SetRefCompoPanelVM(New CompoPanelVM("PartPage")) If IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) Then Return - ' Map.refSceneManagerVM.RefreshBtn() ' Map.refAssemblyManagerVM.LoadTempFile() ' Map.refMainWindowVM.selectedWatcher = MainWindowVM.WatcherCalling.OnLoadTempFile Map.refAssemblyManagerVM.RefreshAssembly() + Map.refSceneManagerVM.RefreshBtn() End Sub #End Region ' ReloadCommand @@ -549,7 +556,7 @@ Public Class ProjectManagerVM Map.refAssemblyManagerVM.Save(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) If DdfFile.DDFIsCorrect Then Map.refSceneManagerVM.RefreshBtn() ' aggiorno l'immagine solo se il salvataggio è andato a buon fine ' Aggiungo alla lista dei recenti/ verifico se esite anche se posso salvare un indirizzo comlpeto - Map.refOptionsVM.MyProjectDir = Map.refAssemblyManagerVM.CurrProject.Name + ' Map.refOptionsVM.MyProjectDir = Map.refAssemblyManagerVM.CurrProject.Name If OptionModule.m_SingleDoor Then m_MruFiles.Add(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name) Else @@ -659,7 +666,7 @@ Public Class ProjectManagerVM CurrProject.NotifyPropertyChanged("Name") CurrProject.NotifyPropertyChanged("AssemblyList") Map.refMainWindowVM.ProjectNameMsg = CurrProject.Name - Map.refOptionsVM.MyProjectDir = CurrProject.Name + 'Map.refOptionsVM.MyProjectDir = CurrProject.Name 'Map.refMainWindowVM.ModifyTitle(False) ' Se c'è almeno una porta la visualizzo