Files
EgtDOORCreator/DoorParameters/Part.vb
T
Dario Sassi 3c2b662cda EgtDOORCreator 1.9a4 :
- resa più flessibile lettura pressure (per compatibilità con vecchie porte).
2018-01-31 11:12:25 +00:00

2142 lines
96 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Imports System.Text.RegularExpressions
Public Class Part
Implements INotifyPropertyChanged
' questa variabile è stata definita condovisa per permettere di essere inizializzata alla prima lettura del DDF
Public Shared FirstReadingEdge As Boolean = False
#Region "GENERAL"
#Region "Nuove proprietà delle parti"
' serve ad attribuire il nome all'oggetto che stiamo per creare (Il vecchio frame ora indicato nel DDF come piece)
Private m_TypePart As String
Public Property TypePart As String
Get
Return m_TypePart
End Get
Set(value As String)
m_TypePart = value
NotifyPropertyChanged("TypePart")
End Set
End Property
' per sapere se il check è attivo
Private m_IsActive As Boolean
Public Property IsActive As Boolean
Get
Return m_IsActive
End Get
Set(value As Boolean)
m_IsActive = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Public Sub SetIsActive(bIsActive As Boolean)
m_IsActive = bIsActive
NotifyPropertyChanged("IsActive")
End Sub
' lista delle disposizioni da mostrare a video
Friend Shared m_DispositionList As New ObservableCollection(Of EdgeType)
Public ReadOnly Property DispositionList As ObservableCollection(Of EdgeType)
Get
Return m_DispositionList
End Get
End Property
' elemento selezionato dalla lista delle disposizinioni
Private m_DispositionItem As EdgeType
Public Property DispositionItem As EdgeType
Get
Return m_DispositionItem
End Get
Set(value As EdgeType)
m_DispositionItem = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
OptionModule.m_Disposition = m_DispositionItem
NotifyPropertyChanged("DispositionItem")
End Set
End Property
Public Sub SetDispositionItem(ObjDisposition As EdgeType)
If IsNothing(m_DispositionItem) Then
m_DispositionItem = ObjDisposition
End If
NotifyPropertyChanged("DispositionItem")
End Sub
#End Region ' Nuove proprietà delle parti
Private m_SwingTypeList As List(Of String) = New List(Of String)
Public Property SwingTypeList As List(Of String)
Get
Return m_SwingTypeList
End Get
Set(value As List(Of String))
m_SwingTypeList = value
NotifyPropertyChanged("SwingTypeList")
End Set
End Property
Private m_Measure As String
Public Property Measure As String
Get
Return m_Measure
End Get
Set(value As String)
m_Measure = value
End Set
End Property
Private m_Code As String
Public Property Code As String
Get
Return m_Code
End Get
Set(value As String)
m_Code = value
End Set
End Property
Private m_Customer As String
Public Property Customer As String
Get
Return m_Customer
End Get
Set(value As String)
m_Customer = value
End Set
End Property
Private m_Elevation As String
Public Property Elevation As String
Get
Return m_Elevation
End Get
Set(value As String)
m_Elevation = value
End Set
End Property
Private m_Project As String
Public Property Project As String
Get
Return m_Project
End Get
Set(value As String)
m_Project = value
End Set
End Property
Private m_PO As String
Public Property PO As String
Get
Return m_PO
End Get
Set(value As String)
m_PO = value
End Set
End Property
Private m_Line As String
Public Property Line As String
Get
Return m_Line
End Get
Set(value As String)
m_Line = value
End Set
End Property
Private m_Date As String
Public Property DatePar As String
Get
Return m_Date
End Get
Set(value As String)
m_Date = value
End Set
End Property
Private m_Secure As String
Public Property Secure As String
Get
Return m_Secure
End Get
Set(value As String)
m_Secure = value
End Set
End Property
#Region "Size"
Public ReadOnly Property ToolTipEvaluatedHeight As String
Get
Dim dVal As Double
If StringToDouble(m_Height, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedWidth As String
Get
Dim dVal As Double
If StringToDouble(m_Width, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedThickness As String
Get
Dim dVal As Double
If StringToDouble(m_Thickness, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedWeight As String
Get
Dim dVal As Double
If StringToDouble(m_Weight, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Private m_Height As String
Public Property Height As String
Get
Return m_Height
End Get
Set(value As String)
'Dim dVal As Double
'If StringToDouble(value, dVal) Then
' m_Height = DoubleToString(dVal, 4)
'Else
' Dim x As String = EgtMsg(50143)
'End If
'If StringToDouble(value, dVal) Then
' m_Height = value
'Else
' MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
'End If
m_Height = value
Dim dHeight As Double
If StringToDouble(value, dHeight) Then
EgtLuaSetGlobNumVar("H", dHeight)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
' ricalcola la dimensione altezza dei Jamb FL e FR
Map.refAssemblyPageVM.CurrAssembly.HeightJamb(m_Height)
Map.refAssemblyPageVM.CurrAssembly.HeightDoor(m_Height)
Map.refAssemblyPageVM.CurrAssembly.UpDateAllCompo()
Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly()
'SetVarSize()
UpdateToolTip()
NotifyPropertyChanged("Height")
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Public Sub SetHeight(sHeight As String)
m_Height = sHeight
NotifyPropertyChanged("Height")
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Sub
Private m_Width As String = String.Empty
Public Property Width As String
Get
Return m_Width
End Get
Set(value As String)
'Dim dVal As Double
'If StringToDouble(value, dVal) Then
' m_Width = value
'Else
' MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
'End If
m_Width = value
Dim dWidth As Double
If StringToDouble(value, dWidth) Then
EgtLuaSetGlobNumVar("W", dWidth)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
' ricalcola la dimensione larghezza dei Jamb FT e FB
Map.refAssemblyPageVM.CurrAssembly.SetTopWidth()
Map.refAssemblyPageVM.CurrAssembly.UpDateAllCompo()
Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly()
'SetVarSize()
UpdateToolTip()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Public Sub SetWidth(sWidth As String)
m_Width = sWidth
NotifyPropertyChanged("Width")
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Sub
Private m_Thickness As String
Public Property Thickness As String
Get
Return m_Thickness
End Get
Set(value As String)
'Dim dVal As Double
'If StringToDouble(value, dVal) Then
' m_Thickness = value
'Else
' MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
'End If
m_Thickness = value
Dim dThickness As Double
If StringToDouble(value, dThickness) Then
EgtLuaSetGlobNumVar("T", dThickness)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly()
'SetVarSize()
UpdateToolTip()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Public Sub SetThickness(sThickness As String)
m_Thickness = sThickness
NotifyPropertyChanged("Thickness")
End Sub
Private m_Weight As String
Public Property Weight As String
Get
If String.IsNullOrEmpty(m_Weight) Then
m_Weight = OptionModule.m_Weight
End If
Return m_Weight
End Get
Set(value As String)
m_Weight = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
NotifyPropertyChanged("ToolTipEvaluatedWeight")
End Set
End Property
Private Shared m_IsCheckedWeight As Visibility
Public Shared Property IsCheckedWeight As Visibility
Get
Return m_IsCheckedWeight
End Get
Set(value As Visibility)
m_IsCheckedWeight = value
End Set
End Property
Public Property VisibilityWeight As Visibility
Get
Return m_IsCheckedWeight
End Get
Set(value As Visibility)
If m_IsCheckedWeight <> value Then
m_IsCheckedWeight = value
End If
NotifyPropertyChanged("VisibilityWeight")
End Set
End Property
Private m_Swing As String = Nothing
Public Property Swing As String
Get
Return m_Swing
End Get
Set(value As String)
m_Swing = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Map.refAssemblyPageVM.CurrAssembly.UpdateSwing(m_Swing)
Map.refAssemblyPageVM.CurrAssembly.TopRabbetJamb()
' aggiorno la grafica
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetSwing(sSwing As String)
m_Swing = sSwing
NotifyPropertyChanged("Swing")
End Sub
Private m_NewPart As Boolean = True
Public Property NewPart As Boolean
Get
Return m_NewPart
End Get
Set(value As Boolean)
m_NewPart = value
End Set
End Property
#End Region
#Region "TypeEdge"
Friend Shared m_LockEdgeTypeList As New ObservableCollection(Of EdgeType)
Friend Shared m_HingeEdgeTypeList As New ObservableCollection(Of EdgeType)
Friend Shared m_BottomEdgeTypeList As New ObservableCollection(Of EdgeType)
Friend Shared m_TopEdgeTypeList As New ObservableCollection(Of EdgeType)
'Friend Shared m_EdgeTypeList As New ObservableCollection(Of EdgeType)
'Public Property EdgeTypeList As ObservableCollection(Of EdgeType)
' Get
' ' restituisco il valore della lista che è stato creato all'avvio
' If m_TypePart.Contains("DO_") Then
' Return m_EdgeTypeList
' Else ' se stiamo leggendo un frame carico la lista dei bevel dei frame
' Return Assembly.m_FrameEdgeTypeList
' End If
' End Get
' Set(value As ObservableCollection(Of EdgeType))
' m_EdgeTypeList = value
' Map.refAssemblyPageVM.CurrAssembly.NotifyPropertyChanged("EdgeTypeList")
' Map.refAssemblyPageVM.CurrAssembly.NotifyPropertyChanged("TopEdgeTypeList")
' Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
' End Set
'End Property
Public ReadOnly Property LockEdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
If m_TypePart.Contains("DO_") Then
Return m_LockEdgeTypeList
Else ' se stiamo leggendo un frame carico la lista dei bevel dei frame
Return Assembly.m_FrameEdgeTypeList
End If
End Get
End Property
Public ReadOnly Property HingeEdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
If m_TypePart.Contains("DO_") Then
Return m_HingeEdgeTypeList
Else ' se stiamo leggendo un frame carico la lista dei bevel dei frame
Return Assembly.m_FrameEdgeTypeList
End If
End Get
End Property
Public ReadOnly Property BottomEdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
If m_TypePart.Contains("DO_") Then
Return m_BottomEdgeTypeList
Else ' se stiamo leggendo un frame carico la lista dei bevel dei frame
Return Assembly.m_FrameEdgeTypeList
End If
End Get
End Property
Public ReadOnly Property TopEdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
If m_TypePart.Contains("DO_") Then
Return m_TopEdgeTypeList
Else ' se stiamo leggendo un frame carico la lista dei bevel dei frame
Return Assembly.m_FrameEdgeTypeList
End If
End Get
End Property
Private m_LockEdgeType As New EdgeType("", Visibility.Visible)
Public Property LockEdgeType As EdgeType
Get
'If m_LockEdgeType.IsActive = Visibility.Collapsed Then
' m_LockEdgeType = EdgeTypeList(0)
' Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
'End If
Return m_LockEdgeType
End Get
Set(value As EdgeType)
m_LockEdgeType = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetLockEdgeType(LockEdgeType As EdgeType)
m_LockEdgeType = LockEdgeType
NotifyPropertyChanged("LockEdgeType")
End Sub
Private m_HingeEdgeType As New EdgeType("", Visibility.Visible)
Public Property HingeEdgeType As EdgeType
Get
'If m_HingeEdgeType.IsActive = Visibility.Collapsed Then
' m_HingeEdgeType = EdgeTypeList(0)
' Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
'End If
NotifyPropertyChanged("EdgeTypeList")
Return m_HingeEdgeType
End Get
Set(value As EdgeType)
m_HingeEdgeType = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetHingeEdgeType(HingeEdgeType As EdgeType)
m_HingeEdgeType = HingeEdgeType
NotifyPropertyChanged("HingeEdgeType")
End Sub
Private m_TopType As New EdgeType("", Visibility.Visible)
Public Property TopType As EdgeType
Get
'If m_TopType.IsActive = Visibility.Collapsed Then
' m_TopType = EdgeTypeList(0)
' Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
'End If
Return m_TopType
End Get
Set(value As EdgeType)
m_TopType = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetTopType(TopType As EdgeType)
m_TopType = TopType
NotifyPropertyChanged("TopType")
End Sub
Private m_BottomType As New EdgeType("", Visibility.Visible)
Public Property BottomType As EdgeType
Get
'If m_BottomType.IsActive = Visibility.Collapsed Then
' m_BottomType = EdgeTypeList(0)
' Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
'End If
Return m_BottomType
End Get
Set(value As EdgeType)
m_BottomType = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetBottomType(BottomType As EdgeType)
m_BottomType = BottomType
NotifyPropertyChanged("BottomType")
End Sub
#End Region
#Region "Machining"
Private m_TopMachining As Boolean
Public Property TopMachining As Boolean
Get
Return m_TopMachining
End Get
Set(value As Boolean)
m_TopMachining = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Private m_LockEdgeMachining As Boolean
Public Property LockEdgeMachining As Boolean
Get
Return m_LockEdgeMachining
End Get
Set(value As Boolean)
m_LockEdgeMachining = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Private m_HingeEdgeMachining As Boolean
Public Property HingeEdgeMachining As Boolean
Get
Return m_HingeEdgeMachining
End Get
Set(value As Boolean)
m_HingeEdgeMachining = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Private m_BottomMachining As Boolean
Public Property BottomMachining As Boolean
Get
Return m_BottomMachining
End Get
Set(value As Boolean)
m_BottomMachining = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
#End Region
#Region "OverMaterial"
Public ReadOnly Property ToolTipEvaluatedLockOverMaterial As String
Get
Dim dVal As Double
If StringToDouble(m_LockEdgeOverMaterial, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedHingeOverMaterial As String
Get
Dim dVal As Double
If StringToDouble(m_HingeEdgeOverMaterial, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedTopOverMaterial As String
Get
Dim dVal As Double
If StringToDouble(m_TopOverMaterial, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Public ReadOnly Property ToolTipEvaluatedBottomOverMaterial As String
Get
Dim dVal As Double
If StringToDouble(m_BottomOverMaterial, dVal) Then
Return DoubleToString(dVal, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Private m_LockEdgeOverMaterial As String = String.Empty
Public Property LockEdgeOverMaterial As String
Get
Return m_LockEdgeOverMaterial
End Get
Set(value As String)
m_LockEdgeOverMaterial = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
NotifyPropertyChanged("ToolTipEvaluatedLockOverMaterial")
End Set
End Property
Private m_HingeEdgeOverMaterial As String = String.Empty
Public Property HingeEdgeOverMaterial As String
Get
Return m_HingeEdgeOverMaterial
End Get
Set(value As String)
m_HingeEdgeOverMaterial = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
NotifyPropertyChanged("ToolTipEvaluatedHingeOverMaterial")
End Set
End Property
Private m_TopOverMaterial As String = String.Empty
Public Property TopOverMaterial As String
Get
Return m_TopOverMaterial
End Get
Set(value As String)
m_TopOverMaterial = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
NotifyPropertyChanged("ToolTipEvaluatedTopOverMaterial")
End Set
End Property
Private m_BottomOverMaterial As String = String.Empty
Public Property BottomOverMaterial As String
Get
Return m_BottomOverMaterial
End Get
Set(value As String)
m_BottomOverMaterial = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
NotifyPropertyChanged("ToolTipEvaluatedBottomOverMaterial")
End Set
End Property
#End Region
Public Sub SetVarSize()
Dim dHeight As Double
Dim dWidth As Double
Dim dThickness As Double
If Not IsNothing(m_Height) And Not IsNothing(m_Width) And Not IsNothing(m_Thickness) Then
If StringToDouble(m_Height, dHeight) Then
EgtLuaSetGlobNumVar("H", dHeight)
End If
If StringToDouble(m_Width, dWidth) Then
EgtLuaSetGlobNumVar("W", dWidth)
End If
If StringToDouble(m_Thickness, dThickness) Then
EgtLuaSetGlobNumVar("T", dThickness)
End If
End If
End Sub
#End Region ' General
Friend m_CompoList As New ObservableCollection(Of Compo)
Public Property CompoList As ObservableCollection(Of Compo)
Get
Return m_CompoList
End Get
Set(value As ObservableCollection(Of Compo))
m_CompoList = value
End Set
End Property
'Gestione ComboBox e TextBox di ogni compo della pulsantiera letta da Compo.ini
Friend Function AddNewCompo(CurrCompoType As CompoType) As Compo
' disabilito la costruzione del riferimento
Assembly.BuiltReffCompo = False
' creo la stringa che contiene la lista degli errori
Dim ErrorList As String = String.Empty
' creo il nuovo compo
Dim NewCompo As New Compo(CurrCompoType, Me)
' Leggo il file ini del componente per vedere se c'è il template: se c'è
If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME) <> 0 Then
' leggo nomi
Dim Name As String = String.Empty
Dim DDFName As String = String.Empty
IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
Dim TemplateList As New List(Of String)
GetDirectoryCompoFiles(CurrCompoType.Path, TemplateList)
' aggiungo il template come parametro
NewCompo.TemplateDDFName = DDFName
NewCompo.TemplateName = Name
NewCompo.TemplateItemList = TemplateList
If Not SetItemTemplate(NewCompo.CompoType.DDFName) = String.Empty Then
NewCompo.SetTemplateSelItem(SetItemTemplate(NewCompo.CompoType.DDFName))
Else
' se esiste un lista di template
If NewCompo.TemplateItemList.Count > 0 Then
Dim SelItemindex As Integer = 0
' cerco il primo elemento della lista che abbia estensione lua
While Path.HasExtension(NewCompo.TemplateItemList(SelItemindex)) And SelItemindex < NewCompo.TemplateItemList.Count - 1
SelItemindex += 1
End While
' inizializzo la combobox template
NewCompo.SetTemplateSelItem(NewCompo.TemplateItemList(SelItemindex))
End If
End If
' se non c'è il template
Else
' nascondo il template
NewCompo.TemplateVisibility = Visibility.Collapsed
' leggo il nome del compo dal file config.ini
Dim sTemplateName As String = String.Empty
EgtUILib.GetPrivateProfileString(S_TEMPLATE, K_COMPO, "", sTemplateName, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
If String.IsNullOrWhiteSpace(sTemplateName) Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
ElseIf Not File.Exists(CurrCompoType.Path & "\" & sTemplateName & ".lua") Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
Else
NewCompo.TemplateSelItem = sTemplateName
End If
End If
' raggruppo tutte le componenti che hanno lo stesso nome vicine
If Not IsNothing(NewCompo) Then
'-----------------------------------------------------------------------------------------------------------------------------------------------
' questa parte viene ignorata se l'oggetto chiamante è un Frame o una Porta Inattiva
If Not IsNothing(Me.m_TypePart) AndAlso Not Me.m_TypePart.Contains("F") Then
If Not IsNothing(Map.refAssemblyPageVM.CurrAssembly.LeftJamb) Then
' costruisco un riferimnto in locale dell'assemblato
Dim CurrAssembly As Assembly = Map.refAssemblyPageVM.CurrAssembly
' il nome del file associato alla componente
Dim FrameCompoFile As String = String.Empty
Dim FrameCompoFileConfig As String = String.Empty
Dim nDoorNbr As Integer = 1
Int32.TryParse(Map.refAssemblyPageVM.CurrAssembly.DoorNumber, nDoorNbr)
' se il file Matching.lua manca nel direttorio allora esco
If CalcCompoMatching(NewCompo.CompoType.Path, nDoorNbr, NewCompo.TemplateSelItem, FrameCompoFile) AndAlso
Not String.IsNullOrEmpty(FrameCompoFile) Then
'------------------------------------------------------------------------------------------------------------------------------------------
If Not SearchFileConfig(FrameCompoFile, FrameCompoFileConfig) Then
MessageBox.Show("Jamb compo does not exist", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning)
Else
CreateRefCompo(CurrCompoType, NewCompo, CurrAssembly, FrameCompoFileConfig, FrameCompoFile, Me)
End If
End If
End If
End If
'-----------------------------------------------------------------------------------------------------------------------------------------------
' se trova già una componente allora l'inserimento avviene nel ciclo for
Dim bInsert = False
Dim CompoIndex = 0
For CompoIndex = 0 To m_CompoList.Count - 1
' inserisco la nuova componente
If NewCompo.CompoType.DDFName = m_CompoList(CompoIndex).CompoType.DDFName Then
' cerco l'ultima componente con lo stesso nome
Dim Lastindex As Integer = 0
While CompoIndex + Lastindex < m_CompoList.Count AndAlso NewCompo.CompoType.DDFName = m_CompoList(CompoIndex + Lastindex).CompoType.DDFName
Lastindex += 1
End While
CompoList.Insert(CompoIndex + Lastindex, NewCompo)
bInsert = True
Exit For
End If
Next
If Not bInsert Then
CompoList.Add(NewCompo)
End If
End If
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
' riabilito la costruzion del riferimnto
Assembly.BuiltReffCompo = True
Return NewCompo
End Function
Friend Shared Sub CreateRefCompo(ByRef CurrCompoType As CompoType, ByRef NewCompo As Compo, ByRef CurrAssembly As Assembly, FrameCompoFileConfig As String, FrameCompoFile As String, CurrDoor As Part)
' disabilito la costruzione del riferimento
Assembly.BuiltReffCompo = False
' definisco un riferimento ad una variabile che sarà usata nel jamb
Dim CompoTypeJamb As CompoType
' dato il direttorio dove si trova la componente devo ora cercare il file Config.ini per la lettura dei parametri della componente
Dim FrameCompoNameDDF As String = String.Empty
Dim FrameCompoName As String = String.Empty
Dim Side As String = String.Empty
Dim CurrCompoPath As String = FrameCompoFileConfig
If File.Exists(CurrCompoPath) Then
GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, FrameCompoNameDDF, FrameCompoName, CurrCompoPath)
GetPrivateProfileJambSide(S_POSITIONSIDE, K_SIDE, Side, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
If String.IsNullOrEmpty(Side) Then
' controllo nell'elenco dei parametri se esiste un parametro di tipo Side
For IndexParam As Integer = 0 To NewCompo.CompoParamList.Count - 1
If NewCompo.CompoParamList(IndexParam).DDFName.ToLower = "side" Then
Side = DirectCast(NewCompo.CompoParamList(IndexParam), ComboBoxParam).SelItem
Exit For
End If
Next
End If
' ricontrollo che la stringa non sia vuota
If Not String.IsNullOrEmpty(Side) Then
Dim FrameCompoDirectory As String
FrameCompoDirectory = FrameCompoFileConfig.Remove(FrameCompoFileConfig.LastIndexOf("\"))
CompoTypeJamb = New CompoType(FrameCompoName, FrameCompoNameDDF, FrameCompoDirectory, Side)
NewCompo.CompoType.SetJambSide(Side)
Else
Return
End If
Else
' se non trovo nulla nel direttorio indicato carico il direttorio della componente corrente
Return
End If
'------------------------------------------------------------------------------------------------------------------------------------------
Select Case CurrAssembly.DoorNumber
Case "1"
' questo select case serve per gestire la posizione degli hardware sui Jamb
Select Case CurrCompoType.JambSide.ToLower
Case "hinge"
If CurrAssembly.LeftJamb.Swing.Contains("L") Then
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "lock"
If CurrAssembly.LeftJamb.Swing.Contains("L") Then
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "top"
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case "bottom"
NewCompo.refJambCompo = CurrAssembly.BottomJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End Select
Case "2"
Select Case CurrCompoType.JambSide.ToLower
Case "hinge"
If CurrDoor.TypePart = "DO_1" Then
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "lock"
' significa che le componenrti stanno solo sulle porte
If CurrDoor.TypePart = "DO_1" And Not CurrDoor.Swing.Contains("I") Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(1).Door.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
ElseIf CurrDoor.TypePart = "DO_2" And Not CurrDoor.Swing.Contains("I") Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(0).Door.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "top"
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case "bottom"
NewCompo.refJambCompo = CurrAssembly.BottomJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End Select
End Select
' riabilito la costruzion del riferimnto
Assembly.BuiltReffCompo = True
End Sub
'Gestione ComboBox e TextBox di ogni compo della pulsantiera letta da Compo.ini
Public Function AddRefCompo(CurrCompoType As CompoType, FrameCompoFile As String) As Compo
' creo la stringa che contiene la lista degli errori
Dim ErrorList As String = String.Empty
' creo il nuovo compo
Dim NewCompo As New Compo(CurrCompoType, Me)
' Leggo il file ini del componente per vedere se c'è il template: se c'è
If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME) <> 0 Then
' leggo nomi
Dim Name As String = String.Empty
Dim DDFName As String = String.Empty
IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
Dim TemplateList As New List(Of String)
GetDirectoryCompoFiles(CurrCompoType.Path, TemplateList)
' aggiungo il template come parametro
NewCompo.TemplateDDFName = DDFName
NewCompo.TemplateName = Name
NewCompo.TemplateItemList = TemplateList
NewCompo.SetTemplateSelItemRefCompo(FrameCompoFile, NewCompo)
Else
' nascondo il template
NewCompo.TemplateVisibility = Visibility.Collapsed
' leggo il nome del compo dal file config.ini
Dim sTemplateName As String = String.Empty
EgtUILib.GetPrivateProfileString(S_TEMPLATE, K_COMPO, "", sTemplateName, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
If String.IsNullOrWhiteSpace(sTemplateName) Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
ElseIf Not File.Exists(CurrCompoType.Path & "\" & sTemplateName & ".lua") Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
Else
NewCompo.TemplateSelItem = sTemplateName
End If
End If
' raggruppo tutte le componenti che hanno lo stesso nome vicine
If Not IsNothing(NewCompo) Then
' se trova già una componente allora l'inserimento avvien nel ciclo for
Dim bInsert = False
Dim CompoIndex = 0
For CompoIndex = 0 To m_CompoList.Count - 1
' inserisco la nuova componente
If NewCompo.CompoType.DDFName = m_CompoList(CompoIndex).CompoType.DDFName Then
' cerco l'ultima componente con lo stesso nome
Dim Lastindex As Integer = 0
While CompoIndex + Lastindex < m_CompoList.Count AndAlso NewCompo.CompoType.DDFName = m_CompoList(CompoIndex + Lastindex).CompoType.DDFName
Lastindex += 1
End While
CompoList.Insert(CompoIndex + Lastindex, NewCompo)
bInsert = True
Exit For
End If
Next
If Not bInsert Then
CompoList.Add(NewCompo)
End If
End If
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Return NewCompo
End Function
' ricerco la stessa componente all'interno della lista di comopnenti, se non trovo nulla restituisco una stringa vuota
Private Function SetItemTemplate(CompoName As String) As String
Dim IndexCompo As Integer = 0
For IndexCompo = 0 To CompoList.Count - 1
If CompoList(IndexCompo).CompoType.DDFName = CompoName Then
Return CompoList(IndexCompo).TemplateSelItem
Exit For
End If
Next
Return String.Empty
End Function
Friend Sub RemoveCompo(CompoToRemove As Compo)
If Not IsNothing(CompoToRemove.refJambCompo) Then
If Map.refAssemblyPageVM.CurrAssembly.LeftJamb.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.LeftJamb.RemoveCompo(CompoToRemove.refJambCompo)
ElseIf Map.refAssemblyPageVM.CurrAssembly.RightJamb.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.RightJamb.RemoveCompo(CompoToRemove.refJambCompo)
ElseIf Map.refAssemblyPageVM.CurrAssembly.TopJamb.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.TopJamb.RemoveCompo(CompoToRemove.refJambCompo)
ElseIf Map.refAssemblyPageVM.CurrAssembly.BottomJamb.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.BottomJamb.RemoveCompo(CompoToRemove.refJambCompo)
ElseIf Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.RemoveCompo(CompoToRemove.refJambCompo)
ElseIf Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.CompoList.IndexOf(CompoToRemove.refJambCompo) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.RemoveCompo(CompoToRemove.refJambCompo)
End If
End If
CompoList.Remove(CompoToRemove)
End Sub
Friend Sub RemoveRefCompo(ByRef CompoToRemove As Compo)
If Not IsNothing(CompoToRemove) Then
If Map.refAssemblyPageVM.CurrAssembly.LeftJamb.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.LeftJamb.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
ElseIf Map.refAssemblyPageVM.CurrAssembly.RightJamb.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.RightJamb.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
ElseIf Map.refAssemblyPageVM.CurrAssembly.TopJamb.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.TopJamb.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
ElseIf Map.refAssemblyPageVM.CurrAssembly.BottomJamb.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.BottomJamb.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
ElseIf Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(1).Door.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
ElseIf Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.CompoList.IndexOf(CompoToRemove) > -1 Then
Map.refAssemblyPageVM.CurrAssembly.GetArrayPartDoor(0).Door.RemoveCompo(CompoToRemove)
CompoToRemove = Nothing
End If
End If
End Sub
' aggiorna il ToolTip delle TextBox
Private Sub UpdateToolTip()
For CompoIndex = 0 To m_CompoList.Count - 1
For ParamIndex = 0 To m_CompoList(CompoIndex).CompoParamList.Count - 1
If TypeOf m_CompoList(CompoIndex).CompoParamList(ParamIndex) Is TextBoxParam Then
Dim TextBoxParam As TextBoxParam = DirectCast(m_CompoList(CompoIndex).CompoParamList(ParamIndex), TextBoxParam)
TextBoxParam.NotifyPropertyChanged("ToolTipValue")
End If
Next
Next
End Sub
#Region "LETTURA DDF"
Private bModifyBevel As Boolean = False
Private FileContent As String()
' Genero una nuova porta da usare nella lettura di un DDF
Shared Sub ReadDDFPartDoor(ArrayFile() As String, ByRef LineIndex As Integer, ByRef ReadDoor As Part)
' Inizializzazioni
ReadDoor.FileContent = ArrayFile
ReadDoor.m_TypePart = "DO_1"
' Se il file DDF è vuoto
If ReadDoor.FileContent.Count = 0 Then
MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
End If
' Leggo riga per riga
Dim sErrorInfo As String = String.Empty
While LineIndex < ReadDoor.FileContent.Count
Dim sLine As String = RemoveComment(ReadDoor.FileContent(LineIndex))
' Se linea vuota o solo commento, vado oltre
If String.IsNullOrWhiteSpace(sLine) Then
LineIndex += 1
Continue While
End If
' Controllo fine pezzo o fine file
If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While
' Modifica su vecchi file con "pressure:" indentato, per continuare a leggerli
If sLine.IndexOf(S_WEIGHT & ":") > 0 Then sLine = sLine.TrimStart()
' Processo la sezione
Dim sSection As String = GetName(sLine)
Select Case sSection
Case S_PRODUCE
LineIndex = ReadDoor.GetProduce(LineIndex)
Case S_MEASURES
LineIndex = ReadDoor.GetMeasure(LineIndex)
Case S_CODE
LineIndex = ReadDoor.GetCode(LineIndex)
' Se manca il codice, errore
If LineIndex = -1 Then
' carico il messaggio di errore
sErrorInfo &= String.Format(EgtMsg(50102), S_CODE) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
Case S_ORDER
LineIndex = ReadDoor.GetOrder(ReadDoor.NextIndex(LineIndex))
' Se mancano i dati dell'ordine, errore
If LineIndex = -1 Then
' carico il messaggio di errore
sErrorInfo &= String.Format(EgtMsg(50102), S_ORDER) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
Case S_DATE
LineIndex = ReadDoor.GetDate(LineIndex)
Case S_PIECE
LineIndex = ReadDoor.GetPiece(LineIndex)
Case S_POSITION
LineIndex = ReadDoor.GetPosition(ReadDoor.NextIndex(LineIndex))
' Se mancano i dati di posizione, errore
If LineIndex = -1 Then
' carico il messaggio di errore
sErrorInfo &= String.Format(EgtMsg(50102), S_POSITION) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
Case S_SIZE
LineIndex = ReadDoor.GetSize(ReadDoor.NextIndex(LineIndex))
' Se mancano i dati di size, errore
If LineIndex = -1 Then
' carico il messaggio di errore
sErrorInfo &= String.Format(EgtMsg(50102), S_SIZE) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
Case S_WEIGHT
LineIndex = ReadDoor.GetWeight(LineIndex)
Case S_SWING
LineIndex = ReadDoor.GetSwing(LineIndex)
If LineIndex = -1 Then
sErrorInfo &= String.Format(EgtMsg(50102), S_SWING) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
Case S_SECURE ' creo l'oggetto OptionPage nella Mappa
LineIndex = ReadDoor.GetSecure(LineIndex)
Case S_PROFILES
LineIndex = ReadDoor.GetProfiles(ReadDoor.NextIndex(LineIndex), ReadDoor.TypePart)
If LineIndex = -1 Then
sErrorInfo &= String.Format(EgtMsg(50102), S_PROFILES) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
Case Else 'COMPONENTS
' Se sezione senza nome o altro errore
If String.IsNullOrWhiteSpace(sSection) Then
sErrorInfo &= String.Format(EgtMsg(50130), LineIndex) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
' Lettura del componente
LineIndex = ReadDoor.GetCompo(ReadDoor.NextIndex(LineIndex), sSection, sErrorInfo)
If LineIndex = -1 Then
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
End Select
End While
' Aggiorno
If Not IsNothing(ReadDoor) Then
Map.refPartPageVM.CurrPart = ReadDoor
'Map.refOptionsVM.RefreshEdgeTypeList()
' Sarebbe buona norma inserire qui la stringa con i messaggi di errore e avvertimento (dopo aver caricato i bevel corretti)
If ReadDoor.bModifyBevel Then
MessageBox.Show("Door dispositiopn has been modify.", EgtMsg(50115), MessageBoxButton.OK, MessageBoxImage.Asterisk, MessageBoxResult.No)
End If
End If
' se la stringa dei messaggi contiene delle informazioni allora visualizzo
If Not String.IsNullOrWhiteSpace(sErrorInfo) Then
Dim sTitle As String = EgtMsg(50101)
If Not IsNothing(ReadDoor) Then sTitle &= " in " & ReadDoor.TypePart
MessageBox.Show(sErrorInfo, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
Else
If String.IsNullOrEmpty(ReadDoor.m_Weight) Then
If m_IsCheckedWeight = Visibility.Visible Then
' se il valore è acceso ma non è presente nel ddf chiedo se spegnere
If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' decido di spegnere
OptionsVM.IsCheckedWeight = False
Else
' decido di accendere
OptionsVM.IsCheckedWeight = True
ReadDoor.m_Weight = OptionModule.m_Weight
ReadDoor.VisibilityWeight = Visibility.Visible
End If
End If
End If
End If
End Sub
' Passaggio controllato alla prossima linea del file
Private Function NextIndex(Index As Integer) As Integer
Return SkipWhiteSpace(FileContent, Index + 1)
End Function
' Leggo il frame
Private Function GetProduce(Index As Integer) As Integer
Dim sProduce As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_PRODUCE)
If String.IsNullOrWhiteSpace(sProduce) Then
m_IsActive = True
Else
m_IsActive = (sProduce.ToLower() = "true")
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo l'unità di misura
Private Function GetMeasure(Index As Integer) As Integer
Dim sMeasure As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_MEASURES)
If String.IsNullOrWhiteSpace(sMeasure) Then
' assegna il valore di default caricato nell'OptionModule
m_Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit)
Else
m_Measure = ConvertMmUnitsToString(ConvertStringToMmUnits(sMeasure))
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo il codice
Private Function GetCode(Index As Integer) As Integer
Dim Code As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_CODE)
If String.IsNullOrWhiteSpace(Code) Then
' Errore
Return -1
Else
m_Code = Code
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo i dati della sezione order
Private Function GetOrder(ByRef Index As Integer) As Integer
' Recupero dati customer
If Index > FileContent.Count() - 1 Then Return -1
Dim Customer As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_CUSTOMER)
If Not String.IsNullOrWhiteSpace(Customer) Then m_Customer = Customer
Index = NextIndex(Index)
' Recupero dati elevation
If Index > FileContent.Count() - 1 Then Return -1
Dim Elevation As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_ELEVATION)
If Not String.IsNullOrWhiteSpace(Elevation) Then m_Elevation = Elevation
Index = NextIndex(Index)
' Recupero dati project
If Index > FileContent.Count() - 1 Then Return -1
Dim Project As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PROJECT)
If Not String.IsNullOrWhiteSpace(Project) Then m_Project = Project
Index = NextIndex(Index)
' Recupero dati PO (purchase order)
If Index > FileContent.Count() - 1 Then Return -1
Dim PO As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PO)
If Not String.IsNullOrWhiteSpace(PO) Then m_PO = PO
Index = NextIndex(Index)
' Recupero dati line
If Index > FileContent.Count() - 1 Then Return -1
Dim Line As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_LINE)
If Not String.IsNullOrWhiteSpace(Line) Then m_Line = Line
Index = NextIndex(Index)
' Passo alla fine della sezione
While Index < FileContent.Count() AndAlso Not SearchName(RemoveComment(FileContent(Index)), S_DATE)
Index = NextIndex(Index)
End While
Return Index
End Function
' Leggo la data
Private Function GetDate(Index As Integer) As Integer
Dim sDate As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_DATE)
If String.IsNullOrWhiteSpace(sDate) Then
' assegna il valore di default caricato nell'OptionModule
m_Date = System.DateTime.Now.ToString("dd/MM/yyyy")
Else
m_Date = sDate
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo il piece
Private Function GetPiece(Index As Integer) As Integer
Dim sType As String = GetValueWithKey(RemoveComment(FileContent(Index)), S_PIECE)
If Not String.IsNullOrWhiteSpace(sType) Then
m_TypePart = sType
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo i dati di position
Private Function GetPosition(Index As Integer) As Integer
If Index > FileContent.Count() - 1 Then Return -1
Dim sX As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_X)
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
Dim sY As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_Y)
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
Dim sZ As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_Z)
Index = NextIndex(Index)
Return Index
End Function
' Leggo i dati di size
Private Function GetSize(Index As Integer) As Integer
' Width
If Index > FileContent.Count() - 1 Then Return -1
Dim sLine As String = RemoveComment(FileContent(Index))
Dim Width As String = GetValueWithKey(sLine, K_WIDTH)
If String.IsNullOrWhiteSpace(Width) Then
If Not SearchKey(sLine, K_WIDTH) Then Return -1
' altrimenti
m_Width = OptionModule.m_Width
Part.FirstReadingEdge = True
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_WIDTH_INI) & " Missing parameter in ddf!", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Else
m_Width = Width
End If
Index = NextIndex(Index)
' Height
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim Height As String = GetValueWithKey(sLine, K_HEIGHT)
If String.IsNullOrWhiteSpace(Height) Then
If Not SearchKey(sLine, K_HEIGHT) Then Return -1
' altrimenti
m_Height = OptionModule.m_Height
Part.FirstReadingEdge = True
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_HEIGHT_INI) & " Missing parameter in ddf!", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Else
m_Height = Height
End If
Index = NextIndex(Index)
' Thickness
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim Thickness As String = GetValueWithKey(sLine, K_THICKNESS)
If String.IsNullOrWhiteSpace(Thickness) Then
If Not SearchKey(sLine, K_THICKNESS) Then Return -1
' altrimenti
m_Thickness = OptionModule.m_Thickness
Part.FirstReadingEdge = True
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_THICKNESS_INI) & " Missing parameter in ddf!", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Else
m_Thickness = Thickness
End If
Map.refAssemblyPageVM.CurrAssembly.SetVarAssembly()
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo il valore del peso
Private Function GetWeight(Index As Integer) As Integer
' se sono arrivato fino a qui significa che è stato scritto nel ddf
Dim sLine As String = RemoveComment(FileContent(Index))
Dim Weight As String = GetValueWithKey(sLine, S_WEIGHT)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Weight) Then
' se non c'è la parola chiave significa che il valore è spento
If Not SearchKey(sLine, S_WEIGHT) Then
' confronto con il dato che è stato salvato nell'option page, se il valore è acceso
If m_IsCheckedWeight = Visibility.Visible Then
' se il valore è acceso ma non è presente nel ddf chiedo se spegnere
If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' decido di spegnere
OptionsVM.IsCheckedWeight = False
Else
' decido di accendere
OptionsVM.IsCheckedWeight = True
m_Weight = OptionModule.m_Weight
' questo richiamo serve per avvisare che il ddf sta cambiando forma
VisibilityWeight = Visibility.Visible
End If
End If
' altrimenti la parola chiave esiste ma non è associato nessun valore
Else
If m_IsCheckedWeight = Visibility.Collapsed Then
If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' decido di accendere
OptionsVM.IsCheckedWeight = True
m_Weight = OptionModule.m_Weight
Else
' decido di spegnere
OptionsVM.IsCheckedWeight = False
' questo richiamo serve ad avvisare che sta avvenendo un cambiamento nel ddf
VisibilityWeight = Visibility.Collapsed
End If
Else
' valore è acceso quindi posso salvarlo direttamente
m_Weight = OptionModule.m_Weight
End If
End If
' altrimenti è assegnato il valore del peso
Else
If m_IsCheckedWeight = Visibility.Collapsed Then
If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' decido di accendere
m_IsCheckedWeight = Visibility.Visible
OptionsVM.IsCheckedWeight = True
m_Weight = Weight
Else
' decido di spegnere
m_IsCheckedWeight = Visibility.Collapsed
End If
Else
' valore è acceso quindi posso salvarlo direttamente
m_Weight = Weight
End If
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo swing
Private Function GetSwing(Index As Integer) As Integer
Dim sLine As String = RemoveComment(FileContent(Index))
Dim Swing As String = GetValueWithKey(sLine, S_SWING)
If String.IsNullOrWhiteSpace(Swing) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(sLine, S_SWING) Then Return -1
' altrimenti lascia il valore vuoto
'm_Swing = OptionModule.m_Swing
Part.FirstReadingEdge = True
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_SWING_INI) & " Missing parameter in ddf!", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Else
' carico il valore nella porta corrente
m_Swing = Swing
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' Leggo il posizionamento in macchina della porta
Private Function GetSecure(Index As Integer) As Integer
Dim MessageBoxBevel As MessageBoxResult = MessageBoxResult.OK
' creo l'oggetto OptionsVM per la prima volta se non esiste
If IsNothing(Map.refOptionsVM) Then
Dim OptionsPage As OptionsVM = Map.refMainWindowVM.OptionPage
End If
' Recupero il valore di secure
Dim sLine As String = RemoveComment(FileContent(Index))
Dim sSecure As String = GetValueWithKey(sLine, S_SECURE)
If String.IsNullOrWhiteSpace(sSecure) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(sLine, S_SECURE) Then Return -1
' altrimenti lascia il valore vuoto
Else
' carico il valore nella porta corrente
m_Secure = sSecure
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' calcola la congruenza del posizionamento e del secure
Private Sub CalcBevelFromSecure()
' se sono nella configurazione assemblato e sto leggendo un frame
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly AndAlso Not IsNothing(Map.refAssemblyPageVM.CurrAssembly) AndAlso Not m_TypePart.Contains("DO_") Then
' assegno i profili bevel caricati nella pagina AssemblyPage
Try
SetLockEdgeType(Map.refAssemblyPageVM.CurrAssembly.EdgeTypeList.First(Function(x) x.Name = Map.refAssemblyPageVM.CurrAssembly.LockEdgeType.Name))
Catch ex As Exception
End Try
Try
SetHingeEdgeType(Map.refAssemblyPageVM.CurrAssembly.EdgeTypeList.First(Function(x) x.Name = Map.refAssemblyPageVM.CurrAssembly.HingeEdgeType.Name))
Catch ex As Exception
End Try
Try
SetTopType(Map.refAssemblyPageVM.CurrAssembly.EdgeTypeList.First(Function(x) x.Name = Map.refAssemblyPageVM.CurrAssembly.TopType.Name))
Catch ex As Exception
End Try
Try
SetBottomType(Map.refAssemblyPageVM.CurrAssembly.EdgeTypeList.First(Function(x) x.Name = Map.refAssemblyPageVM.CurrAssembly.BottomType.Name))
Catch ex As Exception
End Try
' la disposizione è sempre BD, non modificabile, quindi mostro a video BySwing
Try
SetDispositionItem(DispositionList.First(Function(x) x.Name = "BySwing"))
Catch ex As Exception
End Try
Else ' se è un'anta (in qualsisi tipo di configurazione)
' controllo se almeno uno dei bevel della porta ha BV
Dim Bevel As String = String.Empty
Dim sBevelLock As String = String.Empty
Dim sBevelHinge As String = String.Empty
Dim sBevelTop As String = String.Empty
Dim sBevelBottom As String = String.Empty
' se almeno un profilo è di tipo bevel
If m_LockEdgeType.Name = "BV" Then sBevelLock = m_LockEdgeType.BevelDDF
If m_HingeEdgeType.Name = "BV" Then sBevelHinge = m_HingeEdgeType.BevelDDF
If m_TopType.Name = "BV" Then sBevelTop = m_TopType.BevelDDF
If m_BottomType.Name = "BV" Then sBevelBottom = m_BottomType.BevelDDF
' controllo che i bevel siano tutti uguali nello stesso Part
Bevel = ControlBevel(sBevelLock, sBevelHinge, sBevelTop, sBevelBottom)
' nel caso di nessuna disposizione fissata da Config.ini
Select Case OptionModule.m_sDisposition
Case "BD"
SetDispositionItem(m_DispositionList(1))
' modifico il bevel da BU a BD
Modifybevel(Bevel, "BU")
'OptionModule.m_bBevelDown = Visibility.Visible
'OptionModule.m_bBevelUp = Visibility.Collapsed
Case "BU"
SetDispositionItem(m_DispositionList(0))
Modifybevel(Bevel, "BD")
' la visibilità serve ad aggiornre la lista dei bevel nel caso siamo in presenza della vecchia configurazione
'OptionModule.m_bBevelUp = Visibility.Visible
'OptionModule.m_bBevelDown = Visibility.Collapsed
Case Else ' BySwing
If Not String.IsNullOrEmpty(Bevel) Then
Try
' seleziono il bevel letto nella lista delle disposizioni possibili (esiste un solo tipo di bevel per tutta la porta)
SetDispositionItem(m_DispositionList.First(Function(x) x.Name = Bevel))
If Bevel = "BU" Then OptionModule.m_bBevelUp = Visibility.Visible
If Bevel = "BD" Then OptionModule.m_bBevelDown = Visibility.Visible
' questo caso il secure segue le solite regole di calcolo
Catch ex As Exception ' se il bevel passato è BV devo calcolare il corretto bevel
SetDispositionItem(m_DispositionList.First(Function(x) x.Name = "BySwing"))
bModifyBevel = True
Part.FirstReadingEdge = True
End Try
Else ' Bevel SQ
If m_Swing.Contains("HR") Then
If m_Secure = "UP" Then
SetDispositionItem(m_DispositionList(0))
OptionModule.m_bBevelUp = Visibility.Visible
ElseIf m_Secure = "DN" Then
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
Else
m_Secure = "DN"
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
End If
Else
If m_Secure = "UP" Then
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
ElseIf m_Secure = "DN" Then
SetDispositionItem(m_DispositionList(0))
OptionModule.m_bBevelUp = Visibility.Visible
Else
m_Secure = "UP"
SetDispositionItem(m_DispositionList(0))
OptionModule.m_bBevelUp = Visibility.Visible
End If
End If
'm_Secure = "DN"
End If
End Select
End If
End Sub
' Leggo i dati dei profili
Private Function GetProfiles(Index As Integer, TypePart As String) As Integer
' ricalcolo la lista da mostrare a video
Map.refOptionsVM.RefreshEdgeTypeList()
Dim bError As Boolean = False
' Lock
If Index > FileContent.Count() - 1 Then Return -1
Dim sLine As String = RemoveComment(FileContent(Index))
m_LockEdgeType = m_LockEdgeTypeList(0)
Dim LockEdgeType As String = GetValueWithKey(sLine, K_LOCKEDGE)
If String.IsNullOrWhiteSpace(LockEdgeType) Then
' se non c'è la parola chiave allora esco con errore
If Not SearchKey(sLine, K_LOCKEDGE) Then Return -1
Else
' se valore nella lista
'If EdgeTypeControl(LockEdgeType) Then
Try
' cerco il valre nella lista
m_LockEdgeType = LockEdgeTypeList.First(Function(x) x.Name = LockEdgeType)
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_LockEdgeType.BevelDDF = LockEdgeType
Catch ex As Exception ' se il valore cercato non è nella lista
If Trim(LockEdgeType) = "BU" Or Trim(LockEdgeType) = "BD" Then
Try
m_LockEdgeType = LockEdgeTypeList.First(Function(x) x.Name = "BV")
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_LockEdgeType.BevelDDF = LockEdgeType
Catch ex2 As Exception
End Try
End If
End Try
' Else
' bError = True
'End If
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim LockEdgeMachining As String = GetValueWithKey(sLine, K_MACHINING)
If String.IsNullOrWhiteSpace(LockEdgeMachining) Then
If Not SearchKey(sLine, K_MACHINING) Then Return -1
Else
m_LockEdgeMachining = Utility.ConvertOnOffToBoolean(LockEdgeMachining)
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim LockEdgeOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(LockEdgeOverMaterial) Then
If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1
Else
m_LockEdgeOverMaterial = LockEdgeOverMaterial
End If
Index = NextIndex(Index)
' Hinge
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
m_HingeEdgeType = m_HingeEdgeTypeList(0)
Dim HingeEdgeType As String = GetValueWithKey(sLine, K_HINGEEDGE)
If String.IsNullOrWhiteSpace(HingeEdgeType) Then
' se non c'è la parola chiave allora esco con errore
If Not SearchKey(sLine, K_HINGEEDGE) Then Return -1
Else
' se valore nella lista
'If EdgeTypeControl(HingeEdgeType) Then
Try
m_HingeEdgeType = HingeEdgeTypeList.First(Function(x) x.Name = HingeEdgeType)
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_HingeEdgeType.BevelDDF = HingeEdgeType
Catch ex As Exception ' se il valore cercato non è nella lista
If Trim(HingeEdgeType) = "BU" Or Trim(HingeEdgeType) = "BD" Then
Try
m_HingeEdgeType = HingeEdgeTypeList.First(Function(x) x.Name = "BV")
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_HingeEdgeType.BevelDDF = HingeEdgeType
Catch ex2 As Exception
End Try
End If
End Try
' Else
' bError = True
'End If
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim HingeEdgeMachining As String = GetValueWithKey(sLine, K_MACHINING)
If String.IsNullOrWhiteSpace(HingeEdgeMachining) Then
If Not SearchKey(sLine, K_MACHINING) Then Return -1
Else
m_HingeEdgeMachining = ConvertOnOffToBoolean(HingeEdgeMachining)
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim HingeEdgeOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(HingeEdgeOverMaterial) Then
If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1
Else
m_HingeEdgeOverMaterial = HingeEdgeOverMaterial
End If
Index = NextIndex(Index)
' Top
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
m_TopType = m_TopEdgeTypeList(0)
Dim TopType As String = GetValueWithKey(sLine, K_TOP)
If String.IsNullOrWhiteSpace(TopType) Then
If Not SearchKey(sLine, K_TOP) Then Return -1
Else
' se valore nella lista
'If EdgeTypeControl(TopType) Then
Try
m_TopType = TopEdgeTypeList.First(Function(x) x.Name = TopType)
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_TopType.BevelDDF = TopType
Catch ex As Exception ' se il valore cercato non è nella lista
If Trim(TopType) = "BU" Or Trim(TopType) = "BD" Then
Try
m_TopType = TopEdgeTypeList.First(Function(x) x.Name = "BV")
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_TopType.BevelDDF = TopType
Catch ex2 As Exception
End Try
End If
End Try
' Else
' bError = True
'End If
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim TopMachining As String = GetValueWithKey(sLine, K_MACHINING)
If String.IsNullOrWhiteSpace(TopMachining) Then
If Not SearchKey(sLine, K_MACHINING) Then Return -1
Else
m_TopMachining = ConvertOnOffToBoolean(TopMachining)
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim TopOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(TopOverMaterial) Then
If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1
Else
m_TopOverMaterial = TopOverMaterial
End If
Index = NextIndex(Index)
' Bottom
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
m_BottomType = m_BottomEdgeTypeList(0)
Dim BottomType As String = GetValueWithKey(sLine, K_BOTTOM)
If String.IsNullOrWhiteSpace(BottomType) Then
If Not SearchKey(sLine, K_BOTTOM) Then Return -1
Else
' se valore nella lista
'If EdgeTypeControl(BottomType) Then
Try
m_BottomType = BottomEdgeTypeList.First(Function(x) x.Name = BottomType)
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_BottomType.BevelDDF = BottomType
Catch ex As Exception ' se il valore cercato non è nella lista
If Trim(BottomType) = "BU" Or Trim(BottomType) = "BD" Then
Try
m_BottomType = BottomEdgeTypeList.First(Function(x) x.Name = "BV")
' segno il bevel che è stato letto nel ddf per il calcolo del secure
m_BottomType.BevelDDF = BottomType
Catch ex2 As Exception
End Try
End If
End Try
' Else
' bError = True
'End If
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim BottomMachining As String = GetValueWithKey(sLine, K_MACHINING)
If String.IsNullOrWhiteSpace(BottomMachining) Then
If Not SearchKey(sLine, K_MACHINING) Then Return -1
Else
m_BottomMachining = ConvertOnOffToBoolean(BottomMachining)
End If
Index = NextIndex(Index)
If Index > FileContent.Count() - 1 Then Return -1
sLine = RemoveComment(FileContent(Index))
Dim BottomOverMaterial As String = GetValueWithKey(sLine, K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(BottomOverMaterial) Then
If Not SearchKey(sLine, K_OVERMATERIAL) Then Return -1
Else
m_BottomOverMaterial = BottomOverMaterial
End If
CalcBevelFromSecure()
Return NextIndex(Index)
End Function
' Leggo i dati del componente
Private Function GetCompo(Index As Integer, CompoNameDDF As String, ByRef sErrorInfo As String) As Integer
' Controllo esistenza del componente
Dim CompoListIndex As Integer = -1
For CmpInd = 0 To CompoPanelVM.CompoTypeList.Count() - 1
' eseguo il confronto con il nome dei componenti che è stato caricato dal file Default.ini
If CompoPanelVM.CompoTypeList(CmpInd).DDFName = CompoNameDDF Then
CompoListIndex = CmpInd
Exit For
End If
Next
' Se non esiste
If CompoListIndex = -1 Then
' il componente non esiste
sErrorInfo &= String.Format(EgtMsg(50136), CompoNameDDF, Index - 1)
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf
Return -1
End If
' Passo alla lettura delle linee con eventuali - shape/- template e con i parametri
While Index < FileContent.Count
Dim sLine As String = RemoveComment(FileContent(Index))
' se stringa vuota o tutto commento, vado oltre
If String.IsNullOrWhiteSpace(sLine) Then
Index += 1
Continue While
End If
' se fine pezzo o fine file, esco dal ciclo
If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While
' se nome, esco dal ciclo
If Not String.IsNullOrWhiteSpace(GetName(sLine)) Then Exit While
' cerco una chiave
Dim sKey As String = GetKey(sLine)
If String.IsNullOrWhiteSpace(sKey) Then
sErrorInfo &= String.Format(EgtMsg(50131), CompoNameDDF, Index + 1)
sErrorInfo &= Environment.NewLine & CompoNameDDF & " has not been created." & vbCrLf
' esco dalla lettura del compo
Exit While
End If
' Creo il componente
Dim m_CurrCompo = New Compo(CompoPanelVM.CompoTypeList(CompoListIndex), Me)
' Se previsto template o shape da configurazione
Dim CurrCompoTypePath As String = CompoPanelVM.CompoTypeList(CompoListIndex).Path
If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME) <> 0 Then
' leggo se template o shape
Dim Name As String = String.Empty
Dim DDFName As String = String.Empty
IniFile.GetPrivateProfileCompoName(S_TEMPLATE, K_NAME, DDFName, Name, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
m_CurrCompo.TemplateDDFName = DDFName
m_CurrCompo.TemplateName = Name
' creo la lista dei possibili template del componente
Dim TemplateList As New List(Of String)
GetDirectoryCompoFiles(CurrCompoTypePath, TemplateList)
m_CurrCompo.TemplateItemList = TemplateList
' Se c'è "- " iniziale
If sKey.StartsWith("- ") Then
' leggo il template effettivamente utilizzato
Dim sTemplate As String = GetValueWithoutKey(sLine)
m_CurrCompo.SetTemplateSelItem(sTemplate)
' se il template non compare nella lista
If String.IsNullOrWhiteSpace(m_CurrCompo.TemplateSelItem) Then
' elimina il compo appena creato
m_CurrCompo = Nothing
sErrorInfo &= String.Format("Template in line {0} does not exist", Index + 1) & vbCrLf
' salto tutti i suoi parametri
Index = NextIndex(Index)
SkipParams(Index)
' continuo nel ciclo while
Continue While
End If
' mi sposto alla riga successiva
Index = NextIndex(Index)
' leggo i parametri del componente
ReadParams(m_CurrCompo, sErrorInfo, Index)
' altrimenti non c'è il trattino nel file DDF
Else
sErrorInfo &= String.Format(EgtMsg(50132), DDFName, Index + 1)
sErrorInfo &= String.Format("-->" & EgtMsg(50133), CompoNameDDF) & vbCrLf
' salto tutti i suoi parametri
Index = NextIndex(Index)
SkipParams(Index)
' continuo nel ciclo while
Continue While
End If
' il componente non ha template (louver_cut_outs)
Else
' nascondo il template
m_CurrCompo.TemplateVisibility = Visibility.Collapsed
' leggo il nome del template della compo dal file config.ini
Dim sTemplateName As String = String.Empty
' controllo il tipo di estensione del file (nome letto da Config.ini)
EgtUILib.GetPrivateProfileString(S_TEMPLATE, K_COMPO, "", sTemplateName, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
If String.IsNullOrWhiteSpace(sTemplateName) Then
sErrorInfo &= String.Format(EgtMsg(50134), CurrCompoTypePath, CONFIGINI_FILE_NAME)
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf
m_CurrCompo = Nothing
ElseIf Not File.Exists(CurrCompoTypePath & "\" & sTemplateName & LUA_EXTENSION) Then
sErrorInfo &= String.Format(EgtMsg(50135), CurrCompoTypePath, CONFIGINI_FILE_NAME, sTemplateName)
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF) & vbCrLf
Else
' assegno il nome del tipo di componente
m_CurrCompo.SetTemplateSelItem(sTemplateName)
ReadParams(m_CurrCompo, sErrorInfo, Index)
End If
End If
' se esiste riferimento ad identificativo, lo leggo
If Index < FileContent.Count Then
' tolgo l'indicazione di metacomando "##"
sLine = RemoveComment(FileContent(Index).Replace(DDF_METADATA, ""))
If GetKey(sLine) = K_IDCODECOMPONENT Then
Dim IdCode As String = String.Empty
IdCode = GetValueWithKey(sLine, K_IDCODECOMPONENT)
If Not String.IsNullOrEmpty(IdCode) Then m_CurrCompo.IdCode = IdCode
Index = NextIndex(Index)
End If
End If
' Inserisco il componente in lista
m_CompoList.Add(m_CurrCompo)
End While
Return Index
End Function
' Salto i parametri del componente
Private Sub SkipParams(ByRef IndexLine As Integer)
' passo alla lettura delle righe
While IndexLine < FileContent.Count
Dim sLine As String = RemoveComment(FileContent(IndexLine))
' se stringa vuota o tutto commento, vado oltre
If String.IsNullOrWhiteSpace(sLine) Then
IndexLine += 1
Continue While
End If
' se fine pezzo o fine file, esco dal ciclo
If Search3Hyphens(sLine) OrElse Search3Dots(sLine) Then Exit While
' se nome, esco dal ciclo
If Not String.IsNullOrWhiteSpace(GetName(sLine)) Then Exit While
' se chiave con '-' iniziale, esco dal ciclo
Dim sKey As String = GetKey(sLine)
If sKey.StartsWith("- ") Then Exit While
' passo alla linea successiva
IndexLine += 1
End While
End Sub
' Leggo i parametri del componente
Private Sub ReadParams(ByRef CompoTemplateItem As Compo, ByRef sErrorInfo As String, ByRef IndexLine As Integer)
' questo è l'indice dei parametri del componente
Dim IndexParam As Integer = 0
While IndexParam < CompoTemplateItem.CompoParamList.Count
' carico la lista dei parametri della componente parametro per parametro
Dim CurrCompoParam As CompoParam = CompoTemplateItem.CompoParamList(IndexParam)
' Controllo che il file non sia terminato
If IndexLine < FileContent.Count Then
Dim sLine As String = RemoveComment(FileContent(IndexLine))
' se stringa vuota o tutto commento, vado oltre
If String.IsNullOrWhiteSpace(sLine) Then
IndexLine += 1
Continue While
End If
' se fine pezzo o fine file o nome o metacomando, esco dal ciclo
If Search3Hyphens(sLine) OrElse Search3Dots(sLine) OrElse
Not String.IsNullOrWhiteSpace(GetName(sLine)) OrElse
sLine.Trim().StartsWith(DDF_METADATA) Then
If Not TypeOf CurrCompoParam Is TextBoxOnOffParam Then
' restituisco il messaggio che manca un parametro
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf
Else
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False)
End If
Exit While
End If
' Se è di tipo obbligatorio (non è OnOff)
If Not (TypeOf CurrCompoParam Is TextBoxOnOffParam OrElse TypeOf CurrCompoParam Is ComboBoxOnOffParam) Then
Dim sKey As String = GetKey(sLine)
' se il nome del parametro è lo stesso di quello presente nel componente
If String.Equals(Trim(CurrCompoParam.DDFName), sKey) Then
If TypeOf CurrCompoParam Is ComboBoxParam Then
' leggo il valore DDF dal file
Dim sVal As String = GetValueWithoutKey(sLine)
' carico la lista dei valori (messaggi)
Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemList
' carico la lista dei valori DDF
Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemListDDF
' riscrivo i valori della lista DDF senza spazi all'inizio e alla fine e in minuscolo
For IndexListDDF As Integer = 0 To ListDDF.Count - 1
ListDDF(IndexListDDF) = Trim(ListDDF(IndexListDDF)).ToLower()
Next
' carico il valore IndexName come indice del valore selezionato dalla lista DDF
Dim IndexName As Integer = ListDDF.IndexOf(sVal.ToLower())
Dim SelItem As String = String.Empty
' se è stata trovata una corrispondenza tra il valore letto dal foile e il valore presente nella lista DDF
If IndexName >= 0 Then
' restituisco il valore DDF della lista associato all'indice passato
SelItem = List(IndexName)
Else
' il nome DDF non è corretto
sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine)
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
If String.IsNullOrEmpty(sVal) Then Part.FirstReadingEdge = True
SelItem = List(0)
End If
' assegno al parametro del componente il valore "filtrato"
DirectCast(CurrCompoParam, ComboBoxParam).SetSelItem(SelItem)
' assegno il valore letto alla textbox
ElseIf TypeOf CurrCompoParam Is TextBoxParam Then
Dim sVal As String = GetValueWithoutKey(sLine)
' per ora non esegue nessun tipo di controllo sui valori letti dal file DDF
DirectCast(CurrCompoParam, TextBoxParam).m_Value = sVal
' avviso che il file è modificato (in caso di chiusura del programma obbligo a passare dal salvataggio)
Dim dVal As Double
If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then Part.FirstReadingEdge = True
End If
' se il nome esiste ma è sbagliato
ElseIf Not String.IsNullOrWhiteSpace(sKey) Then
' se il nome non è preceduto dal trattino
If Not sKey.StartsWith("- ") Then
' il nome DDF non è corretto
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
' passo al parametro successivo senza cambiare linea del file DDF
IndexParam += 1
Continue While
Else
' istanzio tutti i valori che mancano al compo corrente di default
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
' esco dal ciclo
Exit While
End If
End If
' Se altrimenti è una TextBoxOnOff
ElseIf TypeOf CurrCompoParam Is TextBoxOnOffParam Then
' se il nome del parametro è lo stesso di quello presente nel componente
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).m_Value = sVal
Dim dVal As Double
If String.IsNullOrEmpty(sVal) OrElse Not StringToDouble(sVal, dVal) Then Part.FirstReadingEdge = True
DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(True)
' se il nome esiste ma è sbagliato
ElseIf Not String.IsNullOrWhiteSpace(GetKey(sLine)) Then
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False)
' passo al parametro successivo senza cambiare linea del file DDF
IndexParam += 1
Continue While
End If
' Altrimenti è una ComboBoxOnOffParam
Else
' se il nome del parametro è lo stesso di quello presente nel componente
If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(GetKey(sLine))) Then
' leggo il valore DDF dal file
Dim sVal As String = GetValueWithKey(sLine, Trim(CurrCompoParam.DDFName))
Dim IndexName As Integer = 0
' carico la lista dei valori (messaggi)
Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).ItemList
Dim IndexListDDF As Integer = 0
' carico la lista dei valori DDF
Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).ItemListDDF
' riscrivo i valori della lista DDF senza spaziatura
For IndexListDDF = 0 To ListDDF.Count - 1
ListDDF(IndexListDDF) = Trim(ListDDF(IndexListDDF))
Next
' carico il valore IndexName come indice del valore selezionato dalla lista DDF
IndexName = ListDDF.IndexOf(sVal)
Dim SelItem As String = String.Empty
' se è stata trovata una corrispondenza tra il valore letto dal file e il valore presente nella lista DDF
If IndexName >= 0 Then
' restituisco il valore DDF della lista associato all'indice passato
SelItem = Trim(List(IndexName))
Else
' il nome DDF non è corretto
sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine)
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
If String.IsNullOrEmpty(sVal) Then Part.FirstReadingEdge = True
SelItem = List(0)
End If
' assegno al parametro della compnente il valore "filtrato"
DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetSelItem(SelItem)
' se il nome esiste ma è sbagliato
ElseIf Not String.IsNullOrWhiteSpace(GetKey(sLine)) Then
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(False)
' passo al parametro successivo senza cambiare linea del file DDF
IndexParam += 1
Continue While
End If
End If
Else
If TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then
DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False)
ElseIf TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is ComboBoxOnOffParam Then
DirectCast(CurrCompoParam, ComboBoxOnOffParam).SetIsActive(False)
Else
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf
End If
End If
' Avanzo nell'elenco dei parametri e nel file DDF
IndexParam += 1
IndexLine = NextIndex(IndexLine)
End While
End Sub
' controllo che tutti i bevel siano dello stesso tipo
Private Function ControlBevel(BLock As String, BHinge As String, BTop As String, BBottom As String) As String
Dim BBevel As String = String.Empty
' carico i Bevel non nulli in un vettore
Dim ArrayProfile(3) As String
If Not String.IsNullOrEmpty(BLock) Then : ArrayProfile(0) = BLock : BBevel = BLock : Else : ArrayProfile(0) = String.Empty : End If
If Not String.IsNullOrEmpty(BHinge) Then : ArrayProfile(1) = BHinge : BBevel = BHinge : Else : ArrayProfile(1) = String.Empty : End If
If Not String.IsNullOrEmpty(BTop) Then : ArrayProfile(2) = BTop : BBevel = BTop : Else : ArrayProfile(2) = String.Empty : End If
If Not String.IsNullOrEmpty(BBottom) Then : ArrayProfile(3) = BBottom : BBevel = BBottom : Else : ArrayProfile(3) = String.Empty : End If
For Index1 As Integer = 0 To 2
For Index2 As Integer = Index1 + 1 To 3
If Not String.IsNullOrEmpty(ArrayProfile(Index1)) And Not String.IsNullOrEmpty(ArrayProfile(Index2)) Then
' eseguo il confronto
If ArrayProfile(Index1) <> ArrayProfile(Index2) Then
MessageBox.Show("Incongruity between the bevel, it has been resolved by default.", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
Part.FirstReadingEdge = True ' per mantere attivo l'asterisco di modifica
BBevel = ArrayProfile(Index1)
Exit For
Else
BBevel = ArrayProfile(Index1)
End If
End If
Next
Next
Return BBevel
End Function
' restituisce il messaggio di modifica del bevel
Private Sub Modifybevel(Bevel As String, OppositeBevel As String)
If Bevel = "BV" Then : bModifyBevel = True : Part.FirstReadingEdge = True : End If
If Bevel = OppositeBevel Then
' "Door dispositiopn has been modify."
bModifyBevel = True
Part.FirstReadingEdge = True
End If
' Modifico il secure (diverso da zero)
If String.IsNullOrEmpty(Bevel) AndAlso m_Secure <> "0" AndAlso m_Secure <> DdfFile.SetSecure(m_Swing, m_DispositionItem.Name, m_Secure) Then
bModifyBevel = True
Part.FirstReadingEdge = True ' per mantere attivo l'asterisco di modifica
End If
' caso speciale
If String.IsNullOrEmpty(Bevel) AndAlso m_Secure = "0" AndAlso DdfFile.SetSecure(m_Swing, m_DispositionItem.Name, m_Secure) = "UP" Then
bModifyBevel = True
Part.FirstReadingEdge = True ' per mantere attivo l'asterisco di modifica
End If
End Sub
' per mantenere la configuarbilità con la precedente versione devo riaggiornare le liste dei
'Private Sub EdgeTypeCpntrol(ByRef CurrEdgeType As EdgeType)
' If CurrEdgeType.Name = "BU" And OptionModule.m_sDisposition = "BD" Then
' Try
' CurrEdgeType = EdgeTypeList.First(Function(x) x.Name = "BD")
' Catch ex As Exception
' End Try
' ElseIf CurrEdgeType.Name = "BD" And OptionModule.m_sDisposition = "BU" Then
' Try
' CurrEdgeType = EdgeTypeList.First(Function(x) x.Name = "BU")
' Catch ex As Exception
' End Try
' End If
'End Sub
#End Region ' Lettura ddf
' Genero una nuova porta da usare nella lettura di un DDF
Sub New()
'CompoParam.m_rfSetTitle = AddressOf SetTitle
End Sub
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class