Files
EgtDOORCreator/DoorParameters/Part.vb
T
Dario Sassi e87fe6107f EgtDOORCreator :
- ulteriore revisione.
2017-11-28 21:49:49 +00:00

2113 lines
94 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Imports System.Text.RegularExpressions
Public Class Part
Implements INotifyPropertyChanged
Friend m_IsModifyDoor As Boolean = False
Friend Shared m_rfModifyTitle As Action(Of Boolean)
' '' restituisce vero/falso valutando se le componenti o le generals della porta sono state modificate
''Private Function IsModify() As Boolean
'' If m_IsModifyDoor Then Return True
'' ' se esiste almeno un elemento nella lista dei componenti
'' If Not IsNothing(Me.CompoList) Then
'' ' assegno ad una variabile locale il vallore della componente, e ripeto per tutte le componenti della lista
'' For IndexCompoList = 0 To Me.CompoList.Count - 1
'' Dim rCompo As Compo = Me.CompoList(IndexCompoList)
'' If Me.CompoList(IndexCompoList).IsModify Then
'' Return True
'' End If
'' Next
'' End If
'' Return False
''End Function
'Friend Sub SetTitle()
' m_rfModifyTitle(IsModify)
'End Sub
#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
'Private m_IsAssembly As Boolean = False
'Public Property IsAssembly As Boolean
' Get
' Return m_IsAssembly
' End Get
' Set(value As Boolean)
' m_IsAssembly = value
' End Set
'End Property
#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
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
#Region "Size"
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 = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
' 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()
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
' ricalcola la dimensione larghezza dei Jamb FT e FB
Map.refAssemblyPageVM.CurrAssembly.SetTopWidth()
Map.refAssemblyPageVM.CurrAssembly.UpDateAllCompo()
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
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
m_IsModifyDoor = True
End If
Return m_Weight
End Get
Set(value As String)
Dim dVal As Double
If StringToDouble(value, dVal) Then
m_Weight = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
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()
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_EdgeTypeList As New ObservableCollection(Of EdgeType)
Public Property EdgeTypeList As ObservableCollection(Of EdgeType)
Get
' restituisco il valore della lista che è stato creato all'avvio
Return m_EdgeTypeList
End Get
Set(value As ObservableCollection(Of EdgeType))
m_EdgeTypeList = value
Map.refAssemblyPageVM.CurrAssembly.NotifyPropertyChanged("EdgeTypeList")
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
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
End Set
End Property
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
Return m_HingeEdgeType
End Get
Set(value As EdgeType)
m_HingeEdgeType = value
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
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
End Set
End Property
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
End Set
End Property
#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
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
#End Region
#Region "OverMaterial"
Private m_LockEdgeOverMaterial As String = String.Empty
Public Property LockEdgeOverMaterial As String
Get
Return m_LockEdgeOverMaterial
End Get
Set(value As String)
Dim dVal As Double
If StringToDouble(value, dVal) Then
m_LockEdgeOverMaterial = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
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)
Dim dVal As Double
If StringToDouble(value, dVal) Then
m_HingeEdgeOverMaterial = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
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)
Dim dVal As Double
If StringToDouble(value, dVal) Then
m_TopOverMaterial = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
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)
Dim dVal As Double
If StringToDouble(value, dVal) Then
m_BottomOverMaterial = value
Else
MessageBox.Show(EgtMsg(50148), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Asterisk)
End If
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
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
' 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)
IniFile.OpenDirectory(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 qui viene ignorata se l'oggetto chiamente è 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
' definisco un riferimento ad una variabile che sarà usata nel jamb
Dim CompoTypeJamb As CompoType
' 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)
If CalcCompoMatching(NewCompo.CompoType.Path, nDoorNbr, NewCompo.TemplateSelItem, FrameCompoFile) AndAlso
Not String.IsNullOrEmpty(FrameCompoFile) Then
'------------------------------------------------------------------------------------------------------------------------------------------
If Not SearchFileConfig(FrameCompoFile, FrameCompoFileConfig) Then
MessageBox.Show("Compo does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
Else
' 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("PositionSide", "Side", Side, CurrCompoPath)
If String.IsNullOrEmpty(Side) Then Side = CurrCompoType.JambSide
Dim FrameCompoDirectory As String
FrameCompoDirectory = FrameCompoFileConfig.Remove(FrameCompoFileConfig.LastIndexOf("\"))
CompoTypeJamb = New CompoType(FrameCompoName, FrameCompoNameDDF, FrameCompoDirectory, Side)
Else
' se non trovo nulla nel direttorio indicato carico il direttorio della componente corrente
CompoTypeJamb = New CompoType(CurrCompoType.Name, CurrCompoType.DDFName, CurrCompoType.Path, CurrCompoType.JambSide)
End If
'------------------------------------------------------------------------------------------------------------------------------------------
Select Case CurrAssembly.DoorNumber
Case "1"
' questo select case serve per gestire la posizione degli hardware sui Jamb
Select Case CurrCompoType.JambSide
Case "Hinge"
If CurrAssembly.LeftJamb.Swing.Contains("L") Then
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "Lock"
If CurrAssembly.LeftJamb.Swing.Contains("L") Then
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "Top"
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case "Bottom"
NewCompo.refJambCompo = CurrAssembly.BottomJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End Select
Case "2"
Select Case CurrCompoType.JambSide
Case "Hinge"
If Me.TypePart = "DO_1" Then
NewCompo.refJambCompo = CurrAssembly.LeftJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Else
NewCompo.refJambCompo = CurrAssembly.RightJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "Lock"
' significa che le componenrti stanno solo sulle porte
If Me.TypePart = "DO_1" And Not Me.Swing.Contains("I") Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(1).Door.AddRefCompo(CurrCompoType)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
ElseIf Me.TypePart = "DO_2" And Not Me.Swing.Contains("I") Then
NewCompo.refJambCompo = CurrAssembly.GetArrayPartDoor(0).Door.AddRefCompo(CurrCompoType)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End If
Case "Top"
NewCompo.refJambCompo = CurrAssembly.TopJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
Case "Bottom"
NewCompo.refJambCompo = CurrAssembly.BottomJamb.AddRefCompo(CompoTypeJamb)
NewCompo.refJambCompo.SetTemplateSelItem(FrameCompoFile)
NewCompo.refJambCompo.IsReadOnly = True
End Select
End Select
End If
End If
End If
End If
'-----------------------------------------------------------------------------------------------------------------------------------------------
' 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
'm_IsModifyDoor = True
'SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
Return NewCompo
End Function
'Gestione ComboBox e TextBox di ogni compo della pulsantiera letta da Compo.ini
Public Function AddRefCompo(CurrCompoType As CompoType) 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)
IniFile.OpenDirectory(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
' 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
'm_IsModifyDoor = True
'SetTitle()
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
' 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"
' Genero una nuova porta da usare nella lettura di un DDF
Private FileContent As String()
'Shared Sub ReadDDF(sPathDDF As String, ByRef ReadDoor As Part)
' If Not Directory.Exists(IniFile.m_CompoDir) Then
' EgtOutLog("CompoDir not found : " & IniFile.m_CompoDir)
' MessageBox.Show("CompoDir not found : " & IniFile.m_CompoDir, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error)
' End
' Return
' End If
' ReadDoor.m_IsModifyDoor = False
' 'm_Door = ReadDoor
' ' restituisce un problema nella lettura di un valore della compo
' Dim InvalidValue As String = String.Empty
' ' controllo se esite il file DDF
' If Not File.Exists(sPathDDF) Then Return
' ReadDoor.FileContent = File.ReadAllLines(sPathDDF)
' ' se il file esiste ma è vuoto
' If ReadDoor.FileContent.Count = 0 Then
' MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
' End If
' Dim bSecure As Boolean = False
' ' leggo riga per riga
' For LineIndex As Integer = 0 To ReadDoor.FileContent.Count - 1
' ' pulisco dai commenti
' ' FileContent(LineIndex) = FindComments(FileContent(LineIndex))
' ' Leggo le unità di misura
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_MEASURES) Then
' LineIndex = ReadDoor.GetMeasure(LineIndex)
' ' se manca una parola chiave nel DDF
' If LineIndex = -1 Then
' ' carico il messaggio di errore
' InvalidValue += String.Format(EgtMsg(50102), K_MEASURES + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' ' interrompo la lettura del file
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' Leggo il codice
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_CODE) Then
' LineIndex = ReadDoor.GetCode(LineIndex)
' ' se manca una parola chiave nel DDF
' If LineIndex = -1 Then
' ' carico il messaggio di errore
' InvalidValue += String.Format(EgtMsg(50102), K_CODE + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' ' interrompo la lettura del file
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' Leggo il ordine
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), S_ORDER) Then
' LineIndex = ReadDoor.GetOrder(LineIndex + 1)
' ' se manca una parola chiave nel DDF
' If LineIndex = -1 Then
' ' carico il messaggio di errore
' InvalidValue += String.Format(EgtMsg(50102), S_ORDER + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' ' interrompo la lettura del file
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' Leggo la data
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_DATE) Then
' LineIndex = ReadDoor.GetDate(LineIndex)
' ' se manca una parola chiave nel DDF
' If LineIndex = -1 Then
' ' carico il messaggio di errore
' InvalidValue += String.Format(EgtMsg(50102), K_DATE + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' ' interrompo la lettura del file
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' size
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_SIZE) Then
' LineIndex = ReadDoor.GetSize(LineIndex + 1)
' ' se manca una parola chiave nel DDF
' If LineIndex = -1 Then
' ' carico il messaggio di errore
' InvalidValue += String.Format(EgtMsg(50102), K_SIZE + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' ' interrompo la lettura del file
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' leggo il peso della porta
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_WEIGHT) Then
' LineIndex = ReadDoor.GetWeight(LineIndex)
' If LineIndex = -1 Then
' InvalidValue += String.Format(EgtMsg(50102), K_WEIGHT + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' swing
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_SWING) Then
' LineIndex = ReadDoor.GetSwing(LineIndex)
' If LineIndex = -1 Then
' InvalidValue += String.Format(EgtMsg(50102), K_SWING + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' secure
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_SECURE) Then
' bSecure = True
' LineIndex += 1
' End If
' End If
' ' profiles
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' If SearchKey(ReadDoor.FileContent(LineIndex), K_PROFILES) Then
' LineIndex = ReadDoor.GetProfiles(LineIndex + 1, "")
' If LineIndex = -1 Then
' InvalidValue += String.Format(EgtMsg(50102), K_PROFILES + vbCrLf)
' ' assegno una porta vuota ed esco dal ciclo
' ReadDoor = Nothing
' Exit For
' End If
' End If
' Else
' Exit For
' End If
' ' Compo
' ' siccome dopo ogni lettura restituisco la riga successiva: controllo che veramente esiste nel file
' If LineIndex < ReadDoor.FileContent.Count - 1 Then
' ' se trovo un nome seguito dai due punti
' If Not String.IsNullOrWhiteSpace(ReadDoor.SearchName(ReadDoor.FileContent(LineIndex))) Then
' ' carivo la stringa letta come nome DDF
' Dim CompoNameDDF = ReadDoor.SearchName(ReadDoor.FileContent(LineIndex))
' ' passo la riga successiva e il nome DDF alla funzione che controlla se esiste la compo e restituisce la riga successiva
' LineIndex = ReadDoor.GetNewCompo(LineIndex + 1, CompoNameDDF, InvalidValue)
' ' se restituisco una riga scommentata ma non interpretabile
' ElseIf Not String.IsNullOrWhiteSpace(Utility.FindComments(ReadDoor.FileContent(LineIndex))) Then
' If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
' InvalidValue &= String.Format(EgtMsg(50130), LineIndex)
' End If
' Else
' Exit For
' End If
' Next
' ' quando finisce la lettura di tutte le righe esci dal ciclo
' If Not String.IsNullOrWhiteSpace(InvalidValue) Then
' MessageBox.Show(InvalidValue, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
' Else
' If Not bSecure Then
' DdfFile.WriteDDFPart(ReadDoor, sPathDDF, True, True)
' End If
' 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
Shared Sub ReadDDFPartDoor(ArrayFile() As String, ByRef LineIndex As Integer, ByRef ReadDoor As Part)
Dim InvalidValue As String = String.Empty
' controllo se esiste il file DDF
ReadDoor.FileContent = ArrayFile
' se il file esiste ma è vuoto
If ReadDoor.FileContent.Count = 0 Then
MessageBox.Show(EgtMsg(50107), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Dim CurrOrder As New OrderVM
Dim bSecure As Boolean = False
' leggo riga per riga
While LineIndex < ReadDoor.FileContent.Count - 1 OrElse Not Search3Score(ReadDoor.FileContent(LineIndex)) OrElse Not Search3Dots(ReadDoor.FileContent(LineIndex))
' leggo il produce
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), "produce") Then
LineIndex = ReadDoor.GetProduce(LineIndex)
' se manca una parola chiave nel DDF
End If
Else
Exit While
End If
' Leggo le unità di misura
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_MEASURES) Then
LineIndex = ReadDoor.GetMeasure(LineIndex)
' se manca una parola chiave nel DDF
If LineIndex = -1 Then
' carico il messaggio di errore
InvalidValue += String.Format(EgtMsg(50102), K_MEASURES + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
End If
Else
Exit While
End If
' Leggo il codice
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_CODE) Then
LineIndex = ReadDoor.GetCode(LineIndex)
' se manca una parola chiave nel DDF
If LineIndex = -1 Then
' carico il messaggio di errore
InvalidValue += String.Format(EgtMsg(50102), K_CODE + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
End If
Else
Exit While
End If
' Leggo l'ordine
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), S_ORDER) Then
LineIndex = ReadDoor.GetOrder(LineIndex + 1)
' se manca una parola chiave nel DDF
If LineIndex = -1 Then
' carico il messaggio di errore
InvalidValue += 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
End If
Else
Exit While
End If
' Leggo la data
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_DATE) Then
LineIndex = ReadDoor.GetDate(LineIndex)
' se manca una parola chiave nel DDF
If LineIndex = -1 Then
' carico il messaggio di errore
InvalidValue += String.Format(EgtMsg(50102), K_DATE + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
End If
Else
Exit While
End If
' piece (Non necessario, quinidi se viene trovato salta alla riga successiva)
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), "piece") Then
LineIndex = ReadDoor.GetPiece(LineIndex)
LineIndex += 1
End If
End If
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), "position") Then
LineIndex = ReadDoor.GetPoint(LineIndex + 1)
End If
End If
' size
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_SIZE) Then
LineIndex = ReadDoor.GetSize(LineIndex + 1)
' se manca una parola chiave nel DDF
If LineIndex = -1 Then
' carico il messaggio di errore
InvalidValue += String.Format(EgtMsg(50102), K_SIZE + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
' interrompo la lettura del file
Exit While
End If
End If
Else
Exit While
End If
' leggo il peso della porta
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_WEIGHT) Then
LineIndex = ReadDoor.GetWeight(LineIndex)
If LineIndex = -1 Then
InvalidValue += String.Format(EgtMsg(50102), K_WEIGHT + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
End If
Else
Exit While
End If
' swing
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_SWING) Then
LineIndex = ReadDoor.GetSwing(LineIndex)
If LineIndex = -1 Then
InvalidValue += String.Format(EgtMsg(50102), K_SWING + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
End If
Else
Exit While
End If
' secure
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_SECURE) Then
bSecure = True
LineIndex += 1
End If
End If
' profiles
If LineIndex < ReadDoor.FileContent.Count - 1 Then
If SearchKey(ReadDoor.FileContent(LineIndex), K_PROFILES) Then
LineIndex = ReadDoor.GetProfiles(LineIndex + 1, ReadDoor.TypePart)
If LineIndex = -1 Then
InvalidValue += String.Format(EgtMsg(50102), K_PROFILES + vbCrLf)
' assegno una porta vuota ed esco dal ciclo
ReadDoor = Nothing
Exit While
End If
End If
Else
Exit While
End If
' Compo
' siccome dopo ogni lettura restituisco la riga successiva: controllo che veramente esiste nel file
If LineIndex < ReadDoor.FileContent.Count - 1 Then
' se trovo un nome seguito dai due punti
If Not String.IsNullOrWhiteSpace(ReadDoor.SearchName(ReadDoor.FileContent(LineIndex))) Then
' carivo la stringa letta come nome DDF
Dim CompoNameDDF = ReadDoor.SearchName(ReadDoor.FileContent(LineIndex))
' passo la riga successiva e il nome DDF alla funzione che controlla se esiste la compo e restituisce la riga successiva
LineIndex = ReadDoor.GetNewCompo(LineIndex + 1, CompoNameDDF, InvalidValue)
' se restituisco una riga scommentata ma non interpretabile
ElseIf Not String.IsNullOrWhiteSpace(Utility.FindComments(ReadDoor.FileContent(LineIndex))) Then
' interrompi la lettura quando arrivia ad altri trattini o a ai tre punti
If Search3Score(ReadDoor.FileContent(LineIndex)) Then
Exit While
End If
If Search3Dots(ReadDoor.FileContent(LineIndex)) Then
Exit While
End If
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50130), LineIndex)
End If
Else
Exit While
End If
' interrompi la lettura quando arrivia ad altri trattini o a ai tre punti
If LineIndex > ReadDoor.FileContent.Count - 1 OrElse Search3Score(ReadDoor.FileContent(LineIndex)) Then
Exit While
End If
If LineIndex > ReadDoor.FileContent.Count - 1 OrElse Search3Dots(ReadDoor.FileContent(LineIndex)) Then
Exit While
End If
LineIndex += 1
If LineIndex > ReadDoor.FileContent.Count - 1 Then Exit While
End While
' quando finisce la lettura di tutte le righe esci dal ciclo
' se la stringa dei messaggi contiene delle informazioni allora stampa
If Not String.IsNullOrWhiteSpace(InvalidValue) Then
MessageBox.Show(InvalidValue, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Else
'' se non è stata trovata nessun Secure allora aggiorno subito il file
'If Not bSecure Then
' DdfFile.WriteDDF(ReadDoor, sPathDDF, True)
'End If
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
' restituisce il valore della stringa che precede i due punti
Friend Function SearchName(sLine As String) As String
'Dim x As String = Regex.Match(FindComments(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value
Return Regex.Match(FindComments(sLine), "\s*(.*?\b)\s*:.*").Groups(1).Value
End Function
' restituisce il trattino
Friend Function Score(sLine As String) As String
Return Regex.Match(FindComments(sLine), "\s*(-)*\s*(.*?\b)\s*:.*").Groups(1).Value
End Function
' Cerca la stringa con il trattino
Friend Function SearchScore(sLine As String) As Boolean
If Regex.Match(FindComments(sLine), "\s*(-).*$").Groups(1).Value = "-" Then Return True
Return False
End Function
' restituisce il nome compreso tra il trattino meno e i due punti
Friend Function SearchTemplate(sLine As String) As String
Return Regex.Match(FindComments(sLine), "\s*-*\s*(.*?\b)\s*:.*$").Groups(1).Value
End Function
#Region "Carica il General della porta"
' Leggo il frame
Public Function GetProduce(Index As Integer) As Integer
Dim sProduce As String = SearchKeyValue(FileContent(Index), "produce")
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(sProduce) Then
' assegno la riga successiva
m_IsActive = True
Index += 1
Else
m_IsActive = CBool(sProduce)
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' Leggo l'unità di misura
Public Function GetMeasure(Index As Integer) As Integer
Dim Measure As String = SearchKeyValue(FileContent(Index), K_MEASURES)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Measure) Then
' assegno la riga successiva
Index += 1
' assegna il valore di default caricato nell'OptionModule
If String.Equals(Trim(UnitMeasure), "0") Then
' converto il valore intero del file config.ini in stringa
m_Measure = "inches"
Else
m_Measure = "mm"
End If
Else
' carico il valore nella porta corrente
m_Measure = Measure
' passo alla riga successiva
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' Leggo il codice
Public Function GetCode(Index As Integer) As Integer
Dim Code As String = SearchKeyValue(FileContent(Index), K_CODE)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Code) Then
' assegno la riga successiva
Index += 1
' assegna il valore di default caricato nell'OptionModule
m_Code = "124-AA-657"
Else
m_Code = Code
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' Leggo valori di Order
Public Function GetOrder(ByRef Index As Integer) As Integer
Dim ExitOrder As Integer = 0
Dim Customer As String = SearchKeyValue(FileContent(Index), K_CUSTOMER)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Customer) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(FileContent(Index), K_CUSTOMER) Then ExitOrder = -1
' altrimenti lascia il valore vuoto
Index += 1
Else
' carico il valore nella porta corrente
m_Customer = Customer
' passo alla riga successiva
Index += 1
End If
Dim Elevation As String = SearchKeyValue(FileContent(Index), K_ELEVATION)
If String.IsNullOrWhiteSpace(Elevation) Then
If Not SearchKey(FileContent(Index), K_ELEVATION) Then ExitOrder = -1
Index += 1
Else
m_Elevation = Elevation
Index += 1
End If
Dim Project As String = SearchKeyValue(FileContent(Index), K_PROJECT)
If String.IsNullOrWhiteSpace(Project) Then
If Not SearchKey(FileContent(Index), K_PROJECT) Then ExitOrder = -1
Index += 1
Else
m_Project = Project
Index += 1
End If
Dim PO As String = SearchKeyValue(FileContent(Index), K_PO)
If String.IsNullOrWhiteSpace(PO) Then
If Not SearchKey(FileContent(Index), K_PO) Then ExitOrder = -1
Index += 1
Else
m_PO = PO
Index += 1
End If
Dim Line As String = SearchKeyValue(FileContent(Index), K_LINE)
If String.IsNullOrWhiteSpace(Line) Then
If Not SearchKey(FileContent(Index), K_LINE) Then ExitOrder = -1
Index += 1
Else
m_Line = Line
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return SkipOrder(FileContent, Index, ExitOrder)
End Function
Private Function SkipOrder(Array() As String, ByRef Index As Integer, ExitOrder As Integer) As Integer
' se trovo un problema nella lettura dell'ordine allora la funzione GetOrder restituisce -1
If ExitOrder = -1 Then
' cerco la data
While Not SearchName(Array(Index)) = "date"
Index += 1
End While
End If
' riparto quindi dalla data
Return Index
End Function
' Leggo il piece
Public Function GetPiece(Index As Integer) As Integer
Dim sType As String = SearchKeyValue(FileContent(Index), "piece")
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(sType) Then
' assegno la riga successiva
Index += 1
Else
m_TypePart = sType
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
Public Function GetPoint(Index As Integer) As Integer
Dim X As String = SearchKeyValue(FileContent(Index), "x")
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(X) Then
' se non c'è la parola chiave allora esci
If SearchKey(FileContent(Index), "x") Then
Index += 1
End If
Else
Index += 1
End If
Dim Y As String = SearchKeyValue(FileContent(Index), "y")
If String.IsNullOrWhiteSpace(Y) Then
If SearchKey(FileContent(Index), "y") Then
Index += 1
End If
Else
Index += 1
End If
Dim Z As String = SearchKeyValue(FileContent(Index), "z")
If String.IsNullOrWhiteSpace(Z) Then
If SearchKey(FileContent(Index), "z") Then
Index += 1
End If
Else
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' Leggo il codice
Public Function GetDate(Index As Integer) As Integer
Dim sDate As String = SearchKeyValue(FileContent(Index), K_DATE)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(sDate) Then
' assegno la riga successiva
Index += 1
' assegna il valore di default caricato nell'OptionModule
m_Date = System.DateTime.Now.ToString("dd/MM/yyyy")
Else
m_Date = sDate
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' carico valori di Size
Public Function GetSize(Index As Integer) As Integer
Dim Width As String = SearchKeyValue(FileContent(Index), K_WIDTH)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Width) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(FileContent(Index), K_WIDTH) Then Return -1
' altrimenti lascia il valore vuoto
Index += 1
Else
' carico il valore nella porta corrente
m_Width = Width
' passo alla riga successiva
Index += 1
End If
Dim Height As String = SearchKeyValue(FileContent(Index), K_HEIGHT)
If String.IsNullOrWhiteSpace(Height) Then
If Not SearchKey(FileContent(Index), K_HEIGHT) Then Return -1
Index += 1
Else
m_Height = Height
Index += 1
End If
Dim Thickness As String = SearchKeyValue(FileContent(Index), K_THICKNESS)
If String.IsNullOrWhiteSpace(Thickness) Then
If Not SearchKey(FileContent(Index), K_THICKNESS) Then Return -1
Index += 1
Else
m_Thickness = Thickness
SetVarSize()
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' carico il valore del peso
Public Function GetWeight(Index As Integer) As Integer
' se sono arrivato fino a qui significa che è stato scritto nel ddf
Dim Weight As String = SearchKeyValue(FileContent(Index), K_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(FileContent(Index), K_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
' se 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
' se il valore esiste Weight
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
Index += 1
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' carico valori swing
Public Function GetSwing(Index As Integer) As Integer
Dim Swing As String = SearchKeyValue(FileContent(Index), K_SWING)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(Swing) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(FileContent(Index), K_SWING) Then Return -1
' altrimenti lascia il valore vuoto
Index += 1
Else
' carico il valore nella porta corrente
m_Swing = Swing
' passo alla riga successiva
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
' carico valori profiles
Public Function GetProfiles(Index As Integer, TypePart As String) As Integer
' Creo una stringa per scrivere gli errori
Dim bError As Boolean = False
' Lock
Dim LockEdgeType As String = SearchKeyValue(FileContent(Index), K_LOCKEDGE)
' se il valore restituito è nullo o vuoto
If String.IsNullOrWhiteSpace(LockEdgeType) Then
' se non c'è la parola chiave allora esci
If Not SearchKey(FileContent(Index), K_LOCKEDGE) Then
' restituisco il valore -1
Return -1
Else
m_LockEdgeType = m_EdgeTypeList(0)
End If
Index += 1
Else
' controllo che il valore sia nella lista
If EdgeTypeControl(LockEdgeType) Then
' carico il valore nella porta corrente
m_LockEdgeType = EdgeTypeList.First(Function(x) x.Name = LockEdgeType)
' restituisco la riga successiva all'ultimo valore letto
Else
m_LockEdgeType = EdgeTypeList(0)
bError = True
End If
Index += 1
End If
Dim LockEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
If String.IsNullOrWhiteSpace(LockEdgeMachining) Then
If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
Index += 1
Else
m_LockEdgeMachining = Utility.ConvertOnOffToBoolean(LockEdgeMachining)
Index += 1
End If
Dim LockEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(LockEdgeOverMaterial) Then
If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1
Index += 1
Else
m_LockEdgeOverMaterial = LockEdgeOverMaterial
Index += 1
End If
' Hinge
Dim HingeEdgeType As String = SearchKeyValue(FileContent(Index), K_HINGEEDGE)
If String.IsNullOrWhiteSpace(HingeEdgeType) Then
If Not SearchKey(FileContent(Index), K_HINGEEDGE) Then
Return -1
Else
m_HingeEdgeType = m_EdgeTypeList(0)
End If
Index += 1
Else
If EdgeTypeControl(HingeEdgeType) Then
m_HingeEdgeType = EdgeTypeList.First(Function(x) x.Name = HingeEdgeType)
Else
m_HingeEdgeType = m_EdgeTypeList(0)
bError = True
End If
Index += 1
End If
Dim HingeEdgeMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
If String.IsNullOrWhiteSpace(HingeEdgeMachining) Then
If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
Index += 1
Else
m_HingeEdgeMachining = ConvertOnOffToBoolean(HingeEdgeMachining)
Index += 1
End If
Dim HingeEdgeOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(HingeEdgeOverMaterial) Then
If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1
Index += 1
Else
m_HingeEdgeOverMaterial = HingeEdgeOverMaterial
Index += 1
End If
' Top
Dim TopType As String = SearchKeyValue(FileContent(Index), K_TOP)
If String.IsNullOrWhiteSpace(TopType) Then
If Not SearchKey(FileContent(Index), K_TOP) Then Return -1
Index += 1
Else
If EdgeTypeControl(TopType) Then
m_TopType = EdgeTypeList.First(Function(x) x.Name = TopType)
Else
m_TopType = m_EdgeTypeList(0)
bError = True
End If
Index += 1
End If
Dim TopMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
If String.IsNullOrWhiteSpace(TopMachining) Then
If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
Index += 1
Else
m_TopMachining = ConvertOnOffToBoolean(TopMachining)
Index += 1
End If
Dim TopOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(TopOverMaterial) Then
If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1
Index += 1
Else
m_TopOverMaterial = TopOverMaterial
Index += 1
End If
' Bottom
Dim BottomType As String = SearchKeyValue(FileContent(Index), K_BOTTOM)
If String.IsNullOrWhiteSpace(BottomType) Then
If Not SearchKey(FileContent(Index), K_BOTTOM) Then Return -1
Index += 1
Else
If EdgeTypeControl(BottomType) Then
m_BottomType = EdgeTypeList.First(Function(x) x.Name = BottomType)
Else
m_BottomType = m_EdgeTypeList(0)
bError = True
End If
Index += 1
End If
Dim BottomMachining As String = SearchKeyValue(FileContent(Index), K_MACHINING)
If String.IsNullOrWhiteSpace(BottomMachining) Then
If Not SearchKey(FileContent(Index), K_MACHINING) Then Return -1
Index += 1
Else
m_BottomMachining = ConvertOnOffToBoolean(BottomMachining)
Index += 1
End If
Dim BottomOverMaterial As String = SearchKeyValue(FileContent(Index), K_OVERMATERIAL)
If String.IsNullOrWhiteSpace(BottomOverMaterial) Then
If Not SearchKey(FileContent(Index), K_OVERMATERIAL) Then Return -1
Index += 1
Else
m_BottomOverMaterial = BottomOverMaterial
Index += 1
End If
' restituisco la riga successiva all'ultimo valore letto
Return Index
End Function
#End Region ' Carica il General della porta
' questa variabile è stata definita condovisa per permettere di essere inizializzata alla prima lettura del DDF
Public Shared FirstReadingEdge As Boolean = False
' controllo che i valori passati come spigoli siano presenti nella lista corrente (lettura DDF)
Public Function EdgeTypeControl(Edge As String) As Boolean
Dim bFound As Boolean = False
For Index = 0 To EdgeTypeList.Count - 1
If Part.m_EdgeTypeList(Index).Name = Edge And Part.m_EdgeTypeList(Index).IsActive = Visibility.Collapsed Then
bFound = True
End If
Next
If bFound And Not FirstReadingEdge Then
Dim CautionBevel As String = String.Format(EgtMsg(50151), Edge)
MessageBox.Show(CautionBevel, EgtMsg(50115), MessageBoxButton.OK, MessageBoxImage.Asterisk)
FirstReadingEdge = True
Return False
Else
Return True
End If
End Function
' ricerco la compo nella lista dei compobtn
Public Function GetNewCompo(Index As Integer, CompoNameDDF As String, ByRef InvalidValue As String) As Integer
Dim bDDFName As Boolean = False
Dim bCompo As Boolean = False
' controllo che il nome passato esiste nella lista delle componenti
Dim CompoListIndex As Integer
' se la stringa ha un trattino ipotizzo che il nome della componente sia lo stesso dell'ultima componente inserita
If Not String.IsNullOrWhiteSpace(Score(FileContent(Index - 1))) Then
If m_CompoList.Count > 0 Then
CompoNameDDF = m_CompoList.Last.CompoType.DDFName
Index -= 1
Else
Index -= 1
Return Index
End If
End If
For CompoListIndex = 0 To CompoPanelVM.CompoTypeList.Count() - 1
' eseguo il confronto con il nome delle componenti che è stato acricato nel file Default.ini
If CompoPanelVM.CompoTypeList(CompoListIndex).DDFName = CompoNameDDF Then
' se il nome esiste
bDDFName = True
' passo alla lettura delle righe successive (quindi a quella passata nella funzione)
While Index < FileContent.Count - 1 AndAlso Not Search3Score(FileContent(Index)) AndAlso Not Search3Dots(FileContent(Index)) AndAlso Not String.IsNullOrWhiteSpace(FindComments(FileContent(Index)))
' cerco il nome
' controllo che la stringa abbia i due punti: se non ha i due punti
If String.IsNullOrWhiteSpace(SearchName(FileContent(Index))) Then
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50131), CompoNameDDF, Index - 1)
InvalidValue &= Environment.NewLine & CompoNameDDF & " has not been created."
' esco dalla lettura della compo
Exit While
' se ha il trattino
Else
' creo la nuova componente
Dim m_CurrCompo = New Compo(CompoPanelVM.CompoTypeList(CompoListIndex), Me)
' Leggo il file ini del componente per vedere se c'è il template: se c'è
Dim CurrCompoTypePath As String = CompoPanelVM.CompoTypeList(CompoListIndex).Path
If EgtUILib.GetPrivateProfileInt(S_TEMPLATE, K_ISACTIVE, 1, CurrCompoTypePath & "\" & 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, CurrCompoTypePath & "\" & CONFIGINI_FILE_NAME)
' creo la lista dei templati della compnente
Dim TemplateList As New List(Of String)
' che carico con i nome delle directory contenute nella directory principale (quella che contiene il file Config.ini)
IniFile.OpenDirectory(CompoPanelVM.CompoTypeList(CompoListIndex).Path, TemplateList)
' aggiungo il template come parametro (è un parametro particolare, quindi esiste separatamente)
m_CurrCompo.TemplateDDFName = DDFName
m_CurrCompo.TemplateName = Name
m_CurrCompo.TemplateItemList = TemplateList
' cercco trattino "-": se lo trovo
If SearchScore(FileContent(Index)) Then
' leggo il valore del template e lo assegno alla componente che sto generando
' attenzione: devo passare anche il nome del parametro da cercare; per ora posso avere "template" o "shape" come parola chiave
m_CurrCompo.SetTemplateSelItem(SearchKeyValue(FileContent(Index), SearchTemplate(FileContent(Index))))
' se il template non ha nessun nome
If String.IsNullOrWhiteSpace(m_CurrCompo.TemplateSelItem) Then
' elimina la compo che stai creando
m_CurrCompo = Nothing
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format("Template in line {0} does not exist", Index - 1)
' ed esci dal ciclo while
Exit While
End If
'mi sposto nella riga successiva
Index += 1
' leggo i parametri della componente
ReadParam(m_CurrCompo, InvalidValue, Index)
' se creo la componente allora assegno vero
bCompo = True
Else
' restituisco la riga precedente alla funzione ReadDDF
Index -= 1
' se non ha il trattino (ma ha un template) esci dal ciclo
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50132), DDFName, Index - 1)
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
Exit While
End If
' la 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
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50134), CurrCompoTypePath, CONFIGINI_FILE_NAME)
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
m_CurrCompo = Nothing
ElseIf Not File.Exists(CurrCompoTypePath & "\" & sTemplateName & ".lua") Then
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50135), CurrCompoTypePath, CONFIGINI_FILE_NAME, sTemplateName)
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
Else
' assegno il nome del tipo di componente
'm_CurrCompo.TemplateSelItem = sTemplateName
m_CurrCompo.SetTemplateSelItem(sTemplateName)
ReadParam(m_CurrCompo, InvalidValue, Index)
' se creo la compo allora assegno vero
bCompo = True
End If
End If
m_CompoList.Add(m_CurrCompo)
'------------------------------------------------------------------------------------------------------------------------------------------------------
' qui leggo se esite un dato di tipo "##IdCodeComponent : 12
If Index < FileContent.Count - 1 AndAlso SearchName(FileContent(Index)) = "IdCodeComponent" Then
Dim IdCode As String = String.Empty
IdCode = SearchKeyValue(Regex.Match(FileContent(Index), "\s*##\s*(.*?\b)\s*$").Groups(1).Value, "IdCodeComponent")
If Not String.IsNullOrEmpty(IdCode) Then
' ho trovato il riferimento
m_CurrCompo.IdCode = IdCode
End If
Index += 1
End If
'------------------------------------------------------------------------------------------------------------------------------------------------------
End If
' se la stringa non ha i due punti
End While
Exit For
End If
Next
If Not bDDFName Then
' la componente none esiste
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50136), CompoNameDDF, Index - 1)
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50133), CompoNameDDF)
Index -= 1
End If
Return Index
End Function
' leggo i parametri della componente
Sub ReadParam(ByRef CompoTemplateItem As Compo, ByRef InvalidValue As String, ByRef IndexLine As Integer)
' questo è l'indice dei parametri della componente
Dim IndexParam As Integer
For IndexParam = 0 To CompoTemplateItem.CompoParamList.Count - 1
' carico la lista dei parametri della componente
Dim CurrCompoParam As CompoParam = CompoTemplateItem.CompoParamList(IndexParam)
' Controllo che il file non sia terminato
If IndexLine + IndexParam < FileContent.Count Then
' se è di tipo textboBoxOnOff lo tratto separatamente
If Not TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then
' se il nome del parametro è lo stesso di quello presente nella componente
If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
' verifico di che tipo si tratta: combobox
If TypeOf CurrCompoParam Is ComboBoxParam Then
' leggo il valore DDF dal file
Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
Dim IndexName As Integer = 0
' carico la lista dei valori (messaggi)
Dim List As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).ItemList
Dim IndexListDDF As Integer = 0
' carico la lista dei valori DDF
Dim ListDDF As List(Of String) = DirectCast(CurrCompoParam, ComboBoxParam).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 foile 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
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50137), sVal, IndexLine)
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
SelItem = List(0)
End If
' assegno al parametro della compnente il valore "filtrato"
DirectCast(CurrCompoParam, ComboBoxParam).SetSelItem(SelItem)
' assegno il valore letto alla textbox
ElseIf TypeOf CurrCompoParam Is TextBoxParam Then
Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
' per ora non esegue nessun tipo di controllo sui valori letti dal file DDF
DirectCast(CurrCompoParam, TextBoxParam).m_Value = sVal
End If
' se il nome esiste ma è sabgliato
ElseIf Not String.IsNullOrWhiteSpace(SearchName(FileContent(IndexLine + IndexParam))) Then
' se il nome non è preceduto dal trattino
If String.IsNullOrWhiteSpace(Score(FileContent(IndexLine + IndexParam))) Then
' il nome DDF non è corretto
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
Else
' istanzio tutti i valori che mancano alla compo corrente di default
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
' esco dal ciclo for dei parametri
Exit For
End If
'se c'è una riga vuota
ElseIf String.IsNullOrWhiteSpace(SearchName(FileContent(IndexLine + IndexParam))) Then
' spostati alla riga successiva nel fie DDF
IndexLine += 1
' e continua a cercare lo stesso parametro
IndexParam -= 1
' se trovo un trattino vuol dire che cè una nuova componente
End If
' se è una TextBoxOnOff
Else
' prima verifico che ci sia veramnte la stringa nel file DDF
If IndexLine + IndexParam < FileContent.Count Then
If Not String.IsNullOrWhiteSpace(Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
' poi verifico che sia ugule al paramentro: se ha lo stesso nome DDF
If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
' se la stringa c'è nel DDF vuol dire che è stata selezionata
Dim sVal As String = SearchKeyValue(FileContent(IndexLine + IndexParam), Trim(CurrCompoParam.DDFName))
DirectCast(CurrCompoParam, TextBoxOnOffParam).m_Value = sVal
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = True
Else
' cerco un parametro successivo
If IndexParam < CompoTemplateItem.CompoParamList.Count - 1 Then
' controllo che il file abbia un'altra riga da leggere: se c'è un'altra riga
If IndexLine + IndexParam < FileContent.Count Then
' confronto con il succesivo parametro: se è uguale
If String.Equals(Trim(CompoTemplateItem.CompoParamList(IndexParam + 1).DDFName), Trim(SearchName(FileContent(IndexLine + IndexParam)))) Then
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
IndexLine -= 1
Else
' se sono diversi: è decisamente un errore
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50138))
' disattivo la TextBoxOnOff
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
IndexLine -= 1
End If
' se il file è terminato
Else
' istanzio tutti i valori che mancano alla compo corrente di default
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50140))
End If
' non ci sono più parametri nella lista
Else
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
'IndexLine = IndexLine - 1
Exit For
End If
End If
Else
' '' se cè una riga vuota passo alla succesiva
''IndexLine += 1
' '' e continua a cercare lo stesso parametro
''IndexParam -= 1
' significa che la TextBoxOnOff è stata disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
'IndexLine = IndexLine - 1
Exit For
End If
Else
' se la textBoxOnOff è l'ultima della lista (quindi seguita da uno psazio vuoto) allora considero che sia disattivata
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
Exit For
End If
End If
Else
' se il file è più corto di quel che dovrebbe essere (mancono alcuni parametri nel file prima della fine)
If TypeOf DirectCast(CompoTemplateItem.CompoParamList(IndexParam), CompoParam) Is TextBoxOnOffParam Then
DirectCast(CurrCompoParam, TextBoxOnOffParam).IsActive = False
Else
If Not String.IsNullOrEmpty(InvalidValue) Then InvalidValue &= Environment.NewLine
InvalidValue &= String.Format(EgtMsg(50139), IndexLine + IndexParam, Trim(CompoTemplateItem.CompoParamList(IndexParam).DDFName))
InvalidValue &= String.Format(Environment.NewLine & EgtMsg(50140))
End If
End If
If IndexLine + IndexParam < FileContent.Count Then
If Search3Score(FileContent(IndexLine + IndexParam)) Then
Exit For
End If
If Search3Dots(FileContent(IndexLine + IndexParam)) Then
Exit For
End If
Else
Exit For
End If
Next
' terminata la lettura dei parametri
IndexLine += IndexParam
End Sub
'' salto gli spazi vuoti finoa alla prima riga piena
'Public Function SkipWhiteSpace(Array() As String, ByRef Index As Integer, LastIndex As Integer) As Integer
' Array(Index) = FindComments(Array(Index))
' While String.IsNullOrWhiteSpace(Array(Index)) And Index < LastIndex
' Index += 1
' Array(Index) = FindComments(Array(Index))
' End While
' Return Index
'End Function
#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