Imports System.Collections.ObjectModel Imports System.IO Imports EgtUILib Imports System.Text.RegularExpressions Friend Module DdfFile ' lista ordinata delle componenti da stampare Friend CompoListOrder As New List(Of String) Friend UnitMeasure As String #Region "SCRITTURA DDF" ' Questa funzione dovrà sostituire quella precedente (Scritta sopra) Private IdIndex As Integer = 0 Friend Sub WriteDDFPart(Part As Part, sPath As String, bIsTemplate As Boolean, bIsForAssembly As Boolean) ' pulisco lista prima di iniziare a scrivere Dim DdfFileContent As New List(Of String) ' quindi significa che non è mai stato caricato il valore If IsNothing(Part.Measure) Then Part.Measure = OptionModule.m_SelectedMeasureUnit End If DdfFileContent.Add("#EGTDOORCREATOR") If Not IsNothing(Part.TypePart) Then DdfFileContent.Add("#" & PrintTitleDDFPart(Part.TypePart)) If Part.IsActive Then DdfFileContent.Add("produce: " & "true") Else DdfFileContent.Add("produce: " & "false") End If End If DdfFileContent.Add("") 'Genero una lista di stringhe If Part.Measure = "Inches" Then Part.Measure = "inches" End If DdfFileContent.Add(ConstCompo.K_MEASURES & ": " & Part.Measure) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") If Not IsNothing(Part.TypePart) Then Part.Code = " " & PrintTitleDDFPart(Part.TypePart) DdfFileContent.Add(ConstCompo.K_CODE & ": " & Part.Code) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") Else DdfFileContent.Add(ConstCompo.K_CODE & ": " & "1111") ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") End If DdfFileContent.Add(ConstCompo.S_ORDER & ":") ' Probabilmente da cambiare If Not IsNothing(Part.Customer) Then DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_CUSTOMER & ": " & Part.Customer) Else DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_CUSTOMER & ": ") End If If Not IsNothing(Part.Elevation) Then DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_ELEVATION & ": " & Part.Elevation) Else DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_ELEVATION & ": ") End If If Not IsNothing(Part.Project) Then DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PROJECT & ": " & Part.Project) Else DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PROJECT & ": ") End If If Not IsNothing(Part.PO) Then DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PO & ": " & Part.PO) Else DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_PO & ": ") End If If Not IsNothing(Part.Line) Then DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LINE & ": " & Part.Line) Else DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LINE & ": ") End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add(ConstCompo.K_DATE & ":" & " " & System.DateTime.Now.ToString("dd/MM/yyyy")) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") ' è specificato il tipo significa che abbiamo un assemblato DdfFileContent.Add("piece: " & Part.TypePart) DdfFileContent.Add("") If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then If Not IsNothing(Part.TypePart) Then ' il posizionamento della prima porta sta nell'origine If Part.TypePart = "DO_1" Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & "0") DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & "0") DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & "0") ElseIf Part.TypePart = "DO_2" Then ' si trova traslata verso destra dello spessore DO_1 sommato a LightLock" Dim x_DO_1 As Double Dim dLightLock As Double StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Width, x_DO_1) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightLock, dLightLock) Dim x As String = DoubleToString(x_DO_1 + dLightLock, 4) DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & x) DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & "0") DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & "0") ' Jamb Sinistro serratura ElseIf Part.TypePart.Contains("FL_") Then Dim x As String = PositionJamb_X(Part) Dim y As String = PositionJamb_Y(Part) Dim z As String = PositionJamb_Z(Part) DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & x) DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & y) DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & z) ElseIf Part.TypePart.Contains("FR_") Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains("FT_") Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains("FB_") Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.K_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.K_SPACE3 & "z: " & PositionJamb_Z(Part)) End If DdfFileContent.Add("") End If End If Dim dVal As Double = 0 DdfFileContent.Add(ConstCompo.K_SIZE & ":") If Not StringToDouble(Part.Width, dVal) Then MessageBox.Show(EgtMsg(50106) & K_WIDTH, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_WIDTH & ": " & DoubleToString(dVal, 5)) If Not StringToDouble(Part.Height, dVal) Then MessageBox.Show(EgtMsg(50106) & K_HEIGHT, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HEIGHT & ": " & DoubleToString(dVal, 5)) If Not StringToDouble(Part.Thickness, dVal) Then MessageBox.Show(EgtMsg(50106) & K_THICKNESS, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5)) ' aggiungo il peso della porta If Part.IsCheckedWeight = Visibility.Visible Then If Not StringToDouble(Part.Weight, dVal) Then MessageBox.Show(EgtMsg(50106) & K_WEIGHT, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_WEIGHT & ": " & Part.Weight) End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add("" & ConstCompo.K_SWING & ": " & Part.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 & ": " & Part.LockEdgeType.Name) DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.LockEdgeMachining)) If Not StringToDouble(Part.LockEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_LOCKEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & Part.HingeEdgeType.Name) DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.HingeEdgeMachining)) If Not StringToDouble(Part.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_HINGEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_TOP & ": " & Part.TopType.Name) DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.TopMachining)) If Not StringToDouble(Part.TopOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_TOPOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.K_SPACE3 & ConstCompo.K_BOTTOM & ": " & Part.BottomType.Name) DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.BottomMachining)) If Not StringToDouble(Part.BottomOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_BOTTOMOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return End If DdfFileContent.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) ' Riordino e stampo le compo SearchCompo(DdfFileContent, Part, bIsTemplate) If Not Directory.Exists(Path.GetDirectoryName(sPath)) Then Directory.CreateDirectory(Path.GetDirectoryName(sPath)) End If '----------------------------------------------------------------------------------------------------------------------------------- 'Stampa su file If bIsForAssembly Then File.AppendAllLines(sPath, DdfFileContent, Text.Encoding.UTF8) Else File.WriteAllLines(sPath, DdfFileContent, Text.Encoding.UTF8) End If End Sub #Region "Funzioni per il posizionamento" Private Function PositionJamb_Y(CurrPart As Part) As String Dim y As String Dim dLightBottom As Double Dim dThicknessJamb As Double Dim dLightUp As Double Dim dOverlapTop As Double Dim dHeightDoor As Double StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightUp, dLightUp) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.OverlapTop, dOverlapTop) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.Width, dThicknessJamb) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightBottom, dLightBottom) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Height, dHeightDoor) If CurrPart.TypePart.Contains("E") Then If CurrPart.TypePart.Contains("FT_") Then y = DoubleToString(dHeightDoor - dOverlapTop + dLightUp, 4) Else y = DoubleToString(-dLightBottom - dThicknessJamb, 4) End If Else If CurrPart.TypePart.Contains("FT_") Then y = DoubleToString(dHeightDoor + dLightUp, 4) Else y = DoubleToString(-dLightBottom, 4) End If End If Return y End Function Private Function PositionJamb_X(CurrPart As Part) As String Dim x As String = "0" Dim dLightLock As Double Dim dLightHinge As Double Dim dOverlapLock As Double Dim dOverlapHinge As Double Dim dThicknessJamb As Double Dim dWidthDoor_0 As Double Dim dWidthDoor_1 As Double StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightLock, dLightLock) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightHinge, dLightHinge) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.OverlapLock, dOverlapLock) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.OverlapHinge, dOverlapHinge) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.Width, dThicknessJamb) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Width, dWidthDoor_0) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.Width, dWidthDoor_1) If CurrPart.TypePart.Contains("E") Then ' posizione del Jamb sinistro If CurrPart.TypePart.Contains("FL_L") Then x = DoubleToString(-dThicknessJamb + dOverlapLock - dLightLock, 4) ElseIf CurrPart.TypePart.Contains("FL_H") Then x = DoubleToString(-dThicknessJamb + dOverlapHinge - dLightHinge, 4) End If ' posiziono il jamb destro If CurrPart.TypePart.Contains("FR_") Then If Map.refAssemblyPageVM.CurrAssembly.DoorNumber = "1" Then If CurrPart.TypePart.Contains("FR_L") Then x = DoubleToString(dWidthDoor_0 - dOverlapLock + dLightLock, 4) ElseIf CurrPart.TypePart.Contains("FR_H") Then x = DoubleToString(dWidthDoor_0 - dOverlapHinge + dLightHinge, 4) End If Else x = DoubleToString(dWidthDoor_0 + dWidthDoor_1 - dOverlapHinge + dLightHinge + dLightLock, 4) End If End If ' posiziono il jamb sopra If CurrPart.TypePart.Contains("FT_") Then If CurrPart.Swing.Contains("L") Then x = DoubleToString(-dLightHinge, 4) Else x = DoubleToString(-dLightLock, 4) End If End If ' posiziono il jamb sotto If CurrPart.TypePart.Contains("FB_") Then If CurrPart.Swing.Contains("L") Then x = DoubleToString(-dLightHinge, 4) Else x = DoubleToString(-dLightLock, 4) End If End If Else ' posizione del Jamb sinistro If CurrPart.TypePart.Contains("FL_L") Then x = DoubleToString(-dThicknessJamb - dLightLock, 4) ElseIf CurrPart.TypePart.Contains("FL_H") Then x = DoubleToString(-dThicknessJamb - dLightHinge, 4) End If ' posiziono il jamb destro If CurrPart.TypePart.Contains("FR_") Then If Map.refAssemblyPageVM.CurrAssembly.DoorNumber = "1" Then If CurrPart.TypePart.Contains("FR_L") Then x = DoubleToString(dWidthDoor_0 + dLightLock, 4) ElseIf CurrPart.TypePart.Contains("FR_H") Then x = DoubleToString(dWidthDoor_0 + dLightHinge, 4) End If Else x = DoubleToString(dWidthDoor_0 + dWidthDoor_1 + dLightHinge + dLightLock, 4) End If End If ' posiziono il jamb sopra If CurrPart.TypePart.Contains("FT_") Then If CurrPart.Swing.Contains("L") Then x = DoubleToString(-dOverlapHinge - dLightHinge, 4) Else x = DoubleToString(-dOverlapLock - dLightLock, 4) End If End If End If Return x End Function Private Function PositionJamb_Z(CurrPart As Part) As String Dim z As String Dim dDeltaThickness As Double StringToDouble(Map.refAssemblyPageVM.CurrAssembly.DeltaThickness, dDeltaThickness) If CurrPart.Swing.Contains("HR") Then Dim dThicknessDoor As Double Dim dThicknessJamb As Double StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Thickness, dThicknessDoor) StringToDouble(Map.refAssemblyPageVM.CurrAssembly.Thickness, dThicknessJamb) z = DoubleToString(-dThicknessJamb + dThicknessDoor + dDeltaThickness, 4) Else z = DoubleToString(-dDeltaThickness, 4) End If Return z End Function #End Region ' Funzioni per il posizionamento Private Function PrintTitleDDFPart(NamePart As String) As String If NamePart.Contains("F") And NamePart.Count > 3 Then NamePart = NamePart.Remove(3) End If Dim SelectPart As String = NamePart Select Case SelectPart Case "FL_" Return "Frame Left" Case "FR_" Return "Frame Right" Case "FT_" Return "Frame Top" Case "FB_" ' eseguo un controllo per verifiacre che sia attivo If Not Map.refAssemblyPageVM.CurrAssembly.Exterior Then Map.refAssemblyPageVM.CurrAssembly.BottomJamb.SetIsActive(False) End If Return "Frame Bottom" Case Else Return "Door" & NamePart(NamePart.Count - 1) End Select End Function ' stampa le compo seguedo l'ordine della lista delle componenti del ddf Public Sub SearchCompo(DdfFileContent As List(Of String), ByRef Door As Part, bIsDDf As Boolean) Dim NewCompoNameDDF = False Dim WritingError As String = String.Empty ' cerco la prima componente da aggiungere alla lista delle componenti For Index1 = 0 To DdfFile.CompoListOrder.Count() - 1 For Index2 = 0 To Door.CompoList.Count() - 1 ' se trovo la componenete da aggiungere If DdfFile.CompoListOrder(Index1) = Door.CompoList(Index2).CompoType.DDFName Then ' se il nome della componente da aggiungere già esiste If Index2 >= 1 AndAlso String.Equals(Door.CompoList(Index2).CompoType.DDFName, Door.CompoList(Index2 - 1).CompoType.DDFName) Then NewCompoNameDDF = True Else ' aggiungo una riga vuota per separare il nome della nuova componente DdfFileContent.Add("") End If ' Carico nella lista dei componenti la lista di stringhe da stampare DdfFileContent.AddRange(GenerateCompolistDDF(Door.CompoList(Index2), WritingError, NewCompoNameDDF, bIsDDf)) End If NewCompoNameDDF = False Next Next ' finto di leggere tutte le componenti stampo il messaggio degli errori If Not String.IsNullOrWhiteSpace(WritingError) Then MessageBox.Show(WritingError, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) End If End Sub 'Genero la lista di parametri di ogni compo che vedo a video Public Function GenerateCompolistDDF(Compo As Compo, ByRef sErrorList As String, bNewCompoNameDDF As Boolean, bIsDDF As Boolean) As List(Of String) Dim CompoListDDF As New List(Of String) ' se il nome non esiste ancora nella lista lo aggiungo If Not bNewCompoNameDDF Then ' aggiungo il nome DDF della componente CompoListDDF.Add(Compo.CompoType.DDFName & ":") End If ' se esiste il template If Not String.IsNullOrWhiteSpace(Compo.TemplateDDFName) Then ' aggiungo " - nomeTemplate: TemplateSelezionato" CompoListDDF.Add(K_SCORE & Compo.TemplateDDFName & ": " & Compo.TemplateSelItem) End If ' creo l'indice dei parametri della compo Dim ParamIndex As Integer ' scrivo tutti i parametri della compo For ParamIndex = 0 To Compo.CompoParamList.Count - 1 Dim CurrCompoParam As CompoParam = Compo.CompoParamList(ParamIndex) ' controllo il tipo di parametro: ComboBox If TypeOf CurrCompoParam Is ComboBoxParam Then ' controllo che sia selezionato un elemento If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, ComboBoxParam).SelItem) Then Dim IndexDDF As Integer = 0 ' carico la lista DDF Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemListDDF ' rccolgo il valore IndexDDF come indice del valore selezionato dalla lista IndexDDF = DirectCast(CurrCompoParam, ComboBoxParam).ItemList.IndexOf(DirectCast(CurrCompoParam, ComboBoxParam).SelItem) ' restituisco il valore DDF della lista associato all'indice passato Dim SelItemDDF As String = Trim(List(IndexDDF)) CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, ComboBoxParam).DDFName & ": " & SelItemDDF) Else ' se non è selezionato nessun elemento (cosa impossibile...) If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50114), DirectCast(CurrCompoParam, ComboBoxParam).Name, CurrCompoParam.DDFName) End If ElseIf TypeOf CurrCompoParam Is TextBoxOnOffParam Then If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue) AndAlso DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive Then ' se è stata inserita un'espressine non valida restituisco un errore If DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxOnOffParam).Name, CurrCompoParam.DDFName) CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxOnOffParam).DDFName & ": ") Else If bIsDDF Then CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxOnOffParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue) Else CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxOnOffParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxOnOffParam).Value) End If End If ElseIf Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxOnOffParam).ToolTipValue) AndAlso Not DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive Then ' non restituire nessun tipo di errore End If ' TextBox ElseIf TypeOf CurrCompoParam Is TextBoxParam Then If Not String.IsNullOrWhiteSpace(DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue) Then ' se è stata inserita un'espressine non valida restituisco iun errore If DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxParam).Name, CurrCompoParam.DDFName) CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxParam).DDFName & ": ") Else If bIsDDF Then CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxParam).ToolTipValue) Else CompoListDDF.Add(K_SPACE5 & DirectCast(CurrCompoParam, TextBoxParam).DDFName & ": " & DirectCast(CurrCompoParam, TextBoxParam).Value) End If End If Else If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), DirectCast(CurrCompoParam, TextBoxParam).Name, CurrCompoParam.DDFName) End If End If Next ' inserisco qui il riferimento da stampare (il codice è scelto dalla porta) If Not IsNothing(Compo.refJambCompo) Then Compo.IdCode = CStr(IdIndex) Compo.refJambCompo.IdCode = Compo.IdCode CompoListDDF.Add(K_SPACE5 & "##IdCodeComponent : " & IdIndex) IdIndex += 1 ElseIf Not String.IsNullOrEmpty(Compo.IdCode) Then CompoListDDF.Add(K_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) IdIndex += 1 End If Return CompoListDDF End Function #End Region ' Scrittura DDF #Region "SCRITTURA ASSEMBLATO" ' serve per pulire il file temporaneo la prima volta che viene creato Friend Function WriteDDFAssembly(ByVal CurrAssembly As Assembly, sPath As String, bIsTemplate As Boolean) As Boolean ' verifico esistenza assemblato If IsNothing(CurrAssembly) Then Return False ' serve per capire se almeno una Part è stata inserita e quindi inserire il separatore Dim bSplit As Boolean = False Dim SplitPart As New List(Of String) SplitPart.Add("") SplitPart.Add("---") Dim EndAssebly As New List(Of String) EndAssebly.Add("") EndAssebly.Add("...") ' inizio stampando l'elenco delle porte Dim FirstPart As Boolean = False Select Case CurrAssembly.DoorNumber Case "1" WriteDDFPart(CurrAssembly.GetArrayPartDoor(0).Door, sPath, bIsTemplate, FirstPart) FirstPart = True File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) Case "2" If Not CurrAssembly.GetArrayPartDoor(0).Door.Swing.Contains("I") Then WriteDDFPart(CurrAssembly.GetArrayPartDoor(0).Door, sPath, bIsTemplate, FirstPart) FirstPart = True File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) WriteDDFPart(CurrAssembly.GetArrayPartDoor(1).Door, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) Else WriteDDFPart(CurrAssembly.GetArrayPartDoor(1).Door, sPath, bIsTemplate, FirstPart) FirstPart = True File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) WriteDDFPart(CurrAssembly.GetArrayPartDoor(0).Door, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) End If End Select WriteDDFPart(CurrAssembly.LeftJamb, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) WriteDDFPart(CurrAssembly.RightJamb, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) If CurrAssembly.Exterior Then WriteDDFPart(CurrAssembly.TopJamb, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) WriteDDFPart(CurrAssembly.BottomJamb, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, EndAssebly, Text.Encoding.UTF8) Else WriteDDFPart(CurrAssembly.TopJamb, sPath, bIsTemplate, FirstPart) File.AppendAllLines(sPath, EndAssebly, Text.Encoding.UTF8) End If '------------------------------------------------------------------------------------------------------------------ ' inizio ora a stampare le caratteristiche generali della finestra JambPageVM Dim dVal As Double = 0 Dim GeneralAssembly As New List(Of String) GeneralAssembly.Add("") GeneralAssembly.Add("#GENERAL ASSEMBLY") GeneralAssembly.Add("") GeneralAssembly.Add(" " & "Size : ") If StringToDouble(CurrAssembly.Thickness, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "thickness : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.K_SPACE3 & EgtMsg(50106) & "thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.Width, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "width : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.K_SPACE3 & EgtMsg(50106) & "width", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add("") GeneralAssembly.Add(" " & "Light : ") If StringToDouble(CurrAssembly.LightUp, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "up : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.K_SPACE3 & EgtMsg(50106) & "LightUp", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightLock, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "lock : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightLock", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightHinge, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "hinge : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightHinge", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightBottom, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "bottom : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightBottom", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add("") GeneralAssembly.Add(" " & "Overlap : ") If StringToDouble(CurrAssembly.ThicknessHead, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "thickness : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "ThicknessHead", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.OverlapHinge, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "hinge : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Hinge", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.OverlapLock, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "lock : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Lock", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.DeltaThickness, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "deltaT : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Delta Thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If ' i parametri associatia alla condizione di Exterior sono stampati solo se Exterior è true If CurrAssembly.Exterior Then GeneralAssembly.Add(" " & "Exterior :") If StringToDouble(CurrAssembly.OverlapTop, dVal) Then GeneralAssembly.Add(ConstCompo.K_SPACE3 & "top : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "Overlap Top", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If End If GeneralAssembly.Add("") GeneralAssembly.Add(" " & ConstCompo.K_PROFILES & ":") GeneralAssembly.Add(ConstCompo.K_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & CurrAssembly.LockEdgeType.Name) GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.LockEdgeMachining)) If Not StringToDouble(CurrAssembly.LockEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_LOCKEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.K_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & CurrAssembly.HingeEdgeType.Name) GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.HingeEdgeMachining)) If Not StringToDouble(CurrAssembly.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_HINGEDGEOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.K_SPACE3 & ConstCompo.K_TOP & ": " & CurrAssembly.TopType.Name) GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.TopMachining)) If Not StringToDouble(CurrAssembly.TopOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_TOPOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.K_SPACE3 & ConstCompo.K_BOTTOM & ": " & CurrAssembly.BottomType.Name) GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(CurrAssembly.BottomMachining)) If Not StringToDouble(CurrAssembly.BottomOverMaterial, dVal) Then MessageBox.Show(EgtMsg(50106) & K_BOTTOMOVERMATERIAL_INI, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(ConstCompo.K_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add("") If Not IsNothing(CurrAssembly.DoorNumber) Then GeneralAssembly.Add(" " & "doors : " & CurrAssembly.DoorNumber) Else MessageBox.Show(EgtMsg(50106) & "Number of Doors", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If File.AppendAllLines(sPath, GeneralAssembly, Text.Encoding.UTF8) Return True End Function #End Region End Module