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) ' se riesco a scrivere un DDF (o una parte dell'essamblato) diventa true Friend DDFIsCorrect As Boolean = False Private ParamInCompoIsCorrect As Boolean = True #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, bIsDDF As Boolean, bIsForAssembly As Boolean) DDFIsCorrect = False ' pulisco lista prima di iniziare a scrivere Dim DdfFileContent As New List(Of String) ' quindi significa che non è mai stato caricato il valore DdfFileContent.Add("#EGTDOORCREATOR") ' inserisco la configurazione usata Dim Config As String = IniFile.m_sDoorsDirPath Config = Path.GetFileName(Config) DdfFileContent.Add("#Config: " & Config) If Not IsNothing(Part.TypePart) Then DdfFileContent.Add("#" & PrintTitleDDFPart(Part.TypePart)) End If DdfFileContent.Add("") DdfFileContent.Add("produce: " & If(Part.IsActive, "true", "false")) 'Genero una lista di stringhe DdfFileContent.Add("") If IsNothing(Part.Measure) Then Part.Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit) DdfFileContent.Add(ConstCompo.S_MEASURES & ": " & Part.Measure) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then Part.Code = Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.GraphicName If Part.Code.Contains("*") Then Part.Code = Part.Code.Replace("*", "") End If DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) DdfFileContent.Add("") ElseIf Not IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then Part.Code = " " & PrintTitleDDFPart(Part.TypePart) DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") ElseIf IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then DdfFileContent.Add(ConstCompo.S_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.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": " & Part.Customer) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": ") End If If Not IsNothing(Part.Elevation) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": " & Part.Elevation) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": ") End If If Not IsNothing(Part.Project) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": " & Part.Project) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": ") End If If Not IsNothing(Part.PO) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": " & Part.PO) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": ") End If If Not IsNothing(Part.Line) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": " & Part.Line) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": ") End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add(ConstCompo.S_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("") ' posizionamento porte If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then If Not IsNothing(Part.TypePart) Then ' il posizionamento della prima porta sta nell'origine If Part.TypePart = ConstGen.PART_DO_ & "1" Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & "0") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & "0") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & "0") ElseIf Part.TypePart = ConstGen.PART_DO_ & "2" Then ' si trova traslata verso destra dello spessore DO_1 sommato a LightLock" Dim x_DO_1 As Double = 0.0 Dim dLightLock As Double 'StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Width, x_DO_1) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.Width, x_DO_1) End If StringToDouble(Map.refAssemblyPageVM.CurrAssembly.LightLock, dLightLock) Dim x As String = DoubleToString(x_DO_1 + dLightLock, 4) DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & x) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & "0") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & "0") ' Jamb Sinistro serratura ElseIf Part.TypePart.Contains(ConstGen.PART_FRAME_LEFT) 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.DDF_SPACE3 & "x: " & x) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & y) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & z) ElseIf Part.TypePart.Contains(ConstGen.PART_FRAME_RIGHT) Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains(ConstGen.PART_FRAME_TOP) Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) ElseIf Part.TypePart.Contains(ConstGen.PART_FRAME_BOTTOM) Then DdfFileContent.Add("position: ") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "x: " & PositionJamb_X(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "y: " & PositionJamb_Y(Part)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & "z: " & PositionJamb_Z(Part)) End If DdfFileContent.Add("") End If End If Dim dVal As Double = 0 DdfFileContent.Add(ConstCompo.S_SIZE & ":") If Not StringToDouble(Part.Width, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_WIDTH), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & Part.Width) End If End If If Not StringToDouble(Part.Height, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_HEIGHT), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & Part.Height) End If End If If Not StringToDouble(Part.Thickness, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_THICKNESS), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & Part.Thickness) End If End If ' aggiungo il peso della porta If Part.IsCheckedWeight = Visibility.Visible Then If Not StringToDouble(Part.Weight, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), S_WEIGHT), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else DdfFileContent.Add("") If bIsDDF Then DdfFileContent.Add(ConstCompo.S_WEIGHT & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.S_WEIGHT & ": " & Part.Weight) End If End If End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add("" & ConstCompo.S_SWING & ": " & Part.Swing) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- ' aggiungo il secure nullo al DDF If Part.TypePart.Contains(ConstGen.PART_DO_) Then DdfFileContent.Add("" & ConstCompo.S_SECURE & ": " & SetSecure(Part.SwingAlias.Name, Part.DispositionItem.Name, Part.Secure)) ' aggiungo una riga vuota per separare la lista successiva Else DdfFileContent.Add("" & ConstCompo.S_SECURE & ": " & ConstGen.SWING_DOWN) End If DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- ' aggiungo le Properties If Part.PropertiesIsVisible = Visibility.Visible Then Dim sProperties As String = String.Empty Dim ItemIndex As Integer For ItemIndex = 0 To Part.PropertiesList.Count - 1 If Part.PropertiesList(ItemIndex).IsChecked Then sProperties &= Part.PropertiesList(ItemIndex).Name & ", " End If Next If Not String.IsNullOrEmpty(sProperties) Then sProperties = sProperties.Remove(sProperties.LastIndexOf(","c)) DdfFileContent.Add("" & ConstCompo.S_PROPERTIES & ": " & sProperties) DdfFileContent.Add("") End If End If '---------------------------------------------------------------------------------------------------------------------------------------------------- DdfFileContent.Add("" & ConstCompo.S_PROFILES & ":") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & SetBevel(Part.TypePart, Part.LockEdgeType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.LockEdgeMachining)) If Not StringToDouble(Part.LockEdgeOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_LOCKEDGEOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.LockEdgeOverMaterial) End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & SetBevel(Part.TypePart, Part.HingeEdgeType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.HingeEdgeMachining)) If Not StringToDouble(Part.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_HINGEDGEOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.HingeEdgeOverMaterial) End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_TOP & ": " & SetBevel(Part.TypePart, Part.TopType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.TopMachining)) If Not StringToDouble(Part.TopOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_TOPOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.TopOverMaterial) End If End If If Part.TopArcIsChecked And (Not IsNothing(Part.Radius) AndAlso Not IsNothing(Part.Posx)) Then If Not StringToDouble(Part.Radius, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_RADIUS), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_RADIUS & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_RADIUS & ": " & Part.Radius) End If End If If Not StringToDouble(Part.Posx, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_POSX), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_POSX & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_POSX & ": " & Part.Posx) End If End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_BOTTOM & ": " & SetBevel(Part.TypePart, Part.BottomType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.BottomMachining)) If Not StringToDouble(Part.BottomOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_BOTTOMOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else If bIsDDF Then DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) Else DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.BottomOverMaterial) End If End If ' Riordino e stampo le compo SearchCompo(DdfFileContent, Part, bIsDDF) If Not Directory.Exists(Path.GetDirectoryName(sPath)) Then Directory.CreateDirectory(Path.GetDirectoryName(sPath)) End If DdfFileContent.Add(" ") DdfFileContent.Add("# End Part") ' se sono arrivato fin qui significa che tutto è andato a buon fine (posso quindisalvare il file corrente) DDFIsCorrect = ParamInCompoIsCorrect '----------------------------------------------------------------------------------------------------------------------------------- '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 ' la funzione è quasi identica alla precedente per piccole differenze (evito di richiamare dei riferimenti all'assemblato) Friend Sub WriteDDFPartForTestHardware(Part As Part, sPath As String, bIsDDF As Boolean, bIsForAssembly As Boolean) DDFIsCorrect = False ' pulisco lista prima di iniziare a scrivere Dim DdfFileContent As New List(Of String) ' quindi significa che non è mai stato caricato il valore DdfFileContent.Add("#EGTDOORCREATOR") If Not IsNothing(Part.TypePart) Then DdfFileContent.Add("#" & PrintTitleDDFPart(Part.TypePart)) End If DdfFileContent.Add("") DdfFileContent.Add("produce: " & If(Part.IsActive, "true", "false")) 'Genero una lista di stringhe DdfFileContent.Add("") If IsNothing(Part.Measure) Then Part.Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit) DdfFileContent.Add(ConstCompo.S_MEASURES & ": " & Part.Measure) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") If OptionModule.m_ConfigurationSoftware = ConfigType.Door Then Part.Code = "TestDoorHardware" DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) DdfFileContent.Add("") ElseIf Not IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then Part.Code = " " & PrintTitleDDFPart(Part.TypePart) DdfFileContent.Add(ConstCompo.S_CODE & ": " & Part.Code) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") ElseIf IsNothing(Part.TypePart) And OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then DdfFileContent.Add(ConstCompo.S_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.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": " & Part.Customer) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_CUSTOMER & ": ") End If If Not IsNothing(Part.Elevation) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": " & Part.Elevation) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_ELEVATION & ": ") End If If Not IsNothing(Part.Project) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": " & Part.Project) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PROJECT & ": ") End If If Not IsNothing(Part.PO) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": " & Part.PO) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_PO & ": ") End If If Not IsNothing(Part.Line) Then DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": " & Part.Line) Else DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LINE & ": ") End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add(ConstCompo.S_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("") Dim dVal As Double = 0 Dim sVal As String = String.Empty DdfFileContent.Add(ConstCompo.S_SIZE & ":") If Not StringToDouble(Part.Width, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_WIDTH), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.Width ConvertCurrentUnitMeasure(sVal) 'Part.SetWidth(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & Part.Width) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_WIDTH & ": " & sVal) End If End If If Not StringToDouble(Part.Height, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_HEIGHT), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.Height ConvertCurrentUnitMeasure(sVal) 'Part.SetHeight(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & Part.Height) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HEIGHT & ": " & sVal) End If End If If Not StringToDouble(Part.Thickness, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_THICKNESS), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.Thickness ConvertCurrentUnitMeasure(sVal) 'Part.SetThickness(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & Part.Thickness) DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_THICKNESS & ": " & sVal) End If End If ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") DdfFileContent.Add("" & ConstCompo.S_SWING & ": " & Part.Swing) ' aggiungo una riga vuota per separare la lista successiva DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- ' aggiungo il secure nullo al DDF If Part.TypePart.Contains(ConstGen.PART_DO_) Then DdfFileContent.Add("" & ConstCompo.S_SECURE & ": " & SetSecure(Part.SwingAlias.Name, Part.DispositionItem.Name, Part.Secure)) ' aggiungo una riga vuota per separare la lista successiva Else DdfFileContent.Add("" & ConstCompo.S_SECURE & ": " & ConstGen.SWING_DOWN) End If DdfFileContent.Add("") '---------------------------------------------------------------------------------------------------------------------------------------------------- DdfFileContent.Add("" & ConstCompo.S_PROFILES & ":") DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_LOCKEDGE & ": " & SetBevel(Part.TypePart, Part.LockEdgeType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.LockEdgeMachining)) If Not StringToDouble(Part.LockEdgeOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_LOCKEDGEOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.LockEdgeOverMaterial ConvertCurrentUnitMeasure(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.LockEdgeOverMaterial) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_HINGEEDGE & ": " & SetBevel(Part.TypePart, Part.HingeEdgeType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.HingeEdgeMachining)) If Not StringToDouble(Part.HingeEdgeOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_HINGEDGEOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.HingeEdgeOverMaterial ConvertCurrentUnitMeasure(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.HingeEdgeOverMaterial) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_TOP & ": " & SetBevel(Part.TypePart, Part.TopType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.TopMachining)) If Not StringToDouble(Part.TopOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_TOPOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.TopOverMaterial ConvertCurrentUnitMeasure(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.TopOverMaterial) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) End If End If DdfFileContent.Add(ConstCompo.DDF_SPACE3 & ConstCompo.K_BOTTOM & ": " & SetBevel(Part.TypePart, Part.BottomType.Name, Part.DispositionItem.Name, Part.SwingAlias.Name)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_MACHINING & ": " & ConvertBooleanToOnOff(Part.BottomMachining)) If Not StringToDouble(Part.BottomOverMaterial, dVal) Then MessageBox.Show(String.Format(EgtMsg(50141), K_BOTTOMOVERMATERIAL_INI), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return Else sVal = Part.BottomOverMaterial ConvertCurrentUnitMeasure(sVal) If bIsDDF Then 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) Else 'DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & Part.BottomOverMaterial) DdfFileContent.Add(ConstCompo.DDF_SPACE5 & ConstCompo.K_OVERMATERIAL & ": " & sVal) End If End If ' Riordino e stampo le compo SearchCompo(DdfFileContent, Part, bIsDDF) If Not Directory.Exists(Path.GetDirectoryName(sPath)) Then Directory.CreateDirectory(Path.GetDirectoryName(sPath)) End If DdfFileContent.Add(" ") DdfFileContent.Add("# End Part") ' se sono arrivato fin qui significa che tutto è andato a buon fine (posso quindisalvare il file corrente) DDFIsCorrect = ParamInCompoIsCorrect '----------------------------------------------------------------------------------------------------------------------------------- '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 Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.Height, dHeightDoor) Else dHeightDoor = 0 End If If CurrPart.TypePart.Contains(ConstGen.EXTERIOR) Then If CurrPart.TypePart.Contains(ConstGen.PART_FRAME_TOP) Then y = DoubleToString(dHeightDoor - dOverlapTop + dLightUp, 4) Else y = DoubleToString(-dLightBottom - dThicknessJamb, 4) End If Else If CurrPart.TypePart.Contains(ConstGen.PART_FRAME_TOP) 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) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.Width, dWidthDoor_0) Else dWidthDoor_0 = 0 End If ' StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.Width, dWidthDoor_1) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_2")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_2").Door.Width, dWidthDoor_1) Else dWidthDoor_1 = 0 End If If CurrPart.TypePart.Contains(ConstGen.EXTERIOR) 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(ConstGen.PART_FRAME_RIGHT) 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(ConstGen.PART_FRAME_TOP) Then If CurrPart.SwingAlias.Name.Contains(ConstGen.LOCK) Then x = DoubleToString(-dLightHinge, 4) Else x = DoubleToString(-dLightLock, 4) End If End If ' posiziono il jamb sotto If CurrPart.TypePart.Contains(ConstGen.PART_FRAME_BOTTOM) Then If CurrPart.SwingAlias.Name.Contains(ConstGen.LOCK) 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(ConstGen.PART_FRAME_RIGHT) 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(ConstGen.PART_FRAME_TOP) Then If CurrPart.SwingAlias.Name.Contains(ConstGen.LOCK) 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.SwingAlias.Name.Contains(ConstGen.HAND_REVERSE) Then Dim dThicknessDoor As Double Dim dThicknessJamb As Double ' StringToDouble(Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.Thickness, dThicknessDoor) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.Thickness, dThicknessDoor) Else dThicknessDoor = 0 End If 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(ConstGen.PART_FRAME) And NamePart.Count > 3 Then NamePart = NamePart.Remove(3) End If Dim SelectPart As String = NamePart Select Case SelectPart Case ConstGen.PART_FRAME_LEFT Return "Frame Left" Case ConstGen.PART_FRAME_RIGHT Return "Frame Right" Case ConstGen.PART_FRAME_TOP Return "Frame Top" Case ConstGen.PART_FRAME_BOTTOM ' eseguo un controllo per verifiacre che sia attivo If Not Map.refAssemblyPageVM.CurrAssembly.Exterior Then Dim FB As PartDoor = Map.refAssemblyManagerVM.ReserchPartDoor("FB_") If Not IsNothing(FB) Then FB.Door.SetIsActive(False) Else FB.Door.SetIsActive(True) End If 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) ParamInCompoIsCorrect = True Dim NewCompoNameDDF = False Dim WritingError As String = String.Empty Dim TempList As New ObservableCollection(Of Compo) DdfFileContent.Add("") '------------------------------------------------------------------------------------------------------------------------------------------ '' ' 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 '------------------------------------------------------------------------------------------------------------------------------------------ ' 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 TempList.Add(Door.CompoList(Index2)) End If Next Next TidyCompo(DdfFileContent, TempList, bIsDDF) ' 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 Public Function TidyCompo(DdfFileContent As List(Of String), Door As ObservableCollection(Of Compo), bIsDDF As Boolean) As Boolean Dim TempList As New ObservableCollection(Of Compo) If Door.Count = 0 Then Return True ' se esiste un solo elemento lo carico If Door.Count = 1 Then TempList.Add(Door(0)) : AscendingOrder(TempList, DdfFileContent, bIsDDF) : Return True For Index1 As Integer = 0 To Door.Count - 2 TempList = New ObservableCollection(Of Compo) TempList.Add(Door(Index1)) For Index2 As Integer = Index1 + 1 To Door.Count - 1 If Door(Index1).CompoType.DDFName = Door(Index2).CompoType.DDFName Then TempList.Add(Door(Index2)) End If Next AscendingOrder(TempList, DdfFileContent, bIsDDF) Index1 += TempList.Count - 1 Next TempList = New ObservableCollection(Of Compo) ' controllo che l'ultimo elemento non sia già stato caricato If Door(Door.Count - 1).CompoType.DDFName <> Door(Door.Count - 2).CompoType.DDFName Then TempList.Add(Door(Door.Count - 1)) AscendingOrder(TempList, DdfFileContent, bIsDDF) End If Return True End Function Private Function AscendingOrder(List As ObservableCollection(Of Compo), DdfFileContent As List(Of String), bIsDDF As Boolean) As Boolean Dim NewCompoNameDDF = False Dim tidyParamIndex1 As Integer = -1 Dim tidyParamIndex2 As Integer = -1 Dim WritingError As String = String.Empty If List.Count >= 2 Then For IndexList1 As Integer = 0 To List.Count - 2 For IndexList2 As Integer = IndexList1 + 1 To List.Count - 1 ' se hanno lo stesso parametrro di posizionamento allora riordino If Not String.IsNullOrEmpty(List(IndexList1).TidyParam) And Not String.IsNullOrEmpty(List(IndexList2).TidyParam) Then For IndexParam As Integer = 0 To List(0).CompoParamList.Count - 1 If List(IndexList1).CompoParamList(IndexParam).DDFName = List(IndexList1).TidyParam Then tidyParamIndex1 = IndexParam Exit For Next For IndexParam As Integer = 0 To List(0).CompoParamList.Count - 1 If List(IndexList2).CompoParamList(IndexParam).DDFName = List(IndexList2).TidyParam Then tidyParamIndex2 = IndexParam Exit For Next ' se trovo il nome del parametro nell'elenco dei parametri If Not tidyParamIndex1 = -1 And Not tidyParamIndex1 = -1 Then If TypeOf List(IndexList1).CompoParamList(tidyParamIndex1) Is TextBoxParam And TypeOf List(IndexList2).CompoParamList(tidyParamIndex2) Is TextBoxParam Then Dim Item1 As String = DirectCast(List(IndexList1).CompoParamList(tidyParamIndex1), TextBoxParam).Value Dim Item2 As String = DirectCast(List(IndexList2).CompoParamList(tidyParamIndex2), TextBoxParam).Value Dim dItem1 As Double Dim dItem2 As Double If StringToDouble(Item1, dItem1) And StringToDouble(Item2, dItem2) AndAlso dItem1 > dItem2 Then Dim TempCompo As Compo = List(IndexList1) List(IndexList1) = List(IndexList2) List(IndexList2) = TempCompo End If End If End If End If Next Next End If ' stampa lista DdfFileContent.AddRange(GenerateCompolistDDF(List(0), WritingError, False, bIsDDF)) For IndexItem As Integer = 1 To List.Count - 1 DdfFileContent.AddRange(GenerateCompolistDDF(List(IndexItem), WritingError, True, bIsDDF)) Next DdfFileContent.Add("") Return True End Function '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(DDF_HYPHEN & 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) ' ComboBox If TypeOf CurrCompoParam Is ComboBoxOnOffParam Then Dim cbParam As ComboBoxOnOffParam = DirectCast(CurrCompoParam, ComboBoxOnOffParam) If cbParam.IsActive Then ' recupero l'indice dell'elemento selezionato Dim IndexDDF As Integer = -1 If Not String.IsNullOrWhiteSpace(cbParam.SelItem) Then ' raccolgo il valore IndexDDF come indice del valore selezionato dalla lista IndexDDF = cbParam.ItemList.IndexOf(cbParam.SelItem) End If ' controllo che sia selezionato un elemento If IndexDDF >= 0 AndAlso IndexDDF < cbParam.ItemListDDF.Count() Then ' restituisco il valore DDF della lista associato all'indice passato Dim SelItemDDF As String = Trim(cbParam.ItemListDDF(IndexDDF)) CompoListDDF.Add(DDF_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) Else ' se non è selezionato nessun elemento (cosa impossibile...) If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50114), cbParam.Name, CurrCompoParam.DDFName) ParamInCompoIsCorrect = False End If End If ElseIf TypeOf CurrCompoParam Is ComboBoxParam Then Dim cbParam As ComboBoxParam = DirectCast(CurrCompoParam, ComboBoxParam) ' recupero l'indice dell'elemento selezionato Dim IndexDDF As Integer = -1 If Not String.IsNullOrWhiteSpace(cbParam.SelItem) Then ' raccolgo il valore IndexDDF come indice del valore selezionato dalla lista IndexDDF = cbParam.ItemList.IndexOf(cbParam.SelItem) End If ' controllo che sia selezionato un elemento If IndexDDF >= 0 AndAlso IndexDDF < cbParam.ItemListDDF.Count() Then ' restituisco il valore DDF della lista associato all'indice passato Dim SelItemDDF As String = Trim(cbParam.ItemListDDF(IndexDDF)) CompoListDDF.Add(DDF_SPACE5 & cbParam.DDFName & ": " & SelItemDDF) Else ' se non è selezionato nessun elemento (cosa impossibile...) If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50114), cbParam.Name, CurrCompoParam.DDFName) ParamInCompoIsCorrect = False End If ' TextBox Opzionale ElseIf TypeOf CurrCompoParam Is TextBoxOnOffParam Then Dim tboParam As TextBoxOnOffParam = DirectCast(CurrCompoParam, TextBoxOnOffParam) If Not String.IsNullOrWhiteSpace(tboParam.ToolTipValue) AndAlso tboParam.IsActive Then ' se è stata inserita un'espressione non valida restituisco un errore If tboParam.ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), tboParam.Name, CurrCompoParam.DDFName) CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": ") ParamInCompoIsCorrect = False Else If bIsDDF Then CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": " & tboParam.ToolTipValue) Else CompoListDDF.Add(DDF_SPACE5 & tboParam.DDFName & ": " & tboParam.Value) End If End If ElseIf Not String.IsNullOrWhiteSpace(tboParam.ToolTipValue) AndAlso Not tboParam.IsActive Then ' non restituire nessun tipo di errore End If ' TextBox ElseIf TypeOf CurrCompoParam Is TextBoxParam Then Dim tbParam As TextBoxParam = DirectCast(CurrCompoParam, TextBoxParam) If Not String.IsNullOrWhiteSpace(tbParam.ToolTipValue) Then ' se è stata inserita un'espressine non valida restituisco un errore If tbParam.ToolTipValue = EgtMsg(50143) Then If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), tbParam.Name, CurrCompoParam.DDFName) CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": ") ParamInCompoIsCorrect = False Else If bIsDDF Then CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": " & tbParam.ToolTipValue) Else CompoListDDF.Add(DDF_SPACE5 & tbParam.DDFName & ": " & tbParam.Value) End If End If Else If Not String.IsNullOrEmpty(sErrorList) Then sErrorList &= Environment.NewLine sErrorList &= String.Format(EgtMsg(50141), tbParam.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 ' se il riferiento è stato stampato prima che si passi da questa pagina allora non posso modificare il valore del riferiento If Not String.IsNullOrEmpty(Compo.IdCode) AndAlso Compo.refJambCompo.IdCode = Compo.IdCode Then CompoListDDF.Add(DDF_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) Else Compo.IdCode = CStr(IdIndex) Compo.refJambCompo.IdCode = Compo.IdCode CompoListDDF.Add(DDF_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) End If IdIndex += 1 ElseIf Not String.IsNullOrEmpty(Compo.IdCode) Then CompoListDDF.Add(DDF_SPACE5 & "##IdCodeComponent : " & Compo.IdCode) IdIndex += 1 End If Return CompoListDDF End Function ' calcola il secure da salvare e il tipo di bevel Public Function SetSecure(sSwing As String, DispositionItem As String, DoorSecure As String) As String Dim sSecure As String If DispositionItem = ConstGen.BEVEL_UP Then If sSwing.Contains(ConstGen.HAND_REVERSE) Then sSecure = ConstGen.SWING_UP Else sSecure = ConstGen.SWING_DOWN End If ElseIf DispositionItem = ConstGen.BEVEL_DOWN Then If sSwing.Contains(ConstGen.HAND_REVERSE) Then sSecure = ConstGen.SWING_DOWN Else sSecure = ConstGen.SWING_UP End If Else If DoorSecure <> "0" Then sSecure = DoorSecure End If sSecure = ConstGen.SWING_DOWN End If Return sSecure End Function ' calcola il bevel da stamapare nel ddf Public Function SetBevel(sTypePart As String, sCurrBevel As String, DispositionItem As String, sSwing As String) As String If sTypePart.Contains(ConstGen.PART_DO_) Then If sCurrBevel = ConstGen.BEVEL_GRAPHIC And DispositionItem = ConstGen.BEVEL_DOWN Then Return ConstGen.BEVEL_DOWN ElseIf sCurrBevel = ConstGen.BEVEL_GRAPHIC And DispositionItem = ConstGen.BEVEL_UP Then Return ConstGen.BEVEL_UP ElseIf sCurrBevel = ConstGen.BEVEL_GRAPHIC And DispositionItem <> ConstGen.BEVEL_UP And DispositionItem <> ConstGen.BEVEL_DOWN Then If sSwing.Contains(ConstGen.HAND_REVERSE) Then Return ConstGen.BEVEL_DOWN Else Return ConstGen.BEVEL_UP End If Else Return sCurrBevel End If Else If sCurrBevel = ConstGen.BEVEL_DOWN OrElse sCurrBevel = ConstGen.BEVEL_GRAPHIC OrElse sCurrBevel = ConstGen.BEVEL_UP Then Return ConstGen.BEVEL_DOWN Else Return sCurrBevel End If End If 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, bIsDDF As Boolean) As Boolean ' verifico esistenza assemblato If IsNothing(CurrAssembly) Then Return False ' serve per capire se almeno un Part è stato inserito e quindi inserire il separatore Dim bSplit As Boolean = False Dim SplitPart As New List(Of String) SplitPart.Add("") SplitPart.Add(DDF_PARTIALEND) Dim EndAssebly As New List(Of String) EndAssebly.Add("") EndAssebly.Add(DDF_END) Dim FirstPart As Boolean = False Dim GeneralAssembly As New List(Of String) If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then ' scrive le informazioni relative all'assembalto WriteGeneralAssembly(GeneralAssembly, CurrAssembly) File.WriteAllLines(sPath, GeneralAssembly, Text.Encoding.UTF8) FirstPart = True End If If CurrAssembly.ListPartDoor.Count > 1 Then For IndexPartDoor As Integer = 0 To CurrAssembly.ListPartDoor.Count - 2 WriteDDFPart(CurrAssembly.ListPartDoor(IndexPartDoor).Door, sPath, bIsDDF, FirstPart) File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) Next End If WriteDDFPart(CurrAssembly.ListPartDoor(CurrAssembly.ListPartDoor.Count - 1).Door, sPath, bIsDDF, FirstPart) File.AppendAllLines(sPath, EndAssebly, Text.Encoding.UTF8) '' inizio stampando l'elenco delle porte 'Select Case CurrAssembly.DoorNumber ' Case "1" ' WriteDDFPart(CurrAssembly.GetArrayPartDoor(0).Door, sPath, bIsDDF, 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, bIsDDF, FirstPart) ' FirstPart = True ' File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) ' WriteDDFPart(CurrAssembly.GetArrayPartDoor(1).Door, sPath, bIsDDF, FirstPart) ' File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) ' 'Else ' ' WriteDDFPart(CurrAssembly.GetArrayPartDoor(1).Door, sPath, bIsDDF, FirstPart) ' ' FirstPart = True ' ' File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) ' ' WriteDDFPart(CurrAssembly.GetArrayPartDoor(0).Door, sPath, bIsDDF, FirstPart) ' ' File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) ' 'End If 'End Select 'WriteDDFPart(CurrAssembly.LeftJamb, sPath, bIsDDF, FirstPart) 'File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) 'WriteDDFPart(CurrAssembly.RightJamb, sPath, bIsDDF, FirstPart) 'File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) '' il sill è stampato solo se è nella selezione 'If CurrAssembly.Exterior Then ' WriteDDFPart(CurrAssembly.TopJamb, sPath, bIsDDF, FirstPart) ' File.AppendAllLines(sPath, SplitPart, Text.Encoding.UTF8) ' WriteDDFPart(CurrAssembly.BottomJamb, sPath, bIsDDF, FirstPart) ' File.AppendAllLines(sPath, EndAssebly, Text.Encoding.UTF8) 'Else ' WriteDDFPart(CurrAssembly.TopJamb, sPath, bIsDDF, FirstPart) ' File.AppendAllLines(sPath, EndAssebly, Text.Encoding.UTF8) 'End If Return True End Function Public Function WriteGeneralAssembly(ByRef GeneralAssembly As List(Of String), CurrAssembly As Assembly) As Boolean Dim dVal As Double = 0 GeneralAssembly.Add("#EGTDOORCREATOR") GeneralAssembly.Add("#GENERAL ASSEMBLY") GeneralAssembly.Add("#") GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Size : ") If StringToDouble(CurrAssembly.Thickness, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "thickness : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "thickness", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.Width, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "width : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "width", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(DDF_METADATA) GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Light : ") If StringToDouble(CurrAssembly.LightUp, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "up : " & DoubleToString(dVal, 5)) Else MessageBox.Show(ConstCompo.DDF_METADATA & EgtMsg(50106) & "LightUp", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If If StringToDouble(CurrAssembly.LightLock, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "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.DDF_METADATA & "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.DDF_METADATA & "bottom : " & DoubleToString(dVal, 5)) Else MessageBox.Show(EgtMsg(50106) & "LightBottom", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(ConstCompo.DDF_METADATA) GeneralAssembly.Add(ConstCompo.DDF_METADATA & "Overlap : ") If StringToDouble(CurrAssembly.ThicknessHead, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "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.DDF_METADATA & "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.DDF_METADATA & "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.DDF_METADATA & "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(ConstCompo.DDF_METADATA & "Exterior :") If StringToDouble(CurrAssembly.OverlapTop, dVal) Then GeneralAssembly.Add(ConstCompo.DDF_METADATA & "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(ConstCompo.DDF_METADATA) GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.S_PROFILES & ":") GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_LOCKEDGE & ": " & CurrAssembly.LockEdgeType.Name) GeneralAssembly.Add(ConstCompo.DDF_METADATA & 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.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_HINGEEDGE & ": " & CurrAssembly.HingeEdgeType.Name) GeneralAssembly.Add(ConstCompo.DDF_METADATA & 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.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_TOP & ": " & CurrAssembly.TopType.Name) GeneralAssembly.Add(ConstCompo.DDF_METADATA & 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.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(ConstCompo.DDF_METADATA & ConstCompo.K_BOTTOM & ": " & CurrAssembly.BottomType.Name) GeneralAssembly.Add(ConstCompo.DDF_METADATA & 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.DDF_METADATA & ConstCompo.K_OVERMATERIAL & ": " & DoubleToString(dVal, 5)) GeneralAssembly.Add(DDF_METADATA) If Not IsNothing(CurrAssembly.DoorNumber) Then GeneralAssembly.Add(DDF_METADATA & "doors : " & CurrAssembly.DoorNumber) Else MessageBox.Show(EgtMsg(50106) & "Number of Doors", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If GeneralAssembly.Add(" ") 'File.AppendAllLines(sPath, GeneralAssembly, Text.Encoding.UTF8) Return True End Function #End Region End Module