Files
EgtDOORCreator/DoorParameters/Part.vb
T
Nicola Pievani a30f32484e EgtDOORCreator 1.9f2:
- è salvato nel file ddf il nome della configurazione preceduto dall'intestazione Config: 
- nel caso di apertura di un direttorio vuoto (senza file ddf presenti) è visualizzata la pagina vuota
- sono state eseguite alcune modifiche al codice per iniziare a visualizzare nuovamente l'assemblato
2018-06-22 13:07:42 +00:00

2401 lines
108 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 (bevel)
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 (bevel)
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
#Region "Info Generali del ddf"
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
#End Region ' Info generali del ddf
#Region "SIZE"
Private m_Height As String
Public Property Height As String
Get
Return m_Height
End Get
Set(value As String)
m_Height = value
Dim dHeight As Double
If StringToDouble(value, dHeight) Then
EgtLuaSetGlobNumVar("H", dHeight)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
'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
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
Private m_Width As String = String.Empty
Public Property Width As String
Get
Return m_Width
End Get
Set(value As String)
m_Width = value
Dim dWidth As Double
If StringToDouble(value, dWidth) Then
EgtLuaSetGlobNumVar("W", dWidth)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
'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
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
Private m_Thickness As String
Public Property Thickness As String
Get
Return m_Thickness
End Get
Set(value As String)
m_Thickness = value
Dim dThickness As Double
If StringToDouble(value, dThickness) Then
EgtLuaSetGlobNumVar("T", dThickness)
End If
NotifyPropertyChanged("ToolTipEvaluatedThickness")
NotifyPropertyChanged("ToolTipEvaluatedWidth")
NotifyPropertyChanged("ToolTipEvaluatedHeight")
'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
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
#End Region ' Size
#Region "WEIGHT"
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
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 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
#End Region ' Weight
#Region "SWING"
' lista degli Swing
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_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
' aggiorno la grafica
Map.refSceneManagerVM.RefreshBtn()
End Set
End Property
Public Sub SetSwing(sSwing As String)
m_Swing = sSwing
NotifyPropertyChanged("Swing")
End Sub
#End Region ' Swing
#Region "EDGE"
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)
Public ReadOnly Property LockEdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
If m_TypePart.Contains(ConstGen.PART_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(ConstGen.PART_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(ConstGen.PART_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(ConstGen.PART_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
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
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
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
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 ' Edge
#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 ' Machining
#Region "OVERLAPMATERIAL"
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 ' OverlpaMaterial
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 ' General
' lista delle componenti
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
#Region "ADDCOMPO"
' utilizzata nell'Hardware
Friend Function AddNewHardware(HardwareGeneral As CompoType, TempHardwFile As String) As Boolean
' 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(HardwareGeneral)
' Leggo il file ini del componente per vedere se c'è il template: se c'è
If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, HardwareGeneral.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, HardwareGeneral.Path & "\" & CONFIGINI_FILE_NAME)
'Dim TemplateList As New ObservableCollection(Of String)
'GetDirectoryCompoFiles(HardwareGeneral.Path, TemplateList)
' aggiungo il template come parametro
NewCompo.TemplateDDFName = DDFName
NewCompo.TemplateName = Name
'NewCompo.TemplateItemList = TemplateList
NewCompo.SetTemplateSelItem(TempHardwFile)
' 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, HardwareGeneral.Path & "\" & CONFIGINI_FILE_NAME)
If String.IsNullOrWhiteSpace(sTemplateName) Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
ElseIf Not File.Exists(HardwareGeneral.Path & "\" & sTemplateName & LUA_EXTENSION) Then
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
Else
NewCompo.TemplateSelItem = sTemplateName
End If
End If
If Not IsNothing(NewCompo) Then
CompoList.Add(NewCompo)
Return True
End If
Return False
End Function
'Gestione ComboBox e TextBox di ogni compo della pulsantiera letta da Compo.ini (Door)
Friend Function AddNewCompo(CurrCompoType As CompoType) As Compo
' disabilito la costruzione del riferimento
Assembly.BuiltReffCompo = False
' converto tutti gli sfondi in bianco dei nomi delle componenti
For Each Compo In Map.refPartPageVM.CurrPart.CompoList
Compo.BorderColor = New BrushConverter().ConvertFrom("#DCDCDC")
Compo.BackGroundColor = New BrushConverter().ConvertFrom("#FFFFFF")
Compo.BorderThickness = 1
Next
' creo la stringa che contiene la lista degli errori
Dim ErrorList As String = String.Empty
' creo il nuovo oggetto compo
Dim NewCompo As New Compo(CurrCompoType)
' 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 della componente scritti nel file di configurazione
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)
NewCompo.TemplateDDFName = DDFName
NewCompo.TemplateName = Name
LoadBrandFileList(NewCompo)
' se non c'è il template
Else
' nascondo il template
NewCompo.TemplateVisibility = Visibility.Collapsed
' leggo il nome del compo dal file config.ini ( il nome del file lua che deve essere caricato)
Dim sTemplateName As String = String.Empty
EgtUILib.GetPrivateProfileString(S_TEMPLATE, K_COMPO, "", sTemplateName, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
' se il nome non esiste oppure non è associato alcun file elimina l'oggetto
If String.IsNullOrWhiteSpace(sTemplateName) Then
' Errore nella lettura {0} nel parametro {1} della componente.
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
ElseIf Not File.Exists(CurrCompoType.Path & "\" & sTemplateName & LUA_EXTENSION) Then
' Errore nella lettura {0} nel parametro {1} della componente.
ErrorList &= String.Format(EgtMsg(50122), K_COMPO, NewCompo.TemplateName)
NewCompo = Nothing
Else
' alrimenti seleziono il nome
NewCompo.TemplateSelItem = sTemplateName
End If
End If
' se è stata generata la componente
If Not IsNothing(NewCompo) Then
' raggruppo tutte le componenti che hanno lo stesso nome vicine
' 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
' se la componenteaggiunta è un a Hinge allora il nome del template da visualizzare è di una Mortise
AdviceHinge(NewCompo)
CompoList.Add(NewCompo)
End If
' evidenzio il nome della componente appena aggiunto
NewCompo.BorderColor = New BrushConverter().ConvertFrom("#DCDCDC")
NewCompo.BackGroundColor = New BrushConverter().ConvertFrom("#DCDCDC")
NewCompo.BorderThickness = 1
'-----------------------------------------------------------------------------------------------------------------------------------------------
BuiltReferenceCompo(NewCompo)
'-----------------------------------------------------------------------------------------------------------------------------------------------
End If
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
' riabilito la costruzione del riferimnto
Assembly.BuiltReffCompo = True
Return NewCompo
End Function
' ha lo scopo di generare una componente sul jamb
Private Sub BuiltReferenceCompo(NewCompo As Compo)
' questa parte viene ignorata se l'oggetto chiamante è un Frame
If Not IsNothing(Me.m_TypePart) AndAlso Not Me.m_TypePart.Contains(ConstGen.PART_FRAME) 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
' 50144 =Warning
' 50166 =Jamb compo does not exist
MessageBox.Show(EgtMsg(50166), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
Else
CreateRefCompo(NewCompo.CompoType, NewCompo, CurrAssembly, FrameCompoFileConfig, FrameCompoFile, Me)
End If
End If
End If
End If
End Sub
' crea la componente di riferimento
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 FrameFolderName As String = FOLDERDIR
Dim Side As String = String.Empty
Dim CurrCompoPath As String = FrameCompoFileConfig
If File.Exists(CurrCompoPath) Then
' Name=hinges/50074
GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, FrameCompoNameDDF, FrameCompoName, CurrCompoPath)
' FolderName = 50052
GetPrivateProfileFolderName(S_TEMPLATE, K_FOLDER_NAME, FrameFolderName, CurrCompoPath)
' Side = Hinge
GetPrivateProfileJambSide(S_POSITIONSIDE, K_SIDE, Side, CurrCompoType.Path & "\" & CONFIGINI_FILE_NAME)
' se non è stata trovata nessuna voce nel file di configurazione ( riferita alla posizione side)
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 = K_SIDE.ToLower 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, FrameFolderName)
' assegno alla componente sull'anta la sua posizione
NewCompo.CompoType.SetJambSide(Side)
Else
' se non trovo nessun riferimento per la posizione allora esco
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 SIDE_HINGE
If CurrAssembly.LeftJamb.Swing.Contains(ConstGen.LOCK) 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 SIDE_LOCK
If CurrAssembly.LeftJamb.Swing.Contains(ConstGen.LOCK) 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 SIDE_TOP
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case SIDE_BOTTOM
NewCompo.refJambCompo = CurrAssembly.BottomJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End Select
Case "2"
Select Case CurrCompoType.JambSide.ToLower
Case SIDE_HINGE
If CurrDoor.TypePart = ConstGen.PART_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 SIDE_LOCK
' significa che le componenrti stanno solo sulle porte
If CurrDoor.TypePart = ConstGen.PART_DO_ & "1" And Not CurrDoor.Swing.Contains(ConstGen.INACTIVE) Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(1).Door.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
ElseIf CurrDoor.TypePart = ConstGen.PART_DO_ & "2" And Not CurrDoor.Swing.Contains(ConstGen.INACTIVE) Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(0).Door.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case SIDE_TOP
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb, FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case SIDE_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 (Assembly)
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)
' 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)
'-----------------------------------------------------------------------------------------------------------------------------------
NewCompo.TemplateDDFName = DDFName
NewCompo.TemplateName = Name
LoadBrandFileList(NewCompo, True, FrameCompoFile)
'-----------------------------------------------------------------------------------------------------------------------------------
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
#End Region 'AddCompo
' 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
Private Function LoadBrandFileList(ByRef NewCompo As Compo, Optional IsFrame As Boolean = False, Optional FrameFile As String = Nothing) As Boolean
Dim CurrCompoType As CompoType = NewCompo.CompoType
Dim CurrFolderList As ObservableCollection(Of CompoBrandDir)
If IsFrame Then
CurrFolderList = CurrCompoType.FrameFolderList
' devo dividere il nome che arriva dal matching lua
NewCompo.SetTemplateSelItemRefCompo(FrameFile, NewCompo)
Return True
Else
CurrFolderList = CurrCompoType.FolderList
End If
If CurrFolderList.Count > 0 Then
For IndexModel As Integer = 0 To CurrFolderList.Count - 1
NewCompo.BrandListPart.Add(CurrFolderList(IndexModel).ModelDirGraphic)
Next
For CompoIndex = m_CompoList.Count - 1 To 0 Step -1
If m_CompoList(CompoIndex).CompoType.Name = CurrCompoType.Name Then
NewCompo.SetSelBrand(m_CompoList(CompoIndex).SelBrandPart)
NewCompo.SelFile = m_CompoList(CompoIndex).SelFile
Return True
End If
Next
' Prendo il primo direttorio
For IndexFile As Integer = 0 To CurrFolderList(0).ModelFileList.Count - 1
NewCompo.FileList.Add(CurrFolderList(0).ModelFileList(IndexFile))
Next
NewCompo.SetSelBrand(NewCompo.BrandListPart(0))
' Carico il primo modello della lista
Dim SelItemIndex As Integer = 0
While SelItemIndex < NewCompo.FileList.Count - 1 AndAlso Path.HasExtension(NewCompo.FileList(SelItemIndex))
SelItemIndex += 1
End While
If SelItemIndex < NewCompo.FileList.Count Then
NewCompo.SetSelFile(NewCompo.FileList(SelItemIndex))
Else
NewCompo.SetSelFile(String.Empty)
End If
Else
Return False
End If
Return True
End Function
' ricerca seleziona la prima hinge di tipo Mortise
Private Sub AdviceHinge(NewCompo As Compo)
Dim SelBrand As String = String.Empty
Dim SelFile As String = String.Empty
DefaultGetPrivateProfileString("AdviceHinge", "Brand", "", SelBrand)
DefaultGetPrivateProfileString("AdviceHinge", "File", "", SelFile)
If Not String.IsNullOrEmpty(SelBrand) And Not String.IsNullOrEmpty(SelFile) Then
For IndexFolder As Integer = 0 To NewCompo.CompoType.FolderList.Count - 1
If Trim(SelBrand) = NewCompo.CompoType.FolderList(IndexFolder).ModelDirGraphic Then
For IndexFile As Integer = 0 To NewCompo.CompoType.FolderList(IndexFolder).ModelFileList.Count - 1
If Trim(SelFile) = NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile) Then
NewCompo.SetSelBrand(NewCompo.CompoType.FolderList(IndexFolder).ModelDirGraphic)
NewCompo.SetSelFile(NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile))
Return
End If
Next
End If
Next
End If
Dim ChangeHardware As Boolean = False
If NewCompo.CompoType.DDFName = "hinges" Then
' entro nel primo brand (direttorio)
For IndexFolder As Integer = 0 To NewCompo.CompoType.FolderList.Count - 1
' carico il primo file
For IndexFile As Integer = 0 To NewCompo.CompoType.FolderList(IndexFolder).ModelFileList.Count - 1
' ogni volta che inizio la lettura di un nuovo file resetto la variabile
ChangeHardware = False
Dim LocalFile As String = NewCompo.CompoType.FolderList(IndexFolder).ModelDir & "\" & NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile) & LUA_EXTENSION
If Not File.Exists(LocalFile) Then Return
Dim FileContent() As String = File.ReadAllLines(LocalFile)
For IndexLine As Integer = 0 To FileContent.Count - 1
' se il file lua contiene il numero di parametro 2
If FileContent(IndexLine).Contains("--") And FileContent(IndexLine).Contains("[Graphic parameters]") Then
For SubIndex As Integer = IndexLine + 1 To FileContent.Count - 1
If FileContent(SubIndex).Contains("--") And FileContent(SubIndex).Contains("Default") Then
Dim Items() As String = FileContent(SubIndex).Split("="c)
If Not IsNothing(Items(1)) And Trim(Items(1)) = "2" Then
ChangeHardware = True
Exit For
End If
End If
Next
End If
' termino la lettura del file corrente
Next
' prima di passare al file successivo
' se ho trovato il parametro Deafult= 2
If ChangeHardware Then
'termino la lettura del file
Exit For
Else
NewCompo.SetSelBrand(NewCompo.CompoType.FolderList(IndexFolder).ModelDirGraphic)
NewCompo.SetSelFile(NewCompo.CompoType.FolderList(IndexFolder).ModelFileList(IndexFile))
DefaultWritePrivateProfileString("AdviceHinge", "Brand", NewCompo.SelBrandPart)
DefaultWritePrivateProfileString("AdviceHinge", "File", NewCompo.SelFile)
Return
End If
' passo al Direttorio succesivo
Next
Next
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)
Dim bPressure As Boolean = False
' tutti i parametri fino a profiles devono essere caricati
Dim ReadDoorCompleted As Boolean = False
' passo alla pagina vuota in attesa del caricamneto della prossima
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
' Inizializzazioni
ReadDoor.FileContent = ArrayFile
ReadDoor.m_TypePart = ConstGen.PART_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)
bPressure = True
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 ConstCompo.S_PROFILES
LineIndex = ReadDoor.GetProfiles(ReadDoor.NextIndex(LineIndex), ReadDoor.TypePart)
If LineIndex = -1 Then
sErrorInfo &= String.Format(EgtMsg(50102), ConstCompo.S_PROFILES) & vbCrLf
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
ReadDoorCompleted = True
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
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
Else
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage
End If
' controllo che i parametri della porta siano stati caricati correttamente
If Not ReadDoorCompleted Then
sErrorInfo = EgtMsg(50156)
ReadDoor = Nothing
End If
' Aggiorno
If Not IsNothing(ReadDoor) And ReadDoorCompleted Then
' se la porta esiste allora mostro i suoi parametri
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
' 50169 =Door dispositiopn has been modify.
MessageBox.Show(EgtMsg(50169), 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)
' quando non passa dalla funzione GetWeight (perchè il ddf non ha il peso)
Else
If Not bPressure Then
If m_IsCheckedWeight = Visibility.Visible Then
' ACCESO e NON presenet nel ddf
If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' decido di spegnere
OptionsVM.SetIsCheckedWeight(False)
Else
' decido di accendere
OptionsVM.SetIsCheckedWeight(True)
ReadDoor.m_Weight = OptionModule.m_Weight
ReadDoor.VisibilityWeight = Visibility.Visible
Part.FirstReadingEdge = True
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 (opzionale)
If Index > FileContent.Count() - 1 Then Return -1
If SearchKey(RemoveComment(FileContent(Index)), K_PROJECT) Then
Dim Project As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PROJECT)
If Not String.IsNullOrWhiteSpace(Project) Then m_Project = Project
Index = NextIndex(Index)
End If
' Recupero dati PO (purchase order)(opzionale)
If Index > FileContent.Count() - 1 Then Return -1
If SearchKey(RemoveComment(FileContent(Index)), K_PO) Then
Dim PO As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_PO)
If Not String.IsNullOrWhiteSpace(PO) Then m_PO = PO
Index = NextIndex(Index)
ElseIf SearchKey(RemoveComment(FileContent(Index)), K_ORDER) Then
Dim Order As String = GetValueWithKey(RemoveComment(FileContent(Index)), K_ORDER)
If Not String.IsNullOrWhiteSpace(Order) Then m_PO = Order
Index = NextIndex(Index)
End If
' 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
'50141=Invalid expression in {0}.
'50159= Missing parameter in ddf!
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_WIDTH_INI) & EgtMsg(50159), 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
' 50141 =Invalid expression in {0}.
' 50159 = Missing parameter in ddf!
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_HEIGHT_INI) & EgtMsg(50159), 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
' 50141 =Invalid expression in {0}.
' 50159 = Missing parameter in ddf!
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_THICKNESS_INI) & EgtMsg(50159), 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)
Dim bPressureIsInDDF As Boolean = False
' inizio eseguendo la lettura della stringa del ddf
' se la stringa contiene il MESSAGGIO Pressure
If SearchKey(sLine, S_WEIGHT) Then
bPressureIsInDDF = True
' allora passo alla lettura del VALORE Pressure
Weight = GetValueWithKey(sLine, S_WEIGHT)
If String.IsNullOrWhiteSpace(Weight) Then
' cairco di default il VALORE
m_Weight = OptionModule.m_Weight
' ? inserisco un messaggio o una avvenuta modifica ?
Else
' caricol il VALORE
m_Weight = Weight
End If
End If
' eseguo il confronto con le impostanzioni della option page
' nella option page è ACCESSO ma NON è presnte nel ddf
If m_IsCheckedWeight = Visibility.Visible And Not bPressureIsInDDF Then
' Weight is setted in OptionPage. Do you want to remove?
If MessageBox.Show(EgtMsg(50149), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' SPENTO
OptionsVM.SetIsCheckedWeight(False)
Else
OptionsVM.SetIsCheckedWeight(True)
m_Weight = OptionModule.m_Weight
VisibilityWeight = Visibility.Visible
' notifico una avvenuta modifica
Part.FirstReadingEdge = True
End If
End If
' nella option page è SPENTO ma è presnte nel ddf
If m_IsCheckedWeight = Visibility.Collapsed And bPressureIsInDDF Then
If MessageBox.Show(EgtMsg(50150), EgtMsg(50110), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) = MessageBoxResult.Yes Then
' ACCESO
OptionsVM.SetIsCheckedWeight(True)
Else
OptionsVM.SetIsCheckedWeight(False)
VisibilityWeight = Visibility.Collapsed
' notifico una avvenuta modifica
Part.FirstReadingEdge = True
End If
End If
' passo alla riga successiva
Return NextIndex(Index)
End Function
' 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
' 50141 =Invalid expression in {0}.
' 50159 = Missing parameter in ddf!
MessageBox.Show(String.Format(EgtMsg(50141), ConstIni.K_SWING_INI) & EgtMsg(50159), 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
' 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(ConstGen.PART_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 = ConstGen.BEVEL_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 = ConstGen.BEVEL_GRAPHIC Then sBevelLock = m_LockEdgeType.BevelDDF
If m_HingeEdgeType.Name = ConstGen.BEVEL_GRAPHIC Then sBevelHinge = m_HingeEdgeType.BevelDDF
If m_TopType.Name = ConstGen.BEVEL_GRAPHIC Then sBevelTop = m_TopType.BevelDDF
If m_BottomType.Name = ConstGen.BEVEL_GRAPHIC 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 ConstGen.BEVEL_DOWN
SetDispositionItem(m_DispositionList(1))
' modifico il bevel da BU a BD
Modifybevel(Bevel, ConstGen.BEVEL_UP)
'OptionModule.m_bBevelDown = Visibility.Visible
'OptionModule.m_bBevelUp = Visibility.Collapsed
Case ConstGen.BEVEL_UP
SetDispositionItem(m_DispositionList(0))
Modifybevel(Bevel, ConstGen.BEVEL_DOWN)
' 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 = ConstGen.BEVEL_UP Then OptionModule.m_bBevelUp = Visibility.Visible
If Bevel = ConstGen.BEVEL_DOWN 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 = ConstGen.BEVEL_BYSWING))
bModifyBevel = True
Part.FirstReadingEdge = True
End Try
Else ' Bevel SQ
If m_Swing.Contains(ConstGen.HAND_REVERSE) Then
If m_Secure = ConstGen.SWING_UP Then
SetDispositionItem(m_DispositionList(0))
OptionModule.m_bBevelUp = Visibility.Visible
ElseIf m_Secure = ConstGen.SWING_DOWN Then
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
Else
m_Secure = ConstGen.SWING_DOWN
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
End If
Else
If m_Secure = ConstGen.SWING_UP Then
SetDispositionItem(m_DispositionList(1))
OptionModule.m_bBevelDown = Visibility.Visible
ElseIf m_Secure = ConstGen.SWING_DOWN Then
SetDispositionItem(m_DispositionList(0))
OptionModule.m_bBevelUp = Visibility.Visible
Else
m_Secure = ConstGen.SWING_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
If IsNothing(Map.refOptionsVM) Then
Dim OptionsPage As OptionsVM = Map.refMainWindowVM.OptionPage
refOptionsVM.RefreshEdgeTypeList()
End If
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) = ConstGen.BEVEL_UP Or Trim(LockEdgeType) = ConstGen.BEVEL_DOWN Then
Try
m_LockEdgeType = LockEdgeTypeList.First(Function(x) x.Name = ConstGen.BEVEL_GRAPHIC)
' 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) = ConstGen.BEVEL_UP Or Trim(HingeEdgeType) = ConstGen.BEVEL_DOWN Then
Try
m_HingeEdgeType = HingeEdgeTypeList.First(Function(x) x.Name = ConstGen.BEVEL_GRAPHIC)
' 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) = ConstGen.BEVEL_UP Or Trim(TopType) = ConstGen.BEVEL_DOWN Then
Try
m_TopType = TopEdgeTypeList.First(Function(x) x.Name = ConstGen.BEVEL_GRAPHIC)
' 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) = ConstGen.BEVEL_UP Or Trim(BottomType) = ConstGen.BEVEL_DOWN Then
Try
m_BottomType = BottomEdgeTypeList.First(Function(x) x.Name = ConstGen.BEVEL_GRAPHIC)
' 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 Map.refCompoPanelVM.CompoTypeList.Count() - 1
' eseguo il confronto con il nome dei componenti che è stato caricato dal file Default.ini
If Map.refCompoPanelVM.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
Part.FirstReadingEdge = True
' esco dalla lettura del compo
Exit While
End If
' Creo il componente
Dim m_CurrCompo = New Compo(Map.refCompoPanelVM.CompoTypeList(CompoListIndex))
Dim CurrCompoType As CompoType = m_CurrCompo.CompoType
' Se previsto template o shape da configurazione
Dim CurrCompoTypePath As String = Map.refCompoPanelVM.CompoTypeList(CompoListIndex).Path
Dim nIsActive As Integer = EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
If nIsActive = 1 Or
(nIsActive = 2 And sKey.StartsWith("- ")) 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
LoadBrandFileList(m_CurrCompo)
'-----------------------------------------------------------------------------------------------------------------------------------
' Se c'è "- " iniziale
If sKey.StartsWith("- ") Then
' se la chiave non è template o shape, segno file modificato per farlo salvare
If sKey.Remove(0, 2) <> DDFName Then
Part.FirstReadingEdge = True
m_CurrCompo.LoadByDefault = True
End If
' leggo il template effettivamente utilizzato
Dim sTemplate As String = GetValueWithoutKey(sLine)
sTemplate = sTemplate.Replace("/", "\")
Dim BrandDir As String = String.Empty
Dim sFile As String = String.Empty
Dim sItems() As String = sTemplate.Split("\"c)
Dim bFileExists As Boolean = False
Dim bBrandExists As Boolean = False
' ricerca nella radice della componente
If sItems.Count < 2 Then
bBrandExists = True
sFile = Trim(sItems(0))
m_CurrCompo.SelBrandPart = m_CurrCompo.BrandListPart.Last
For IndexFile As Integer = 0 To m_CurrCompo.FileList.Count - 1
If sFile.ToLower = m_CurrCompo.FileList(IndexFile).ToLower Then
m_CurrCompo.SelFile = m_CurrCompo.FileList(IndexFile)
bFileExists = True
Exit For
End If
Next
End If
' ricerca nei dierttori della radice
If sItems.Count >= 2 Then
BrandDir = Trim(sItems(0))
sFile = Trim(sItems(1))
For IndexSplit As Integer = 2 To sItems.Count - 1
sFile &= "\" & sItems(IndexSplit)
Next
For IndexBrand As Integer = 0 To m_CurrCompo.BrandListPart.Count - 1
If BrandDir.ToLower = m_CurrCompo.BrandListPart(IndexBrand).ToLower Then
m_CurrCompo.SelBrandPart = m_CurrCompo.BrandListPart(IndexBrand)
bBrandExists = True
Exit For
End If
Next
For IndexFile As Integer = 0 To m_CurrCompo.FileList.Count - 1
If sFile.ToLower = m_CurrCompo.FileList(IndexFile).ToLower Then
m_CurrCompo.SelFile = m_CurrCompo.FileList(IndexFile)
bFileExists = True
Exit For
End If
Next
End If
If Not bFileExists Or Not bBrandExists Then
' File {0} in directory {1} has not been found.
sErrorInfo &= String.Format(EgtMsg(50160), sFile, BrandDir) & vbCrLf
m_CurrCompo.LoadByDefault = True
Part.FirstReadingEdge = True
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
' Error in reading {0}: line {1}. Expected 'template' or 'shape'.
sErrorInfo &= String.Format(EgtMsg(50132), DDFName, Index + 1)
' {0} has not been created.
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
Else
' Se c'è "- " iniziale, errore
If sKey.StartsWith("- ") Then
' 50139 =Errore in lettura: riga {0}. Atteso {1}.
' 50161=parameter
sErrorInfo &= String.Format(EgtMsg(50139), Index + 1, EgtMsg(50161)) & vbCrLf
Return -1
End If
' 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
' salto tutti i suoi parametri
Index = NextIndex(Index)
SkipParams(Index)
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
' salto tutti i suoi parametri
Index = NextIndex(Index)
SkipParams(Index)
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 AndAlso Not TypeOf CurrCompoParam Is ComboBoxOnOffParam Then
' restituisco il messaggio che manca un parametro
' Error in reading: line {0}. Expected {1}.
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
' All missing params will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf
CompoTemplateItem.LoadByDefault = True
Else
' significa che la TextBoxOnOff è stata disattivata
If TypeOf CurrCompoParam Is TextBoxOnOffParam Then DirectCast(CurrCompoParam, TextBoxOnOffParam).SetIsActive(False)
If TypeOf CurrCompoParam Is ComboBoxOnOffParam Then DirectCast(CurrCompoParam, ComboBoxOnOffParam).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 ObservableCollection(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemList
' carico la lista dei valori DDF
Dim ListDDF As ObservableCollection(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 file 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
' Error in reading {0}: line {1}. It is not a member of the list.
sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine)
' This param will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
If String.IsNullOrEmpty(sVal) Then
Part.FirstReadingEdge = True
CompoTemplateItem.LoadByDefault = True
End If
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
CompoTemplateItem.LoadByDefault = True
End If
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
' Error in reading: line {0}. Expected {1}.
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
' This param will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
Part.FirstReadingEdge = True
CompoTemplateItem.LoadByDefault = True
' 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
' Error in reading: line {0}. Expected {1}.
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
' This param will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
Part.FirstReadingEdge = True
CompoTemplateItem.LoadByDefault = True
' 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
CompoTemplateItem.LoadByDefault = True
End If
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 ObservableCollection(Of String) = DirectCast(CurrCompoParam, ComboBoxOnOffParam).ItemList
Dim IndexListDDF As Integer = 0
' carico la lista dei valori DDF
Dim ListDDF As ObservableCollection(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
' Error in reading {0}: line {1}. It is not a member of the list.
sErrorInfo &= String.Format(EgtMsg(50137), sVal, IndexLine)
' This param will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50138)) & vbCrLf
If String.IsNullOrEmpty(sVal) Then
Part.FirstReadingEdge = True
CompoTemplateItem.LoadByDefault = True
End If
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
' Error in reading: line {0}. Expected {1}.
sErrorInfo &= String.Format(EgtMsg(50139), IndexLine + 1, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
' All missing params will be initialized by default.
sErrorInfo &= String.Format(Environment.NewLine & EgtMsg(50140)) & vbCrLf
CompoTemplateItem.LoadByDefault = True
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
' 50101 =Error
' 50170 =Incongruity between the bevel, it has been resolved by default.
MessageBox.Show(EgtMsg(50170), EgtMsg(50101), 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 = ConstGen.BEVEL_GRAPHIC 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) = ConstGen.SWING_UP Then
bModifyBevel = True
Part.FirstReadingEdge = True ' per mantere attivo l'asterisco di modifica
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
' utilizzata per generare la porta dell'Hardware
Sub New(Hardware As String)
Me.m_Width = OptionModule.m_Width
Me.m_Height = OptionModule.m_Height
Me.m_Thickness = OptionModule.m_Thickness
Me.m_Swing = OptionModule.m_Swing
Me.m_IsActive = True
Me.m_Measure = ConvertMmUnitsToString(OptionModule.m_bIsMmUnit)
Me.m_Weight = OptionModule.m_Weight
Me.SetLockEdgeType(New EdgeType(ConstGen.BEVEL_SQUARED, Visibility.Visible))
Me.SetHingeEdgeType(New EdgeType(ConstGen.BEVEL_SQUARED, Visibility.Visible))
Me.SetTopType(New EdgeType(ConstGen.BEVEL_SQUARED, Visibility.Visible))
Me.SetBottomType(New EdgeType(ConstGen.BEVEL_SQUARED, Visibility.Visible))
Me.m_LockEdgeMachining = OptionModule.m_LockEdgeMachining
Me.m_HingeEdgeMachining = OptionModule.m_HingeEdgeMachining
Me.m_TopMachining = OptionModule.m_TopMachining
Me.m_BottomMachining = OptionModule.m_BottomMachining
Me.m_LockEdgeOverMaterial = OptionModule.m_LockEdgeOverMaterial
Me.m_HingeEdgeOverMaterial = OptionModule.m_HingeEdgeOverMaterial
Me.m_TopOverMaterial = OptionModule.m_TopOverMaterial
Me.m_BottomOverMaterial = OptionModule.m_BottomOverMaterial
Me.SetDispositionItem(OptionModule.m_Disposition)
Me.TypePart = ConstGen.PART_DO_ & "1"
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