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 ' 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 Private m_LoadByDefault As Boolean = False Public Property LoadByDefault As Boolean Get Return m_LoadByDefault End Get Set(value As Boolean) m_LoadByDefault = value SetImage() NotifyPropertyChanged("ImageButton") End Set End Property Public Sub SetImage() If m_LoadByDefault Then m_ImageButton = "/Resources/Refresh/Error.png" Else m_ImageButton = "/Resources/TopCommandBar/X.png" End If End Sub Private m_ImageButton As String = "/Resources/TopCommandBar/X.png" Public ReadOnly Property ImageButton As String Get Return m_ImageButton End Get End Property Private m_IsFixed As Boolean Friend ReadOnly Property IsFixed As Boolean Get Return m_IsFixed End Get End Property Friend Sub SetIsFixed(IsFixed As Boolean) m_IsFixed = IsFixed End Sub ' utilizzato nel HardwareManager per mostrare i parametri Private m_IsActiveChapter As Boolean = True Public Property IsActiveChapter As Boolean Get Return m_IsActiveChapter End Get Set(value As Boolean) m_IsActiveChapter = value If Not IsNothing(Map.refHardwarePageVM) AndAlso Not IsNothing(Map.refHardwarePageVM.CurrHardware) Then Map.refHardwarePageVM.CurrHardware.RefreshTempHardware() Map.refSceneManagerVM.RefreshBtn() Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True End If End Set End Property Public Sub SetIsActiveChapter(IsActive As Boolean) m_IsActiveChapter = IsActive NotifyPropertyChanged("IsActiveChapter") End Sub ' utilizzato nel HardwareManager per mostrare i parametri in cascata Private m_Cascaded As String Public Property Cascaded As String Get Return m_Cascaded End Get Set(value As String) m_Cascaded = value End Set End Property #Region "Template ComboBox" ' lista dei marchi Private m_BrandListPart As New ObservableCollection(Of String) Public Property BrandListPart As ObservableCollection(Of String) Get Return m_BrandListPart End Get Set(value As ObservableCollection(Of String)) m_BrandListPart = value End Set End Property ' selezione del marchio Private m_SelBrandPart As String Public Property SelBrandPart As String Get Return m_SelBrandPart End Get Set(value As String) ' questa procedura deve essere eseguita SOLO dopo il caricamento della pagina! m_SelBrandPart = value For IndexModelList As Integer = 0 To m_BrandListPart.Count - 1 If m_BrandListPart(IndexModelList) = m_SelBrandPart Then m_FileList = CompoType.FolderList(IndexModelList).ModelFileList Exit For End If Next NotifyPropertyChanged("FileList") Dim SelItemindex As Integer = 0 While SelItemindex < m_FileList.Count - 1 AndAlso Path.HasExtension(m_FileList(SelItemindex)) SelItemindex += 1 End While If SelItemindex < m_FileList.Count Then SelFile = m_FileList(SelItemindex) Else SelFile = String.Empty End If End Set End Property Public Sub SetSelBrand(sSelBrand As String) m_SelBrandPart = sSelBrand For IndexModelList As Integer = 0 To m_BrandListPart.Count - 1 If m_BrandListPart(IndexModelList) = m_SelBrandPart Then m_FileList = CompoType.FolderList(IndexModelList).ModelFileList Exit For End If Next NotifyPropertyChanged("FileList") NotifyPropertyChanged("SelBrandPart") End Sub ' lista dei file Private m_FileList As New ObservableCollection(Of String) Public Property FileList As ObservableCollection(Of String) Get Return m_FileList End Get Set(value As ObservableCollection(Of String)) m_FileList = value End Set End Property ' selezione del file Private m_SelFile As String Public Property SelFile As String Get Return m_SelFile End Get Set(value As String) m_SelFile = value ' ricostruisco il nome del template da passare alle funzioni Dim ModelDir As String = String.Empty If m_SelBrandPart <> RegexFunction.ModelTemplate(m_CompoType.Path) Then ModelDir = m_SelBrandPart & "\" Dim CurrItem As String = ModelDir & m_SelFile ' passo il nome TemplateSelItem = CurrItem NotifyPropertyChanged("SelFile") End Set End Property Friend Sub SetSelFile(File As String) m_SelFile = File ' ricostruisco il nome del template da passare alle funzioni Dim ModelDir As String = String.Empty If m_SelBrandPart <> RegexFunction.ModelTemplate(m_CompoType.Path) Then ModelDir = m_SelBrandPart & "\" Dim CurrItem As String = ModelDir & m_SelFile ' passo il nome SetSelTemplate(CurrItem) NotifyPropertyChanged("SelFile") End Sub ' nome grafica (potrebbe essere shape o template) 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 ' nome DDF (potrebbe essere shape o template) 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 ' il messaggio associato al brand Public ReadOnly Property BrandMsg As String Get Return Me.CompoType.FolderName End Get End Property ' lista dei File Template --> usato nella funzione Private m_TemplateItemList As New ObservableCollection(Of String) Public Property TemplateItemList As ObservableCollection(Of String) Get Return m_TemplateItemList End Get Set(value As ObservableCollection(Of String)) m_TemplateItemList = value End Set End Property ' Template selezionato Private m_TemplateSelItem As String Public Property TemplateSelItem As String Get Return m_TemplateSelItem End Get Set(value As String) SetTemplateSelItem(value) Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True LoadByDefault = False Map.refSceneManagerVM.RefreshBtn() End Set End Property Private Sub SetSelTemplate(Template As String) SetTemplateSelItem(Template) Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True End Sub ' 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 = NGE_EXTENSION 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 Config.ini ReadParamConfig(NewCompoParam, ErrorList, ParamIndex, ConfigDefault) Else ' se il file non ha estensione allora aggiungo l'estensione .lua If Not Path.GetExtension(CurrItemPath).ToLower = LUA_EXTENSION Then CurrItemPath &= LUA_EXTENSION End If ' controllo che esista 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 If Not String.IsNullOrWhiteSpace(ErrorList) Then EgtOutLog(ErrorList) '---------------------------------------------------------------------------------------------------------------------------------------------- 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("Jamb compo does not exist", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning) 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(S_POSITIONSIDE, K_SIDE, Side, Me.CompoType.Path & "\" & CONFIGINI_FILE_NAME) If String.IsNullOrEmpty(Side) Then ' controllo nell'elenco dei parametri se esiste un parametro di tipo Side For IndexParam As Integer = 0 To Me.CompoParamList.Count - 1 If Me.CompoParamList(IndexParam).DDFName.ToLower = K_SIDE.ToLower Then Side = DirectCast(Me.CompoParamList(IndexParam), ComboBoxParam).SelItem Exit For End If Next End If '------------------------------------------------------------------------------------------------------------------------------- If IsNothing(Me.refJambCompo) Then Part.CreateRefCompo(Me.CompoType, Me, Map.refAssemblyPageVM.CurrAssembly, FrameCompoFileConfig, FrameCompoFile, Map.refPartPageVM.CurrPart) If CompoMatch.LoadCompoParam(Me, Map.refPartPageVM.CurrPart.TypePart) Then Map.refAssemblyPageVM.CurrAssembly.UpDateCurrCompoJamb(Me) For IndexParam As Integer = 0 To Me.refJambCompo.CompoParamList.Count - 1 If Me.refJambCompo.CompoParamList(IndexParam).DDFName.ToLower = K_SIDE.ToLower Then ' assegno alla componente del frame la stessa posizione definita sull'anta DirectCast(Me.refJambCompo.CompoParamList(IndexParam), ComboBoxParam).SetSelItem(Me.CompoType.JambSide) Exit For End If Next 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.refPartPageVM.CurrPart.TypePart) Map.refAssemblyPageVM.CurrAssembly.UpDateCurrCompoJamb(Me) ResetCompoParam() Else If Not IsNothing(Me.refJambCompo) Then Map.refPartPageVM.CurrPart.RemoveRefCompo(Me.refJambCompo) Me.refJambCompo = Nothing End If End If End If End Sub ' setto la lista dei parametri da caricare 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 ' ripulisco la lista dei parametri sempre! m_CompoParamList.Clear() If String.IsNullOrWhiteSpace(DefaultConfig) Then S_CHAPTER = S_GR_PARAM_DEFAULT & "1" Else S_CHAPTER = S_GR_PARAM_DEFAULT & DefaultConfig End If ' leggo il nome del parametro che serirà a riordinare le quote in fase di stampa GetPrivateProfileTidyLayer(S_CHAPTER, K_PARAM_LAYER, m_TidyParam, CurrConfig) 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 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 Me.CompoParamList.Insert(ParamIndex - 1, NewCompoParam) Else ' se esiste ma è diverso il nome DDF o il tipo If m_CompoParamList(ParamIndex - 1).DDFName <> NewCompoParam.DDFName OrElse Not Object.ReferenceEquals(m_CompoParamList(ParamIndex - 1).GetType(), NewCompoParam.GetType()) Then ' creo il nuovo parametro m_CompoParamList.RemoveAt(ParamIndex - 1) m_CompoParamList.Insert(ParamIndex - 1, NewCompoParam) End If End If End If End Sub #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 = NGE_EXTENSION 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 If Not Path.GetExtension(CurrItemPath).ToLower = LUA_EXTENSION Then CurrItemPath &= LUA_EXTENSION End If ' controllo che esiste il file altrimenti esco If Not File.Exists(CurrItemPath) Then Return Assembly.BuiltReffCompo = False CurrRefCompo.TemplateSelItem = value ' carico un vettore con le stringhe del file corrente 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 If Not String.IsNullOrWhiteSpace(ErrorList) Then EgtOutLog(ErrorList) 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 ' Utilizzo nome DDF e 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 nome è numerico Dim nInd As Integer If Integer.TryParse(sName, nInd) Then ' recupero il messaggio Dim sMsg As String = EgtMsg(nInd) ' se non esiste lo sostituico con il nome Dim ErrorMsg As String = "Msg" & Trim(sName) If String.Equals(sMsg, ErrorMsg) Then ' Errore nella lettura dei messaggi. Non esiste corrispondenza con il numero {0}. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50119), sName)) Return sDDFName ' altrimenti lo restituisco Else Return sMsg End If ' Altrimenti restituisco il nome Else Return sName End If End Function Public Function ReadParam(sReadLine As String, ByRef NewCompoParam As CompoParam, ByRef sErrorList As String) As Boolean ' Se linea vuota, esco con errore If String.IsNullOrWhiteSpace(sReadLine) Then sErrorList = ConcatErrorString(sErrorList, "Empty Line") Return False End If ' Scompongo la linea nelle sue parti Dim sItems() As String = sReadLine.Split(";"c) ' Devono esserci almeno due parti If sItems.Count() < 2 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), m_CompoType.DDFName, sItems(0)) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' La prima parte definisce la categoria Select Case Trim(sItems(0)) Case INI_COMBOBOX ' NomeDDF e Nome del combo Dim sComboList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sComboList.Count() >= 1 Then sDDFName = Trim(sComboList(0)) If sComboList.Count() >= 2 Then sName = Trim(MsgControl(sComboList(0), sComboList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sComboList(0), m_CompoType.Path)) End If ' La combobox deve contenere almeno un elemento "ComboBox; NomeDDF/Nome; NomeDDFItem/NomeItem, ...." If sItems.Count < 3 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sDDFName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' Ricavo i diversi item 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 NomeDDFItem If ComboItem.Count >= 1 Then DDFComboItemList.Add(Trim(ComboItem(0))) ' se esiste anche il NomeItem If ComboItem.Count >= 2 Then ' carico la lista con i nomi ComboItemList.Add(Trim(MsgControl(ComboItem(0), ComboItem(1), sErrorList))) Else ' se esiste solo un nome considero sia il nome DDF ComboItemList.Add(Trim(ComboItem(0))) ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), ComboItem(0), m_CompoType.Path)) End If Next ' Creo il parametro NewCompoParam = New ComboBoxParam(sDDFName, sName, Me, ComboItemList, DDFComboItemList, ComboItemList(0)) Return True Case INI_COMBOBOX_ONOFF ' NomeDDF e Nome del combo Dim sComboList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sComboList.Count() >= 1 Then sDDFName = Trim(sComboList(0)) If sComboList.Count() >= 2 Then sName = Trim(MsgControl(sComboList(0), sComboList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sComboList(0), m_CompoType.Path)) End If ' La combobox deve contenere almeno un elemento "ComboBox; NomeDDF/Nome; NomeDDFItem/NomeItem, ...." If sItems.Count < 3 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sDDFName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' Ricavo i diversi item 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 NomeDDFItem If ComboItem.Count >= 1 Then DDFComboItemList.Add(Trim(ComboItem(0))) ' se esiste anche il NomeItem If ComboItem.Count >= 2 Then ' carico la lista con i nomi ComboItemList.Add(Trim(MsgControl(ComboItem(0), ComboItem(1), sErrorList))) Else ' se esiste solo un nome considero sia il nome DDF ComboItemList.Add(Trim(ComboItem(0))) ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), ComboItem(0), m_CompoType.Path)) End If Next ' Creo il parametro NewCompoParam = New ComboBoxOnOffParam(sDDFName, sName, Me, ComboItemList, DDFComboItemList, ComboItemList(0)) Return True Case INI_TEXTBOX ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sDDFName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double If StringToDouble(sItems(2), dDefaultValue) AndAlso dDefaultValue < dHeight Then Dim sDefaultValue As String = DoubleToString(dDefaultValue, 5) NewCompoParam = New TextBoxParam(sDDFName, sName, Me, sDefaultValue, Nothing, Nothing) Return True Else NewCompoParam = New TextBoxParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nell'espressione {0}. {1} non associa nulla. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))) Return True End If Case INI_TEXTBOX_ONOFF ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sDDFName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double If StringToDouble(sItems(2), dDefaultValue) AndAlso dDefaultValue < dHeight Then Dim sDefaultValue As String = DoubleToString(dDefaultValue, 5) NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, sDefaultValue, Nothing, Nothing) Return True Else NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nell'espressione {0}. {1} non associa nulla. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))) Return True End If End Select Return False End Function Public Function ReadParamHardware(sReadLine As String, ByRef NewCompoParam As CompoParam, ByRef sErrorList As String) As Boolean ' Se linea vuota, esco con errore If String.IsNullOrWhiteSpace(sReadLine) Then sErrorList = ConcatErrorString(sErrorList, "Empty Line") Return False End If ' Scompongo la linea nelle sue parti Dim sItems() As String = sReadLine.Split(";"c) ' Devono esserci almeno due parti If sItems.Count() < 2 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), m_CompoType.DDFName, sItems(0)) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' La prima parte definisce la categoria Select Case Trim(sItems(0)) Case INI_COMBOBOX ' NomeDDF e Nome del combo "ComboBox; LG/geometry name; MortiseHinge/MortiseHinge, LG/LG" Dim sComboList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sComboList.Count() >= 1 Then sDDFName = Trim(sComboList(0)) If sComboList.Count() >= 2 Then sName = Trim(MsgControl(sComboList(0), sComboList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sComboList(0), m_CompoType.Path)) End If ' La combobox deve contenere almeno un elemento "ComboBox; NomeDDF/Nome; NomeDDFItem/NomeItem, ...." If sItems.Count < 3 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sDDFName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' Ricavo i diversi item 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 NomeDDFItem If ComboItem.Count >= 1 Then DDFComboItemList.Add(Trim(ComboItem(0))) ' se esiste anche il NomeItem If ComboItem.Count >= 2 Then ' carico la lista con i nomi ComboItemList.Add(Trim(MsgControl(ComboItem(0), ComboItem(1), sErrorList))) Else ' se esiste solo un nome considero sia il nome DDF ComboItemList.Add(Trim(ComboItem(0))) ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), ComboItem(0), m_CompoType.Path)) End If Next ' Creo il parametro NewCompoParam = New ComboBoxParam(sDDFName, sName, Me, ComboItemList, DDFComboItemList, ComboItemList(0)) Return True Case INI_COMBOBOX_LUA ' NomeDDF e Nome del combo "ComboBoxLua; LG/geometry name; key1/L" Dim sComboList() As String = sItems(1).Split("/"c) Dim sLuaName As String = String.Empty Dim sName As String = String.Empty If sComboList.Count() >= 1 Then sLuaName = Trim(sComboList(0)) If sComboList.Count() >= 2 Then sName = Trim(MsgControl(sComboList(0), sComboList(1), sErrorList)) Else sName = sLuaName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sComboList(0), m_CompoType.Path)) End If ' La combobox deve contenere almeno un elemento "ComboBoxLua; NomeDDF/Nome; Key/NomePara,etro, ...." Dim sNameGeometry As String = String.Empty If sItems.Count < 3 Then If Not CompoMatch.ReserchInTable(Me.CompoType.DDFName, "", sNameGeometry) Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sLuaName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If End If ' prima chiave di ricerca trovata If sItems.Count = 3 Then Dim sKey1() As String = sItems(2).Split("/"c) Dim sKeyParamLua As String = String.Empty Dim sKey1Param As String = String.Empty If sKey1.Count() >= 1 Then sKey1Param = Trim(sKey1(0)) If sKey1.Count() >= 2 Then sKeyParamLua = Trim(sKey1(1)) Else sKeyParamLua = Trim(sKey1(0)) End If If Not CompoMatch.ReserchInTable(Me.CompoType.DDFName, sKeyParamLua, sNameGeometry) Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sLuaName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If End If ' Ricavo i diversi item If String.IsNullOrEmpty(sNameGeometry) Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sLuaName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If Dim sComboItemList() As String = sNameGeometry.Split(","c) Dim ComboItemList As New List(Of String) Dim LuaComboItemList As New List(Of String) For ItemIndex = 0 To sComboItemList.Count - 1 ComboItemList.Add(Trim(sComboItemList(ItemIndex))) LuaComboItemList.Add(Trim("'" & sComboItemList(ItemIndex) & "'")) Next ' Creo il parametro NewCompoParam = New ComboBoxParam(sLuaName, sName, Me, ComboItemList, LuaComboItemList, ComboItemList(0)) Return True Case INI_COMBOBOX_ONOFF ' NomeDDF e Nome del combo Dim sComboList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sComboList.Count() >= 1 Then sDDFName = Trim(sComboList(0)) If sComboList.Count() >= 2 Then sName = Trim(MsgControl(sComboList(0), sComboList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sComboList(0), m_CompoType.Path)) End If ' La combobox deve contenere almeno un elemento "ComboBox; NomeDDF/Nome; NomeDDFItem/NomeItem, ...." If sItems.Count < 3 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sDDFName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If ' Ricavo i diversi item 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 NomeDDFItem If ComboItem.Count >= 1 Then DDFComboItemList.Add(Trim(ComboItem(0))) ' se esiste anche il NomeItem If ComboItem.Count >= 2 Then ' carico la lista con i nomi ComboItemList.Add(Trim(MsgControl(ComboItem(0), ComboItem(1), sErrorList))) Else ' se esiste solo un nome considero sia il nome DDF ComboItemList.Add(Trim(ComboItem(0))) ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), ComboItem(0), m_CompoType.Path)) End If Next ' Creo il parametro NewCompoParam = New ComboBoxOnOffParam(sDDFName, sName, Me, ComboItemList, DDFComboItemList, ComboItemList(0)) Return True Case INI_TEXTBOX ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sLuaName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sLuaName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sLuaName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxParam(sLuaName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' Se ci sono almeno 3 elementi "TextBox; NomeDDF/Nome; inch/4.5000" ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double = 0.0 Dim sTypeValue As String = String.Empty Dim sValue As String = String.Empty Dim sValueList() As String = sItems(2).Split("/"c) If sValueList.Count() >= 1 Then sValue = Trim(sValueList(0)) If sValueList.Count() >= 2 Then sTypeValue = Trim(sValueList(1)) Else sTypeValue = ConstGen.MM End If ' a seconda del tipo Eseguo il controllo della variabile Dim sDefaultValue As String = "0.0" Select Case sTypeValue Case ConstGen.VAL_DOUBLE If StringToDouble(sValue, dDefaultValue) Then sDefaultValue = DoubleToString(dDefaultValue, 5) Else Return False End If Case ConstGen.INCHES ' ricevo un valore in Inches If OptionModule.m_SelectedMeasureUnit = ConstGen.MM Then ' converto il valore caricato in mm If StringToLen(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa sDefaultValue = DoubleToString(dDefaultValue, 4) Else ' altrimenti esco Return False End If Else ' non deovo convertire il valore caricato perchè è nella stessa unità dell'interfaccia If StringToDouble(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa sDefaultValue = DoubleToString(dDefaultValue, 4) Else Return False End If End If Case ConstGen.MM If Not StringToDouble(sValue, dDefaultValue) Then Return False ' ricevo un numero in mm e lo voglio convertire nell'unità dell'interfaccia sDefaultValue = LenToString(dDefaultValue, 4) Case ConstGen.VAL_STING sDefaultValue = sValue Case Else ' il tipo non è tra quelli indicati sopra ' Errore nell'espressione {0}. {1} non associa nulla. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))) Return False End Select NewCompoParam = New TextBoxParam(sLuaName, sName, Me, sDefaultValue, Nothing, Nothing, sTypeValue) Return True Case INI_TEXTBOX_ONOFF ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sDDFName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sDDFName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sDDFName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double If StringToDouble(sItems(2), dDefaultValue) AndAlso dDefaultValue < dHeight Then Dim sDefaultValue As String = DoubleToString(dDefaultValue, 5) NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, sDefaultValue, Nothing, Nothing) Return True Else NewCompoParam = New TextBoxOnOffParam(sDDFName, sName, Me, "0.000", Nothing, Nothing) ' Errore nell'espressione {0}. {1} non associa nulla. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50147), NewCompoParam.Name, sItems(2))) Return True End If Case INI_TEXTBOXDGC ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sLuaName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sLuaName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sLuaName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxOnOffParam(sLuaName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double = 0.0 Dim sTypeValue As String = String.Empty Dim sValue As String = String.Empty Dim sValueList() As String = sItems(2).Split("/"c) If sValueList.Count() >= 1 Then sValue = Trim(sValueList(0)) If sValueList.Count() >= 2 Then sTypeValue = Trim(sValueList(1)) Else sTypeValue = ConstGen.MM End If ' il tipo di parametro che posso accettare è mm o inch Dim sDefaultValue As String = "0.0" Select Case sTypeValue Case ConstGen.INCHES ' ricevo un valore in Inches If OptionModule.m_SelectedMeasureUnit = ConstGen.MM Then ' converto il valore caricato in mm If StringToLen(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa per interfaccia sDefaultValue = DoubleToString(dDefaultValue, 4) Else ' altrimenti esco Return False End If Else ' non deovo convertire il valore caricato perchè è nella stessa unità dell'interfaccia If StringToDouble(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa per interfaccia sDefaultValue = DoubleToString(dDefaultValue, 4) Else Return False End If End If Case ConstGen.MM If Not StringToDouble(sValue, dDefaultValue) Then Return False ' ricevo un numero in mm e lo voglio convertire nell'unità dell'interfaccia sDefaultValue = LenToString(dDefaultValue, 4) End Select If sItems.Count < 4 Then ' significa che si comporta come fosse una semplice TextBox NewCompoParam = New TextBoxParam(sLuaName, sName, Me, sDefaultValue, Nothing, Nothing, sTypeValue) Return True End If Dim sConst() As String = sItems(3).Split(","c) Dim sListConst As New List(Of String) sListConst.Add("0") ' il primo parametro della lista deve essere sempre quello nullo For Index As Integer = 0 To sConst.Count - 1 If Trim(sConst(Index)) = "0" Then Continue For sListConst.Add(Trim(sConst(Index))) Next NewCompoParam = New TextBoxDGCParam(sLuaName, sName, Me, sDefaultValue, Nothing, Nothing, sListConst, sTypeValue) Return True Case INI_TEXTBOXTHICKNESS ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sLuaName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sLuaName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sLuaName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If ' Se ci sono 2 elementi "TextBox; NomeDDF/Nome" If sItems.Count < 3 Then NewCompoParam = New TextBoxOnOffParam(sLuaName, sName, Me, "0.000", Nothing, Nothing) ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) Return True End If ' recupero il valore di default Dim dHeight As Double = 500 ' Attenzione ai mm Dim dDefaultValue As Double = 0.0 Dim sTypeValue As String = String.Empty Dim sValue As String = String.Empty Dim sValueList() As String = sItems(2).Split("/"c) If sValueList.Count() >= 1 Then sValue = Trim(sValueList(0)) If sValueList.Count() >= 2 Then sTypeValue = Trim(sValueList(1)) Else sTypeValue = ConstGen.MM End If ' il tipo di parametro che posso accettare è mm o inch Dim sDefaultValue As String = "0.0" Select Case sTypeValue Case ConstGen.INCHES ' ricevo un valore in Inches If OptionModule.m_SelectedMeasureUnit = ConstGen.MM Then ' converto il valore caricato in mm If StringToLen(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa per interfaccia sDefaultValue = DoubleToString(dDefaultValue, 4) Else ' altrimenti esco Return False End If Else ' non deovo convertire il valore caricato perchè è nella stessa unità dell'interfaccia If StringToDouble(sValue, dDefaultValue) Then ' restituisco il valore convertito in mm in stringa per interfaccia sDefaultValue = DoubleToString(dDefaultValue, 4) Else Return False End If End If Case ConstGen.MM If Not StringToDouble(sValue, dDefaultValue) Then Return False ' ricevo un numero in mm e lo voglio convertire nell'unità dell'interfaccia sDefaultValue = LenToString(dDefaultValue, 4) End Select Dim sListConst As New List(Of ItemConstThickness)({New ItemConstThickness("thru", -1), New ItemConstThickness("half", -0.5), New ItemConstThickness(OptionModule.m_SelectedMeasureUnit, 0)}) NewCompoParam = New TextBoxThicknessParam(sLuaName, sName, Me, sDefaultValue, Nothing, Nothing, sListConst, sTypeValue) Return True Case INI_CHECKBOX ' NomeDDF e Nome del Text Dim sTextList() As String = sItems(1).Split("/"c) Dim sLuaName As String = String.Empty Dim sName As String = String.Empty If sTextList.Count() >= 1 Then sLuaName = Trim(sTextList(0)) If sTextList.Count() >= 2 Then sName = Trim(MsgControl(sTextList(0), sTextList(1), sErrorList)) Else sName = sLuaName ' Errore nella lettura del nome {0} in {1}. Attesa una corrispondenza numerica. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50120), sTextList(0), m_CompoType.Path)) End If If sItems.Count < 3 Then ' Errore nella lettura {0} nel parametro {1} della componente: non esiste. Dim sError As String = String.Format(EgtMsg(50121), sLuaName, m_CompoType.DDFName) sErrorList = ConcatErrorString(sErrorList, sError) Return False End If Dim nInd As Integer Dim bCheck As Boolean = False If Integer.TryParse(sItems(2), nInd) Then If nInd = 1 Then bCheck = True Else bCheck = False Else ' Errore nella lettura {0} nel parametro {1} della componente: non esiste il valore. sErrorList = ConcatErrorString(sErrorList, String.Format(EgtMsg(50125), sName, m_CompoType.DDFName)) End If NewCompoParam = New CheckBoxParam(sLuaName, sName, Me, bCheck) Return True End Select Return False End Function 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_TidyParam As String Public Property TidyParam As String Get Return m_TidyParam End Get Set(value As String) m_TidyParam = value End Set End Property 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) m_CompoType = CompoType End Sub #Region "COMMANDS" #Region "DeleteCommand" ''' ''' Returns a command that do Exec. ''' 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 ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub Delete() Dim DeleteNameHardware As String = Me.CompoType.Name Map.refPartPageVM.CurrPart.RemoveCompo(Me) Map.refSceneManagerVM.RefreshBtn() Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True Dim bExist As Boolean = False ' aggiorno lista hardware di quotatura Map.refDimensioningPanelVM.LoadHardwareDimList() 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 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 ' utilizzato negli Hardware Private m_TypeVar As String Public Property TypeVar As String Get Return m_TypeVar End Get Set(value As String) m_TypeVar = 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 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") Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = 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, Map.refPartPageVM.CurrPart.TypePart) Then Return If Not UpdateParam() Then MessageBox.Show("No matching param ", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) ResetCompoParam() End Set End Property Public Sub SetValue(sValue As String) m_Value = sValue NotifyPropertyChanged("ToolTipValue") NotifyPropertyChanged("Value") 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 ' utilizzata per le text degli hardware che possono ricevere diversi tipi di valore Sub New(sDDFName As String, sName As String, CurrCompo As Compo, sValue As String, ComboBox As ComboBoxParam, ComboValuelList As List(Of String), TypeVar As String) MyBase.New(sDDFName, sName, CurrCompo) m_Value = sValue m_ComboBox = ComboBox m_ComboValuelList = ComboValuelList m_TypeVar = TypeVar 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 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 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 ' controllo che la chiamata avvenga da una componente sulla porta? Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True Dim CmpPar As CompoParam = Me Dim IndexP As Integer = CurrCompo.CompoParamList.IndexOf(Me) ' se il nome della combobox è side allora ed esiset un riferimento If CmpPar.DDFName.ToLower = K_SIDE.ToLower And Not IsNothing(CurrCompo.refJambCompo) Then ' riposiziono la componente dopo averla eliminata dal jamb su cui si trova Map.refPartPageVM.CurrPart.RemoveRefCompo(CurrCompo.refJambCompo) CurrCompo.SetTemplateSelItem(CurrCompo.TemplateSelItem) End If Map.refSceneManagerVM.RefreshBtn() End Set End Property Friend Sub SetSelItem(value As String) m_SelItem = value NotifyPropertyChanged("SelItem") 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 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 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 Map.refSceneManagerVM.RefreshBtn() End Set End Property Public Sub SetIsActive(IsActive As Boolean) m_IsActive = IsActive 'NotifyPropertyChanged("IsActive") End Sub 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 Public Class TextBoxDGCParam Inherits TextBoxParam Private m_ConstList As List(Of String) Public Property ConstList As List(Of String) Get Return m_ConstList End Get Set(value As List(Of String)) m_ConstList = value End Set End Property Private m_SelConst As String Public Property SelConst As String Get Return m_SelConst End Get Set(value As String) m_SelConst = value Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True End Set End Property Public Sub SetConst(SelConst As String) m_SelConst = SelConst NotifyPropertyChanged("SelConst") End Sub Sub New(sDDFName As String, sName As String, CurrCompo As Compo, sValue As String, ComboBox As ComboBoxParam, ComboValuelList As List(Of String), ConstList As List(Of String), TypeVar As String) MyBase.New(sDDFName, sName, CurrCompo, sValue, ComboBox, ComboValuelList, TypeVar) m_ConstList = ConstList m_SelConst = m_ConstList(0) End Sub End Class Public Class TextBoxThicknessParam Inherits TextBoxParam Private m_ConstList As List(Of ItemConstThickness) Public Property ConstList As List(Of ItemConstThickness) Get Return m_ConstList End Get Set(value As List(Of ItemConstThickness)) m_ConstList = value End Set End Property Private m_SelConst As ItemConstThickness Public Property SelConst As ItemConstThickness Get Return m_SelConst End Get Set(value As ItemConstThickness) m_SelConst = value Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True Map.refSceneManagerVM.RefreshBtn() If m_SelConst.dValue = 0 Then IsEnableMeasure = True Else IsEnableMeasure = False End If End Set End Property Public Sub SetConst(SelConst As ItemConstThickness) m_SelConst = SelConst If m_SelConst.dValue = 0 Then IsEnableMeasure = True Else IsEnableMeasure = False End If NotifyPropertyChanged("SelConst") End Sub Private m_IsEnableMeasure As Boolean = False Public Property IsEnableMeasure As Boolean Get Return m_IsEnableMeasure End Get Set(value As Boolean) m_IsEnableMeasure = value NotifyPropertyChanged("IsEnableMeasure") 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), ConstList As List(Of ItemConstThickness), TypeVar As String) MyBase.New(sDDFName, sName, CurrCompo, sValue, ComboBox, ComboValuelList, TypeVar) m_ConstList = ConstList m_SelConst = m_ConstList(2) End Sub End Class Public Class CheckBoxParam Inherits CompoParam Implements INotifyPropertyChanged Private m_IsChecked As Boolean = False Public Property IsChecked As Boolean Get Return m_IsChecked End Get Set(value As Boolean) m_IsChecked = value Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified = True Map.refSceneManagerVM.RefreshBtn() End Set End Property Public Sub SetIsChecked(IsChecked As Boolean) m_IsChecked = IsChecked NotifyPropertyChanged("IsChecked") End Sub Sub New(sDDFName As String, sName As String, CurrCompo As Compo, IsChecked As Boolean) MyBase.New(sDDFName, sName, CurrCompo) m_IsChecked = IsChecked 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 ComboBoxOnOffParam Inherits ComboBoxParam 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 Map.refSceneManagerVM.RefreshBtn() End Set End Property Public Sub SetIsActive(IsActive As Boolean) m_IsActive = IsActive 'NotifyPropertyChanged("IsActive") 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, ItemList, ItemListDDF, sSelItem) End Sub End Class Public Class ItemConstThickness 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_dValue As Double Public Property dValue As Double Get Return m_dValue End Get Set(value As Double) m_dValue = value End Set End Property Sub New(Message As String, dVal As Double) m_Name = Message m_dValue = dVal End Sub End Class