Imports EgtBEAMWALL.Core Imports EgtUILib.EgtInterface Imports EgtWPFLib5 Public Class FeatureListManagerVM Inherits VMBase #Region "FIELDS & PROPERTIES" Public ReadOnly Property ViewPage_Visibility As Visibility Get Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property PartIsSelected As Boolean Get Return Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) End Get End Property Public ReadOnly Property FeatureIsSelected As Boolean Get Return PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) End Get End Property Public ReadOnly Property CopyFeature_IsEnabled As Boolean Get Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End Get End Property Public ReadOnly Property MacroFeature_IsEnabled As Boolean Get Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End Get End Property Public ReadOnly Property AddFeature_IsEnabled As Boolean Get Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 End Get End Property Public ReadOnly Property RemoveFeature_IsEnabled As Boolean Get Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End Get End Property Private m_cmdCopyFeature As ICommand Private m_cmdMacroFeature As ICommand Private m_cmdAddFeature As ICommand Private m_cmdRemoveFeature As ICommand #End Region ' Fields & Properties #Region "Messages" Public ReadOnly Property CopyFeature_ToolTip As String Get Return EgtMsg(61908) End Get End Property Public ReadOnly Property MacroFeature_ToolTip As String Get Return EgtMsg(61909) End Get End Property Public ReadOnly Property AddFeature_ToolTip As String Get Return EgtMsg(61910) End Get End Property Public ReadOnly Property RemoveFeature_ToolTip As String Get Return EgtMsg(61911) End Get End Property #End Region ' Messages #Region "CONSTRUCTOR" Sub New() Map.SetRefFeatureListManagerVM(Me) End Sub #End Region ' Constructor #Region "METHODS" Friend Sub UpdateView() NotifyPropertyChanged(NameOf(ViewPage_Visibility)) End Sub Friend Sub SetLeftPanelIsEnabled(bIsEnabled As Boolean) NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) End Sub Friend Sub PartShowAllChanged() NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) End Sub Friend Sub FeatureSelectionChanged() NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) End Sub #End Region ' Methods #Region "COMMANDS" #Region "CopyFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property CopyFeature_Command As ICommand Get If m_cmdCopyFeature Is Nothing Then m_cmdCopyFeature = New Command(AddressOf CopyFeature) End If Return m_cmdCopyFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub CopyFeature() If IsNothing(ProjectManagerVM.CurrProj) Then Return Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart If IsNothing(SelPart) Then Return Dim SelFeature As BTLFeatureVM = SelPart.SelBTLFeatureVM If IsNothing(SelFeature) Then Return ' creo copia Dim NewFeature = SelFeature.Copy() If Not IsNothing(NewFeature) Then SelPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeature) EgtDuploSetModified(SelPart.nPartId) End If SelPart.ResetCalcPart() End Sub #End Region ' CopyFeature #Region "MacroFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MacroFeature_Command As ICommand Get If m_cmdMacroFeature Is Nothing Then m_cmdMacroFeature = New Command(AddressOf MacroFeature) End If Return m_cmdMacroFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MacroFeature() If IsNothing(ProjectManagerVM.CurrProj) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return ' apro finestra di creazione macro Dim MacroFeatureWndVM As New MacroFeatureWndVM() Dim MacroFeatureWnd As New MacroFeatureWndV(Application.Current.MainWindow, MacroFeatureWndVM) If MacroFeatureWnd.ShowDialog() Then End If End Sub #End Region ' MacroFeature #Region "AddFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property AddFeature_Command As ICommand Get If m_cmdAddFeature Is Nothing Then m_cmdAddFeature = New Command(AddressOf AddFeature) End If Return m_cmdAddFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub AddFeature(ByVal param As Object) If IsNothing(ProjectManagerVM.CurrProj) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return ' apro finestra di definizione nuova feature Dim AddFeatureWndVM As New AddFeatureWndVM() Dim AddFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) If AddFeatureWnd.ShowDialog() Then Dim NewFeat As BTLFeatureM Dim nNewFeatureId As Integer = 0 Dim bMacroFlag As Boolean = False ' verifico se una Macro è selezionata If AddFeatureWndVM.MacroList.Count > 0 AndAlso AddFeatureWndVM.nSelMacro >= 0 Then ' Creo nuova feature sulla base della Macro selezionata ' Creo table e setto variabili EgtLuaCreateGlobTable("MACRO") EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) EgtLuaSetGlobNumVar("MACRO.W", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW) EgtLuaSetGlobNumVar("MACRO.H", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH) EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) Dim bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(AddFeatureWndVM.nSelMacro)) ' Leggo variabili EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) ' Reset lua EgtLuaResetGlobVar("MACRO") If Not bOk Then MessageBox.Show(EgtMsg(61869), EgtMsg(30007)) Return End If bMacroFlag = True Else ' Creo nuova feature (Macro non selezionata) NewFeat = BTLFeatureM.CreateBTLFeature(AddFeatureWndVM.nSelPRC.nPRC, AddFeatureWndVM.nSelPRC.nGRP, AddFeatureWndVM.nSelPRC.nSIDE) NewFeat.SetDefaultValues() Dim vPar() As Double = Nothing Dim sPar As String = String.Empty Dim vParQ() As String = Nothing NewFeat.CalcParamArray(vPar, sPar, vParQ) ' aggiorno la feature con nuovo valore EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, "", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId(), New Frame3d(), vPar, sPar, vParQ, GDB_ID.NULL, GDB_ID.NULL) bMacroFlag = False End If ' se è stata creata If nNewFeatureId <> GDB_ID.NULL Then EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) ' la aggiungo a struttura BTL corrente NewFeat = BTLFeatureM.CreateBTLFeature(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM, nNewFeatureId) If Not bMacroFlag Then NewFeat.SetDefaultValues() Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.AddBTLFeature(NewFeat) Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeat) Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() End If End If End Sub #End Region ' AddFeature #Region "RemoveFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemoveFeature_Command As ICommand Get If m_cmdRemoveFeature Is Nothing Then m_cmdRemoveFeature = New Command(AddressOf RemoveFeature) End If Return m_cmdRemoveFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemoveFeature() If IsNothing(ProjectManagerVM.CurrProj) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then Return If EgtBeamEraseProcess(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId) Then EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) ' rimuovo dalla lista feature Dim Index As Integer = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.IndexOf(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) If Index = 0 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 0 Then Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(0) Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing End If ElseIf Index = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 1 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 1 Then Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 2) Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing End If Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Index - 1) End If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.RemoveAt(Index) EgtDraw() Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() End If End Sub #End Region ' RemoveFeature #End Region ' Commands End Class