Imports EgtBEAMWALL.Core Imports EgtUILib.EgtInterface Imports EgtWPFLib5 Public Class FeatureListManagerVM Inherits VMBase #Region "FIELDS & PROPERTIES" 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 If Not IsNothing(Map.refBTLPartManagerVM) Then Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End If Return False End Get End Property Public ReadOnly Property MacroFeature_IsEnabled As Boolean Get If Not IsNothing(Map.refBTLPartManagerVM) Then Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End If Return False End Get End Property Public ReadOnly Property AddFeature_IsEnabled As Boolean Get Return PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 1 End Get End Property Public ReadOnly Property RemoveFeature_IsEnabled As Boolean Get If Not IsNothing(Map.refBTLPartManagerVM) Then Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected End If Return False End Get End Property Private m_cmdCopyFeature As ICommand Private m_cmdAddFeature As ICommand Private m_cmdRemoveFeature As ICommand #Region "Messages" Public ReadOnly Property CopyFeature_ToolTip As String Get Return EgtMsg(61908) 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 #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New() Map.SetRefFeatureListManagerVM(Me) End Sub #End Region ' Constructor #Region "METHODS" 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 Private Sub CreateNewFeature(MacroListCount As Integer, nSelMacro As Integer, AddFeatureWndVM As AddFeatureWndVM, nNewFeatureId As Integer, bMacroFlag As Boolean, NewFeat As BTLFeatureM) ' verifico se una Macro è selezionata If MacroListCount > 0 AndAlso nSelMacro >= 0 Then ' Creo nuova feature sulla base della Macro selezionata ' Creo table e setto variabili CreateMacroTable(AddFeatureWndVM) Dim bOk As Boolean If AddFeatureWndVM.nSelMacroDefault >= 0 Then bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroCustomFilePathList(nSelMacro)) Else bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(nSelMacro)) End If ' Leggo variabili EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) ' Reset lua EgtLuaResetGlobVar("MACRO") If Not bOk Then EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, 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) If NewFeat.nPRC = 900 Then NewFeat.sDES = "2" ' aggiorno la feature con nuovo valore EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, NewFeat.sDES, 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 MyMachGroupPanelM.SetDuploModified(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 Sub Private Sub CreateMacroTable(AddFeatureWndVM As AddFeatureWndVM) Dim nMacroW, nMacroH As Integer If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM) Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 0 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 180 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 1 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 3 Then nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH Else nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW End If ElseIf Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 90 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 270 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 1 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 3 Then nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW Else nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH End If Else nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH End If End If EgtLuaCreateGlobTable("MACRO") EgtLuaSetGlobStringVar("MACRO.NAME", AddFeatureWndVM.nSelPRC.sName) EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) EgtLuaSetGlobNumVar("MACRO.W", nMacroW) EgtLuaSetGlobNumVar("MACRO.H", nMacroH) EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) End Sub #End Region ' Methods #Region "COMMANDS" #Region "CopyFeature" 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 Public Sub CopyFeature() 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) MyMachGroupPanelM.SetDuploModified(SelPart.nPartId) End If SelPart.ResetCalcPart() End Sub #End Region ' CopyFeature #Region "AddFeature" 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 Public Sub AddFeature(ByVal param As Object) If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return ' apro finestra di definizione nuova feature Dim AddFeatureWndVM As New AddFeatureWndVM() Dim NewFeat As BTLFeatureM = Nothing Dim nNewFeatureId As Integer = 0 Dim bMacroFlag As Boolean = False Dim AddNewFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) If AddNewFeatureWnd.ShowDialog() Then ' verifico se una Macro è selezionata If AddFeatureWndVM.nSelMacroDefault >= 0 Then CreateNewFeature(AddFeatureWndVM.MacroDefaultList.Count, AddFeatureWndVM.nSelMacroDefault, AddFeatureWndVM, nNewFeatureId, bMacroFlag, NewFeat) Else CreateNewFeature(AddFeatureWndVM.MacroCustomList.Count, AddFeatureWndVM.nSelMacroCustom, AddFeatureWndVM, nNewFeatureId, bMacroFlag, NewFeat) End If End If End Sub #End Region ' AddFeature #Region "RemoveFeature" 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 Public Sub RemoveFeature() 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 MyMachGroupPanelM.SetDuploModified(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