Files
EgtDOORCreator/DoorParameters/Compo.vb
T
Nicola Pievani bdcce9b5ca EgtDOORCreator 1.8l1 :
- I general dell'assemblato sono salvati come metadata (##) all'inizio del file,
- modifica relazioni hardware Jamb-Door
2017-12-04 11:36:47 +00:00

1005 lines
47 KiB
VB.net

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Public Class Compo
Implements INotifyPropertyChanged
Friend TempFileDDF As String = IniFile.m_sTempDir & "\" & TEMP_FILE
'Friend m_rfCurrDoor As Part
' definizione della funzione delegato: riceve il valore di modifica della compo e della general
'Delegate Function CompareIsModify(rIsModifyCompo As Boolean, rIsModifyDoor As Boolean) As Boolean
'' aggiorno la variabile globale di cambiamento: verifico che sia il template che una combo/text sono state modificate
'Function IsModify() As Boolean
' If m_IsModifiedTemplateSelItem Then
' Return True
' End If
' For IndexCompoParamList = 0 To Me.CompoParamList.Count - 1
' If Me.CompoParamList(IndexCompoParamList).m_IsModifyCompoParam Then
' m_rfCurrDoor.m_IsModifyDoor = True
' Return True
' End If
' Next
' Return False
'End Function
' creo la stringa che contiene la lista degli errori
Dim ErrorList As String = String.Empty
Dim SetCompo As Integer = 0
Private m_CompoType As CompoType
Public ReadOnly Property CompoType As CompoType
Get
Return m_CompoType
End Get
End Property
Private m_refCompoJamb As Compo
Public Property refJambCompo As Compo
Get
Return m_refCompoJamb
End Get
Set(value As Compo)
m_refCompoJamb = value
End Set
End Property
Private m_IsReadOnly As Boolean = True
Public Property IsReadOnly As Boolean
Get
Return m_IsReadOnly
End Get
Set(value As Boolean)
m_IsReadOnly = value
End Set
End Property
Private m_IdCode As String
Public Property IdCode As String
Get
Return m_IdCode
End Get
Set(value As String)
m_IdCode = value
End Set
End Property
#Region "Template ComboBox"
Private m_TemplateName As String
Public Property TemplateName As String
Get
Return m_TemplateName
End Get
Set(value As String)
m_TemplateName = value
End Set
End Property
Private m_TemplateDDFName As String
Public Property TemplateDDFName As String
Get
Return m_TemplateDDFName
End Get
Set(value As String)
m_TemplateDDFName = value
End Set
End Property
Private m_TemplateItemList As New List(Of String)
Public Property TemplateItemList As List(Of String)
Get
Return m_TemplateItemList
End Get
Set(value As List(Of String))
m_TemplateItemList = value
End Set
End Property
Friend m_IsModifiedTemplateSelItem As Boolean = False
Private m_TemplateSelItem As String
Public Property TemplateSelItem As String
Get
Return m_TemplateSelItem
End Get
Set(value As String)
SetTemplateSelItem(value)
'm_IsModifiedTemplateSelItem = True
'm_rfCurrDoor.SetTitle()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
' setta il valore del template
Friend Sub SetTemplateSelItem(value As String)
Dim CurrConfig As String = m_CompoType.Path & "\" & CONFIGINI_FILE_NAME
Dim CurrItemPath As String = m_CompoType.Path & "\" & value
Dim ErrorList As String = String.Empty
' se il file ha estensione nge
If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = K_NGEEXTENSION Then
' controllo che esiste il file altrimenti esco
If Not File.Exists(CurrItemPath) Then Return
m_TemplateSelItem = value
' creo la stringa che contiene la lista degli errori
Dim ParamIndex As Integer = 1
Dim ConfigDefault As String = String.Empty
Dim NewCompoParam As CompoParam = Nothing
EgtUILib.GetPrivateProfileString(S_NGECONFIG, K_DEFAULT, "", ConfigDefault, CurrConfig)
' ricerco la parola chiave Param nella stringa nel file Cinfig.ini
ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault)
Else
' se il file non ha estensione allora creo l'estensione .lua
CurrItemPath &= K_LUAEXTENSION
' controllo che esiste il file altrimenti esco
If Not File.Exists(CurrItemPath) Then Return
m_TemplateSelItem = value
' carico un vettore con le stringhe del file corrente
Dim ReadCurrCompo() As String = File.ReadAllLines(CurrItemPath)
Dim EndOfFile As Boolean = False
' leggo il vettore di stringhe del file corrente
For LineIndex = 0 To ReadCurrCompo.Count - 1
' copio il valore della riga
Dim CurrCompoFileLine As String = ReadCurrCompo(LineIndex)
' cerco il titolo [Graphic parameters]: se lo trovo
If RegexFunction.IsGraphicParametersTitle(CurrCompoFileLine) Then
' mi preparo per leggere la prima riga dopo il titolo
Dim ParamIndex As Integer = 1
Dim NewCompoParam As CompoParam = Nothing
Dim bIsFinished As Boolean = False
' se la lettura del primo parametro "--Default=" restituisce un valore non nullo
If Not String.IsNullOrWhiteSpace(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT)) Then
Dim ConfigDefault As String = Trim(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT))
If Not IsNumeric(ConfigDefault) Then
' se il valore letto non è numerico allora esco dal cilo per la lettura dei parametri
Exit For
Else
ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault)
Exit For
End If
Else
' se il primo parametro non è "Dafault" allora mi aspetto di leggere i parametri
While Not bIsFinished
' attualizzo il componente a nulla
NewCompoParam = Nothing
' cerco nella riga successiva al titolo il primo parametro
If Not String.IsNullOrWhiteSpace(ReadCurrCompo(LineIndex + ParamIndex)) Then
Dim ReadLine As String
' carico i valori della stringa che seguono la chiave "--Param1="
ReadLine = ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_PARAM & ParamIndex)
' se uno dei paraemtri è completamente sbagliato allora restituisce falso e non riempo la NewCompoParam che rimane Nothing
bIsFinished = Not ReadParam(ReadLine, NewCompoParam, ErrorList)
Else
' altrimenti se la riga è vuota mi sposto alla successiva
LineIndex += 1
' e continuo il ciclo while
Continue While
End If
' insrisco la nuova componenenet: se la riga è vuota o la componente non è stata creata allora il componete è Nothing
InsertCompoParam(NewCompoParam, ParamIndex)
' se il parametro è stato creato passa alla riga successiva
If Not bIsFinished Then ParamIndex += 1
End While
NotifyPropertyChanged("TemplateSelItem")
End If
' esiste già una lista
For DeleteIndex = m_CompoParamList.Count - 1 To ParamIndex - 1 Step -1
m_CompoParamList.RemoveAt(DeleteIndex)
Next
Exit For
ElseIf LineIndex = ReadCurrCompo.Count - 1 Then
' se non trovo il capitoletto nel file leggo i parametri di default del file Config.ini
Dim ParamIndex As Integer = 1
Dim NewCompoParam As CompoParam = Nothing
ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, "")
Exit For
End If
Next
End If
'----------------------------------------------------------------------------------------------------------------------------------------------
' Not IsNothing(Me.refJambCompo) And
If Assembly.BuiltReffCompo Then
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(Me.CompoType.Path, nDoorNbr, Me.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)
If Not IsNothing(Me.refJambCompo) Then
Map.refPartPageVM.CurrPart.RemoveRefCompo(Me.refJambCompo)
Me.refJambCompo = Nothing
return
End If
Else
Dim FrameCompoNameDDF As String = String.Empty
Dim FrameCompoName As String = String.Empty
Dim Side As String = String.Empty
Dim CurrCompoPath As String = FrameCompoFileConfig
' sostituisco il vecchio CompoType con quello corretto
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 = Me.CompoType.JambSide
'-------------------------------------------------------------------------------------------------------------------------------
If IsNothing(Me.refJambCompo) Then
Part.CreateRefCompo(Me.CompoType, Me, Map.refAssemblyPageVM.CurrAssembly, FrameCompoFileConfig, FrameCompoFile, Map.refPartPageVM.CurrPart)
If CompoMatch.LoadCompoParam(Me) Then Map.refAssemblyPageVM.CurrAssembly.UpDateCurrCompoJamb(Me)
Return
End If
'-------------------------------------------------------------------------------------------------------------------------------
Me.refJambCompo.CompoType.SetDDFName(FrameCompoNameDDF)
Me.refJambCompo.CompoType.SetName(FrameCompoName)
Dim FrameCompoDirectory As String
FrameCompoDirectory = FrameCompoFileConfig.Remove(FrameCompoFileConfig.LastIndexOf("\"))
Me.refJambCompo.CompoType.SetPath(FrameCompoDirectory)
Me.refJambCompo.CompoType.SetJambSide(Side)
End If
End If
' Carico il nome
FrameCompoFile = FrameCompoFile.Substring(FrameCompoFileConfig.LastIndexOf("\") + 1)
Me.refJambCompo.SetTemplateSelItemRefCompo(FrameCompoFile, Me.refJambCompo)
LoadCompoParam(Me)
Map.refAssemblyPageVM.CurrAssembly.UpDateCurrCompoJamb(Me)
ResetCompoParam()
End If
End If
End Sub
' setto la lista dei parametri da caricare la lista dei paramestri
Private Sub ReadParamConfig(ByRef NewCompoParam As CompoParam, ByRef ErrorList As String, ParamIndex As Integer, DefaultConfig As String)
Dim sParam As String = String.Empty
Dim CurrConfig As String = m_CompoType.Path & "\" & CONFIGINI_FILE_NAME
Dim S_CHAPTER As String
If String.IsNullOrWhiteSpace(DefaultConfig) Then
S_CHAPTER = S_GR_PARAM_DEFAULT & "1"
Else
S_CHAPTER = S_GR_PARAM_DEFAULT & DefaultConfig
End If
While EgtUILib.GetPrivateProfileString(S_CHAPTER, K_PARAM & ParamIndex, "", sParam, CurrConfig) > 0
If Not String.IsNullOrWhiteSpace(sParam) Then
' leggo il tipo di parametro
ReadParam(sParam, NewCompoParam, ErrorList)
' carico il parametro nella lista della componente
InsertCompoParam(NewCompoParam, ParamIndex)
End If
ParamIndex += 1
End While
' controllo di aver tolto tutti i parametri che potrrebbero esistere da una precedente chiamata
For DeleteIndex = m_CompoParamList.Count - 1 To ParamIndex - 1 Step -1
m_CompoParamList.RemoveAt(DeleteIndex)
Next
End Sub
' inserisco il parametro letto nella lista dei paramtri senza modificare i parametri già esistenti
Private Sub InsertCompoParam(NewCompoParam As CompoParam, ParamIndex As Integer)
If Not IsNothing(NewCompoParam) Then
' se non esiste l'indice
If Not m_CompoParamList.Count > ParamIndex - 1 Then
' creo il parametro combo
Me.CompoParamList.Insert(ParamIndex - 1, NewCompoParam)
Else
' se esiste ma è diverso il nome DDF
If Not m_CompoParamList(ParamIndex - 1).DDFName = NewCompoParam.DDFName Then
' creo il nuovo parametro combo
m_CompoParamList.RemoveAt(ParamIndex - 1)
m_CompoParamList.Insert(ParamIndex - 1, NewCompoParam)
End If
End If
End If
End Sub
' a differenza delle funzioni sopra queste ricevono come parametro l'oggetto compo che deve essere modificato
' il prossimo passo sarà eliminare le funzioni sopra scritte per lasciare solo queste
#Region "SettemplateREFCOMPO"
Friend Sub SetTemplateSelItemRefCompo(value As String, CurrRefCompo As Compo)
Dim CurrConfig As String = CurrRefCompo.CompoType.Path & "\" & CONFIGINI_FILE_NAME
Dim CurrItemPath As String = CurrRefCompo.CompoType.Path
If value.Contains(CurrItemPath) Then
value = value.Substring(CurrItemPath.Count + 1)
CurrItemPath &= "\" & value
Else
CurrItemPath &= "\" & value
End If
Dim ErrorList As String = String.Empty
' se il file ha estensione nge
If Path.HasExtension(CurrItemPath) AndAlso Path.GetExtension(CurrItemPath).ToLower = K_NGEEXTENSION Then
' controllo che esiste il file altrimenti esco
If Not File.Exists(CurrItemPath) Then Return
CurrRefCompo.TemplateSelItem = value
' creo la stringa che contiene la lista degli errori
Dim ParamIndex As Integer = 1
Dim ConfigDefault As String = String.Empty
Dim NewCompoParam As CompoParam = Nothing
EgtUILib.GetPrivateProfileString(S_NGECONFIG, K_DEFAULT, "", ConfigDefault, CurrConfig)
' ricerco la parola chiave Param nella stringa nel file Cinfig.ini
ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault)
Else
' se il file non ha estensione allora creo l'estensione .lua
CurrItemPath &= K_LUAEXTENSION
' controllo che esiste il file altrimenti esco
If Not File.Exists(CurrItemPath) Then Return
CurrRefCompo.TemplateSelItem = value
' carico un vettore con le stringhe del file corrente
Assembly.BuiltReffCompo = False
Dim ReadCurrCompo() As String = File.ReadAllLines(CurrItemPath)
Assembly.BuiltReffCompo = True
Dim EndOfFile As Boolean = False
' leggo il vettore di stringhe del file corrente
For LineIndex = 0 To ReadCurrCompo.Count - 1
' copio il valore della riga
Dim CurrCompoFileLine As String = ReadCurrCompo(LineIndex)
' cerco il titolo [Graphic parameters]: se lo trovo
If RegexFunction.IsGraphicParametersTitle(CurrCompoFileLine) Then
' mi preparo per leggere la prima riga dopo il titolo
Dim ParamIndex As Integer = 1
Dim NewCompoParam As CompoParam = Nothing
Dim bIsFinished As Boolean = False
' se la lettura del primo parametro "--Default=" restituisce un valore non nullo
If Not String.IsNullOrWhiteSpace(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT)) Then
Dim ConfigDefault As String = Trim(ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_DEFAULT))
If Not IsNumeric(ConfigDefault) Then
' se il valore letto non è numerico allora esco dal cilo per la lettura dei parametri
Exit For
Else
ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault)
Exit For
End If
Else
' se il primo parametro non è "Dafault" allora mi aspetto di leggere i parametri
While Not bIsFinished
' attualizzo il componente a nulla
NewCompoParam = Nothing
' cerco nella riga successiva al titolo il primo parametro
If Not String.IsNullOrWhiteSpace(ReadCurrCompo(LineIndex + ParamIndex)) Then
Dim ReadLine As String
' carico i valori della stringa che seguono la chiave "--Param1="
ReadLine = ParamLine(ReadCurrCompo(LineIndex + ParamIndex), K_PARAM & ParamIndex)
' se uno dei paraemtri è completamente sbagliato allora restituisce falso e non riempo la NewCompoParam che rimane Nothing
bIsFinished = Not ReadParam(ReadLine, NewCompoParam, ErrorList)
Else
' altrimenti se la riga è vuota mi sposto alla successiva
LineIndex += 1
' e continuo il ciclo while
Continue While
End If
' insrisco la nuova componenenet: se la riga è vuota o la componente non è stata creata allora il componete è Nothing
InsertCompoParam(NewCompoParam, ParamIndex)
' se il parametro è stato creato passa alla riga successiva
If Not bIsFinished Then ParamIndex += 1
End While
NotifyPropertyChanged("TemplateSelItem")
End If
' esiste già una lista
For DeleteIndex = Me.refJambCompo.CompoParamList.Count - 1 To ParamIndex - 1 Step -1
Me.refJambCompo.CompoParamList.RemoveAt(DeleteIndex)
Next
Exit For
ElseIf LineIndex = ReadCurrCompo.Count - 1 Then
' se non trovo il capitoletto nel file leggo i parametri di default del file Config.ini
Dim ParamIndex As Integer = 1
Dim NewCompoParam As CompoParam = Nothing
ReadParamConfigRefCompo(NewCompoParam, ErrorList, ParamIndex, "", CurrRefCompo)
Exit For
End If
Next
End If
End Sub
' setto la lista dei parametri da caricare la lista dei paramestri
Private Sub ReadParamConfigRefCompo(ByRef NewCompoParam As CompoParam, ByRef ErrorList As String, ParamIndex As Integer, DefaultConfig As String, CurrRefCompo As Compo)
Dim sParam As String = String.Empty
Dim CurrConfig As String = CurrRefCompo.CompoType.Path & "\" & CONFIGINI_FILE_NAME
Dim S_CHAPTER As String
If String.IsNullOrWhiteSpace(DefaultConfig) Then
S_CHAPTER = S_GR_PARAM_DEFAULT & "1"
Else
S_CHAPTER = S_GR_PARAM_DEFAULT & DefaultConfig
End If
While EgtUILib.GetPrivateProfileString(S_CHAPTER, K_PARAM & ParamIndex, "", sParam, CurrConfig) > 0
If Not String.IsNullOrWhiteSpace(sParam) Then
' leggo il tipo di parametro
ReadParam(sParam, NewCompoParam, ErrorList)
' carico il parametro nella lista della componente
InsertCompoParamRef(NewCompoParam, ParamIndex, CurrRefCompo)
End If
ParamIndex += 1
End While
' controllo di aver tolto tutti i parametri che potrrebbero esistere da una precedente chiamata
For DeleteIndex = CurrRefCompo.CompoParamList.Count - 1 To ParamIndex - 1 Step -1
CurrRefCompo.CompoParamList.RemoveAt(DeleteIndex)
Next
End Sub
' inserisco il parametro letto nella lista dei paramtri senza modificare i parametri già esistenti
Private Sub InsertCompoParamRef(NewCompoParam As CompoParam, ParamIndex As Integer, CurrRefCompo As Compo)
If Not IsNothing(NewCompoParam) Then
' se non esiste l'indice
If Not CurrRefCompo.CompoParamList.Count > ParamIndex - 1 Then
' creo il parametro combo
CurrRefCompo.CompoParamList.Insert(ParamIndex - 1, NewCompoParam)
Else
' se esiste ma è diverso il nome DDF
If Not m_CompoParamList(ParamIndex - 1).DDFName = NewCompoParam.DDFName Then
' creo il nuovo parametro combo
CurrRefCompo.CompoParamList.RemoveAt(ParamIndex - 1)
CurrRefCompo.CompoParamList.Insert(ParamIndex - 1, NewCompoParam)
End If
End If
End If
End Sub
#End Region ' SetTemplateREFCOMPO
' leggo il nome DDF e il nome, restituisco il nome solo se esiste un messaggio associato
Private Function MsgControl(sDDFName As String, sName As String, ByRef sErrorList As String) As String
' se è numerico ma non esiste un messaggio associato
Dim ErrorMsg As String = "Msg" & Trim(sName)
If String.Equals(Utility.ReadMsg(sName), ErrorMsg) Then
sErrorList &= String.Format(EgtMsg(50119), sName)
Return sDDFName
Else
' restituisco il messaggio letto
Return Utility.ReadMsg(sName)
End If
End Function
Private Function ReadParam(sReadLine As String, ByRef NewCompoParam As CompoParam, sErrorList As String) As Boolean
If Not String.IsNullOrWhiteSpace(sReadLine) Then
' carico un vettore con i valori della stringa
Dim sItems() As String = sReadLine.Split(";"c)
' se esistono almeno due elementi "ComboBox; NomeDDF"
If sItems.Count > 1 Then
' il primo elemento del vettore distingue tre categorie
Select Case sItems(0)
Case "ComboBox"
'ConvertComboBoxString(sItems)
' se la combobox contiene almeno un elemento "ComboBox; NomeDDF/Nome; NomeDDFItem/NomeItem"
If sItems.Count >= 3 Then
' carico gli elementi della lista in un vettore
Dim sComboItemList() As String = sItems(2).Split(","c)
Dim ComboItemList As New List(Of String)
Dim DDFComboItemList As New List(Of String)
For ItemIndex = 0 To sComboItemList.Count - 1
Dim ComboItem() As String = sComboItemList(ItemIndex).Split("/"c)
' se esiste il NomeDDF e il Nome allora separo
If ComboItem.Count = 2 Then
' carico la lista con i nomi DDF
DDFComboItemList.Add(ComboItem(0))
' carico la lista con i nomi
ComboItemList.Add(MsgControl(ComboItem(0), ComboItem(1), sErrorList))
Else
' se esiste solo un nome considero sia il nome DDF
ComboItemList.Add(ComboItem(0))
' Errore nella lettura del nome: manca la definizione del nome nella lingua corrente
sErrorList &= String.Format(EgtMsg(50120), ComboItem(0), m_CompoType.Path)
End If
Next
' se il nome DDF non è separato dal diviso vuol dire che non c'è nessun messaggio associato, quindi scrivo due volte il messaggio DDF
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New ComboBoxParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, ComboItemList, DDFComboItemList, ComboItemList(0))
Else
NewCompoParam = New ComboBoxParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, ComboItemList, DDFComboItemList, ComboItemList(0))
End If
Return True
Else
' non esiste una lista di nemmeno un elemento
sErrorList &= String.Format(EgtMsg(50121), sItems(1).Split("/"c)(0), m_CompoType.DDFName)
Return False
End If
Case "TextBox"
'ConvertTextBoxString(sItems)
Dim dHeight As Double = 500
' leggo il valore altezza che già esite nella porta
'------------------------------StringToDouble(m_rfCurrDoor.Height, dHeight)
Dim dDefaultValue As Double
' verifico che sono presenti "TextBox; NomeDDF/Nome"
If sItems.Count > 2 Then
' verifico che sono presenti "TextBox; NomeDDF/Nome; Valore"
If sItems.Count >= 3 Then
' controllo che l'epressione scritta come valore finale sia corretta
If StringToDouble(sItems(2), dDefaultValue) Then
Dim sDefaultValue As String = DoubleToString(dDefaultValue, 5)
' verifico che la misura letta sia minore dell'altezza della porta
If dDefaultValue < dHeight Then
' verifico che sono presenti "TextBox; NomeDDF/Nome; Valore; NomeLista; NomeElementoLista"
If sItems.Count > 4 Then
ElseIf sItems.Count = 3 Then
' se la text contiente solo 4 parametri
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, sDefaultValue, Nothing, Nothing)
Else
NewCompoParam = New TextBoxParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, sDefaultValue, Nothing, Nothing)
End If
Return True
End If
Else
' se la misura passata è più grande di quella della porta non carico il valore e creo il parametro senza lista
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50124), MsgControl(sItems(1), "-1", sErrorList), m_CompoType.DDFName, sDefaultValue)
Else
NewCompoParam = New TextBoxParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50124), MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList), m_CompoType.DDFName, sDefaultValue)
End If
' ma faccio andare avanti nella lettura dei parametri
Return True
End If
Else
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
Else
NewCompoParam = New TextBoxParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
End If
Dim ErrorExpression As String = String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))
MessageBox.Show(ErrorExpression, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Return True
End If
ElseIf sItems.Count = 2 Then
' se la stringa ha 2 elemtni "TextBox; NomeDDF/Nome"
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50125), MsgControl(sItems(1), "-1", sErrorList), m_CompoType.DDFName)
Else
NewCompoParam = New TextBoxParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50125), MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList), m_CompoType.DDFName)
End If
Return True
End If
Else
' se ha solo 1 elementi "TextBox"
NewCompoParam = Nothing
sErrorList &= String.Format(EgtMsg(50122), sItems(1), m_CompoType.DDFName)
Return False
End If
Case "TextBoxOnOff"
Dim dHeight As Double = 500
' leggo il valore altezza che già esite nella porta
'------------------------------------------------StringToDouble(m_rfCurrDoor.Height, dHeight)
Dim dDefaultValue As Double
' verifico che sono presenti "TextBox; NomeDDF/Nome"
If sItems.Count > 2 Then
' verifico che sono presenti "TextBox; NomeDDF/Nome; Valore"
If sItems.Count >= 3 Then
' controllo che l'epressione scritta come valore finale sia corretta
If StringToDouble(sItems(2), dDefaultValue) Then
Dim sDefaultValue As String = DoubleToString(dDefaultValue, 5)
' verifico che la misura letta sia minore dell'altezza della porta
If dDefaultValue < dHeight Then
' verifico che sono presenti "TextBox; NomeDDF/Nome; Valore; NomeLista; NomeElementoLista"
If sItems.Count > 4 Then
ElseIf sItems.Count = 3 Then
' se la text contiente solo 4 parametri
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, sDefaultValue, Nothing, Nothing)
Else
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, sDefaultValue, Nothing, Nothing)
End If
Return True
End If
Else
' se la misura passata è più grande di quella della porta non carico il valore e creo il parametro senza lista
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50124), MsgControl(sItems(1), "-1", sErrorList), m_CompoType.DDFName, sDefaultValue)
Else
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50124), MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList), m_CompoType.DDFName, sDefaultValue)
End If
' ma faccio andare avanti nella lettura dei parametri
Return True
End If
Else
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
Else
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
End If
Dim ErrorExpression As String = String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))
MessageBox.Show(ErrorExpression, EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Return True
End If
ElseIf sItems.Count = 2 Then
' se la stringa ha 2 elemtni "TextBox; NomeDDF/Nome"
If sItems(1).Split("/"c).Count = 1 Then
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1)), MsgControl(Trim(sItems(1)), "-1", sErrorList), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50125), MsgControl(sItems(1), "-1", sErrorList), m_CompoType.DDFName)
Else
NewCompoParam = New TextBoxOnOffParam(Trim(sItems(1).Split("/"c)(0)), Trim(MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList)), Me, "0.000", Nothing, Nothing)
sErrorList &= String.Format(EgtMsg(50125), MsgControl(sItems(1).Split("/"c)(0), sItems(1).Split("/"c)(1), sErrorList), m_CompoType.DDFName)
End If
Return True
End If
Else
' se ha solo 1 elementi "TextBox"
NewCompoParam = Nothing
sErrorList &= String.Format(EgtMsg(50122), sItems(1), m_CompoType.DDFName)
Return False
End If
End Select
Else
' se non è nessuno dei casi precedenti del select case
sErrorList &= String.Format(EgtMsg(50121), m_CompoType.DDFName, sItems(0))
Return True
End If
End If
' creo la stringa di errore
If Not String.IsNullOrEmpty(sErrorList) Then
sErrorList &= Environment.NewLine
sErrorList &= sErrorList
Else
sErrorList &= sErrorList
End If
Return False
End Function
' converto questo vettore {"TextBox", "NomeDDF/Nome"} in {"TextBox", "NomeDDF", "Nome"}
Private Sub ConvertTextBoxString(ByRef Items() As String)
Dim Arrays(Items.Count) As String
Dim IndexArray As Integer = 0
Dim IndexItems As Integer = 0
For IndexItems = 0 To Items.Count - 1
If Not String.IsNullOrEmpty(RegexFunction.ParamExpression(Items(IndexItems))) Then
Arrays(IndexArray) = Trim(RegexFunction.ParamExpression(Items(IndexItems)))
IndexArray += 1
ElseIf Items(IndexItems).Split("/"c).Count = 1 Then
Arrays(IndexArray) = Trim(Items(IndexItems))
IndexArray += 1
ElseIf Items(IndexItems).Split("/"c).Count = 2 Then
Arrays(IndexArray) = Trim(Items(IndexItems).Split("/"c)(0))
IndexArray += 1
If IndexArray < Arrays.Count - 1 Then
Arrays(IndexArray) = Trim(Items(IndexItems).Split("/"c)(1))
IndexArray += 1
End If
End If
Next
If IndexArray = IndexItems + 1 Then
System.Array.Resize(Items, IndexArray)
Items = Arrays
'Else
' Items = Arrays
End If
End Sub
' converto questo vettore {"ComboBox", "NomeDDF/Nome"} in {"ComboBox", "NomeDDF", "Nome"}
Private Sub ConvertComboBoxString(ByRef Items() As String)
Dim bCovert As Boolean = False
Dim Arrays(Items.Count) As String
Dim IndexArray As Integer = 0
Dim IndexItems As Integer = 0
For IndexItems = 0 To Items.Count - 1
If Items(IndexItems).Split("/"c).Count = 1 Then
Arrays(IndexArray) = Trim(Items(IndexItems))
IndexArray += 1
ElseIf Items(IndexItems).Split("/"c).Count = 2 Then
Arrays(IndexArray) = Trim(Items(IndexItems).Split("/"c)(0))
Arrays(IndexArray + 1) = Trim(Items(IndexItems).Split("/"c)(1))
IndexArray += 2
For Index = IndexItems + 1 To Items.Count - 1
Arrays(Index + 1) = Trim(Items(Index))
Next
bCovert = True
Exit For
End If
Next
If bCovert Then
System.Array.Resize(Items, Items.Count)
Items = Arrays
'Else
' Items = Arrays
End If
End Sub
Private m_TemplateVisibility As Visibility
Public Property TemplateVisibility As Visibility
Get
Return m_TemplateVisibility
End Get
Set(value As Visibility)
m_TemplateVisibility = value
End Set
End Property
#End Region ' Template ComboBox
Private m_CompoParamList As New ObservableCollection(Of CompoParam)
Public Property CompoParamList As ObservableCollection(Of CompoParam)
Get
Return m_CompoParamList
End Get
Set(value As ObservableCollection(Of CompoParam))
m_CompoParamList = value
End Set
End Property
' Definizione comando
Private m_CmdDelete As ICommand
Sub New(CompoType As CompoType, MyDoor As Part)
m_CompoType = CompoType
m_rfCurrDoor = MyDoor
End Sub
#Region "COMMANDS"
#Region "DeleteCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property DeleteCommand As ICommand
Get
If m_CmdDelete Is Nothing Then
m_CmdDelete = New Command(AddressOf Delete)
End If
Return m_CmdDelete
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub Delete()
Map.refPartPageVM.CurrPart.RemoveCompo(Me)
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Sub
#End Region ' DeleteCommand
#End Region 'Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
Public Class CompoParam
Friend Shared m_rfSetTitle As Action
Friend m_IsModifyCompoParam As Boolean = False
Private m_Name As String
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Private m_DDFName As String
Public Property DDFName As String
Get
Return m_DDFName
End Get
Set(value As String)
m_DDFName = value
End Set
End Property
Private m_CurrCompo As Compo
Public Property CurrCompo As Compo
Get
Return m_CurrCompo
End Get
Set(value As Compo)
m_CurrCompo = value
End Set
End Property
Sub New(sDDFName As String, sName As String, CurrCompo As Compo)
m_DDFName = sDDFName
m_Name = sName
m_CurrCompo = CurrCompo
End Sub
End Class
Public Class TextBoxParam
Inherits CompoParam
Implements INotifyPropertyChanged
Private m_IsReadOnly As Boolean = True
Public Property IsReadOnly As Boolean
Get
Return m_IsReadOnly
End Get
Set(value As Boolean)
m_IsReadOnly = value
End Set
End Property
Dim dValue As Double = -1
Friend m_Value As String
Public Property Value As String
Get
Return m_Value
End Get
Set(value As String)
m_Value = value
NotifyPropertyChanged("ToolTipValue")
m_IsModifyCompoParam = True
' se la componente non ha un riferimento esce
If IsNothing(CurrCompo.refJambCompo) Then Return
' se fallisce il caricamento dei parametri esce
If Not LoadCompoParam(CurrCompo) Then Return
If Not UpdateParam() Then MessageBox.Show("No matching param ", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
ResetCompoParam()
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Public Sub SetValue(sValue As String)
m_Value = sValue
NotifyPropertyChanged("ToolTipValue")
End Sub
Public ReadOnly Property ToolTipValue As String
Get
If StringToDouble(Value, dValue) Then
Return DoubleToString(dValue, 4)
Else
Return EgtMsg(50143)
End If
End Get
End Property
Private m_ComboValuelList As New List(Of String)
Public Property ComboValuelList As List(Of String)
Get
Return m_ComboValuelList
End Get
Set(value As List(Of String))
m_ComboValuelList = value
End Set
End Property
Private m_ComboBox As ComboBoxParam
Private m_Visibility As Visibility
Public Property Visibility As Visibility
Get
Return m_Visibility
End Get
Set(value As Visibility)
m_Visibility = value
End Set
End Property
Public Function UpdateParam() As Boolean
Dim CmpPar As CompoParam = Me
Dim IndexP As Integer = CurrCompo.CompoParamList.IndexOf(Me)
Dim CmpRefPar As CompoParam = CurrCompo.refJambCompo.CompoParamList(IndexP)
For IndexParam As Integer = 0 To CurrCompo.refJambCompo.CompoParamList.Count - 1
If TypeOf CmpRefPar Is TextBoxParam AndAlso CmpPar.DDFName = CmpRefPar.DDFName Then
Dim TBoxPar As TextBoxParam = DirectCast(CmpPar, TextBoxParam)
Dim TBoxRefPar As TextBoxParam = DirectCast(CmpRefPar, TextBoxParam)
CalcCompoParamValue(TBoxPar.DDFName, TBoxPar.m_Value, TBoxRefPar.m_Value, TBoxRefPar.IsReadOnly)
Return True
ElseIf TypeOf CmpRefPar Is ComboBoxParam AndAlso CmpPar.DDFName = CmpRefPar.DDFName Then
DirectCast(CmpRefPar, ComboBoxParam).IsReadOnly = False
Return True
ElseIf TypeOf CmpRefPar Is TextBoxOnOffParam AndAlso CmpPar.DDFName = CmpRefPar.DDFName Then
Dim TBoxPar As TextBoxOnOffParam = DirectCast(CmpPar, TextBoxOnOffParam)
Dim TBoxRefPar As TextBoxOnOffParam = DirectCast(CmpRefPar, TextBoxOnOffParam)
CalcCompoParamValue(TBoxPar.DDFName, TBoxPar.m_Value, TBoxRefPar.m_Value, TBoxRefPar.IsReadOnly)
Return True
End If
Next
Return False
End Function
Sub New(sDDFName As String, sName As String, CurrCompo As Compo, sValue As String, ComboBox As ComboBoxParam, ComboValuelList As List(Of String))
MyBase.New(sDDFName, sName, CurrCompo)
m_Value = sValue
m_ComboBox = ComboBox
m_ComboValuelList = ComboValuelList
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
Public Class ComboBoxParam
Inherits CompoParam
Private m_IsReadOnly As Boolean = True
Public Property IsReadOnly As Boolean
Get
Return m_IsReadOnly
End Get
Set(value As Boolean)
m_IsReadOnly = value
End Set
End Property
Private m_ItemList As New List(Of String)
Public Property ItemList As List(Of String)
Get
Return m_ItemList
End Get
Set(value As List(Of String))
m_ItemList = value
End Set
End Property
Private m_ItemListDDF As New List(Of String)
Public Property ItemListDDF As List(Of String)
Get
Return m_ItemListDDF
End Get
Set(value As List(Of String))
m_ItemListDDF = value
End Set
End Property
Private m_SelItem As String
Public Property SelItem As String
Get
Return m_SelItem
End Get
Set(value As String)
m_SelItem = value
m_IsModifyCompoParam = True
Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True
End Set
End Property
Friend Sub SetSelItem(value As String)
m_SelItem = value
End Sub
Sub New(sDDFName As String, sName As String, CurrCompo As Compo, ItemList As List(Of String), ItemListDDF As List(Of String), sSelItem As String)
MyBase.New(sDDFName, sName, CurrCompo)
m_ItemList = ItemList
m_ItemListDDF = ItemListDDF
m_SelItem = sSelItem
End Sub
End Class
Public Class TextBoxOnOffParam
Inherits TextBoxParam
Private m_IsActive As Boolean = True
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
Sub New(sDDFName As String, sName As String, CurrCompo As Compo, sValue As String, ComboBox As ComboBoxParam, ComboValuelList As List(Of String))
MyBase.New(sDDFName, sName, CurrCompo, sValue, ComboBox, ComboValuelList)
End Sub
End Class