Imports EgtWPFLib5 Imports EgtUILib Imports Microsoft.Win32 Imports System.IO Public Class SliceManagerVM Inherits VMBase #Region "FIELDS & PROPERTIES" Private Enum CalcSteps As Integer NULL = 0 CALC_INTERSECTIONS = 1 SLICING = 2 CALC_PATHS = 3 CALC_TOOLPATHS = 4 CALC_SOLIDS = 5 CALCTSF = 6 GENERATE = 7 End Enum ' variabile che indica se sono in corso i calcoli Private m_bCalculating As Boolean = False Friend ReadOnly Property bCalculating As Boolean Get Return m_bCalculating End Get End Property #Region "ProgressBar" ' Funzioni di callback per output in interfaccia da LUA Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents) Private m_bSlice As Boolean = False Private m_bCalcTFS As Boolean = False Private m_bGenerate As Boolean = False Private m_bCalcSolid As Boolean = False Friend Sub SetCalcSolid(value As Boolean) m_bCalcSolid = value End Sub Private m_SliceManagerState As CalcSteps Private m_CalcStep As CalcSteps = CalcSteps.NULL Public ReadOnly Property sLoadingText As String Get Select Case m_SliceManagerState Case CalcSteps.CALC_INTERSECTIONS Return "Calculating Intersections..." Case CalcSteps.SLICING Return "Slicing..." Case CalcSteps.CALC_PATHS Return "Calculating Paths..." Case CalcSteps.CALC_TOOLPATHS Return "Calculating Toolpaths..." Case CalcSteps.CALC_SOLIDS Return "Calculating Solids..." Case CalcSteps.CALCTSF Return "Calculating Feed & Speed..." Case CalcSteps.GENERATE Return "Generating..." Case Else Return "" End Select End Get End Property Private m_PartialLoading_Value As Integer = 0 Public Property PartialLoading_Value As Integer Get Return m_PartialLoading_Value End Get Set(value As Integer) m_PartialLoading_Value = value End Set End Property Private Sub SetPartialLoading(value As Integer) m_PartialLoading_Value = value NotifyPropertyChanged(NameOf(PartialLoading_Value)) End Sub Private m_MainLoading_Value As Integer = 0 Public Property MainLoading_Value As Integer Get Return m_MainLoading_Value End Get Set(value As Integer) m_MainLoading_Value = value End Set End Property Private Sub SetMainLoadingValue(value As Integer) m_MainLoading_Value = value NotifyPropertyChanged(NameOf(MainLoading_Value)) End Sub Private m_Loading_Visibility As Visibility = Visibility.Collapsed Public Property Loading_Visibility As Visibility Get Return m_Loading_Visibility End Get Set(value As Visibility) m_Loading_Visibility = value End Set End Property Friend Sub SetLoadingVisibility(bIsVisible As Boolean) m_Loading_Visibility = If(bIsVisible, Visibility.Visible, Visibility.Collapsed) NotifyPropertyChanged(NameOf(Loading_Visibility)) End Sub #End Region ' ProgressBar Private m_dTime As Double = 0 Public ReadOnly Property ghTime As String Get Dim dtTime As TimeSpan = TimeSpan.FromSeconds(m_dTime) Return Math.Floor(dtTime.TotalHours) & "hours " & Math.Floor(dtTime.Minutes) & "min " & Math.Ceiling(dtTime.Seconds) & "sec" End Get End Property Private m_dMass As Double = 0 Public ReadOnly Property ghMass As String Get Return DoubleToString(m_dMass, 1) & " kg" End Get End Property Public ReadOnly Property Time_Visibility As Visibility Get Return If(m_dTime > 0, Visibility.Visible, Visibility.Collapsed) End Get End Property Public ReadOnly Property Mass_Visibility As Visibility Get Return If(m_dMass > 0, Visibility.Visible, Visibility.Collapsed) End Get End Property Private m_Buttons_IsEnabled As Boolean = True Public ReadOnly Property Buttons_IsEnabled As Boolean Get Return m_Buttons_IsEnabled End Get End Property Friend Sub SetButtonsIsEnabled(value As Boolean) m_Buttons_IsEnabled = value NotifyPropertyChanged(NameOf(Buttons_IsEnabled)) End Sub Private m_ModifyMode_Visibility As Visibility = Visibility.Collapsed Public ReadOnly Property ModifyMode_Visibility As Visibility Get Return m_ModifyMode_Visibility End Get End Property Private m_SliceMode_Visibility As Visibility = Visibility.Collapsed Public ReadOnly Property SliceMode_Visibility As Visibility Get Return m_SliceMode_Visibility End Get End Property ' Definizione comandi Private m_cmdSlice As ICommand Private m_cmdSimulate As ICommand Private m_cmdUpdate As ICommand Private m_cmdGenerate As ICommand Private m_cmdExit As ICommand #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTORS" Sub New() ' Creo riferimento a questa classe in EgtCAM5Map Map.SetRefSliceManagerVM(Me) ' Installo funzione gestione eventi per lua EgtSetProcessEvents(m_ProcEventsCallback) UpdateState(False) End Sub #End Region ' CONSTRUCTORS #Region "METHODS" Friend Sub UpdateState(bState As Boolean) If bState Then m_ModifyMode_Visibility = Visibility.Collapsed m_SliceMode_Visibility = Visibility.Visible Else m_ModifyMode_Visibility = Visibility.Visible m_SliceMode_Visibility = Visibility.Collapsed End If NotifyPropertyChanged(NameOf(ModifyMode_Visibility)) NotifyPropertyChanged(NameOf(SliceMode_Visibility)) End Sub Friend Sub UpdateTimeAndMass() Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) If nLayTFSCalcId <> GDB_ID.NULL Then EgtGetInfo(nLayTFSCalcId, "Ttot", m_dTime) EgtGetInfo(nLayTFSCalcId, KEY_MASS, m_dMass) Else m_dTime = 0 m_dMass = 0 End If NotifyPropertyChanged(NameOf(ghTime)) NotifyPropertyChanged(NameOf(ghMass)) NotifyPropertyChanged(NameOf(Time_Visibility)) NotifyPropertyChanged(NameOf(Mass_Visibility)) End Sub Private Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer ' Se previsto, imposto progress If nProg >= 0 Then Dim dPartialProgress As Integer = 0 Dim NewSliceManagerState = Math.DivRem(nProg, 100, dPartialProgress) If dPartialProgress = 0 Then m_SliceManagerState = NewSliceManagerState dPartialProgress = 100 Else m_SliceManagerState = NewSliceManagerState + 1 End If 'EgtOutLog("SliceManagerState: " & m_SliceManagerState) NotifyPropertyChanged(NameOf(sLoadingText)) SetPartialLoading(dPartialProgress) 'EgtOutLog("PartialProgress: " & dPartialProgress) Dim dCalcTSFMax As Double = If(m_bSlice, 15, 70) Dim dGenerateMax As Double = If(m_bSlice, 5, 30) Dim dMainProgress As Double = 0 If m_bSlice Then If m_SliceManagerState > CalcSteps.SLICING Then dMainProgress += 10 ElseIf m_SliceManagerState = CalcSteps.SLICING Then dMainProgress += 10 / 100 * dPartialProgress End If If m_SliceManagerState > CalcSteps.CALC_PATHS Then dMainProgress += 10 ElseIf m_SliceManagerState = CalcSteps.CALC_PATHS Then dMainProgress += 10 / 100 * dPartialProgress End If If m_SliceManagerState > CalcSteps.CALC_TOOLPATHS Then dMainProgress += 10 ElseIf m_SliceManagerState = CalcSteps.CALC_TOOLPATHS Then dMainProgress += 10 / 100 * dPartialProgress End If If m_SliceManagerState > CalcSteps.CALC_SOLIDS Then dMainProgress += 50 ElseIf m_SliceManagerState = CalcSteps.CALC_SOLIDS Then dMainProgress += 50 / 100 * dPartialProgress End If End If If m_bCalcSolid Then dMainProgress += dPartialProgress End If If m_bCalcTFS Then If m_SliceManagerState > CalcSteps.CALCTSF Then dMainProgress += dCalcTSFMax ElseIf m_SliceManagerState = CalcSteps.CALCTSF Then dMainProgress += dCalcTSFMax / 100 * dPartialProgress End If End If If m_bGenerate Then If m_SliceManagerState > CalcSteps.GENERATE Then dMainProgress += dGenerateMax ElseIf m_SliceManagerState = CalcSteps.GENERATE Then dMainProgress += dGenerateMax / 100 * dPartialProgress End If End If SetMainLoadingValue(dMainProgress) 'EgtOutLog("MainProgress: " & dMainProgress) End If ' Costringo ad aggiornare UpdateUI() ' Eventuale attesa Threading.Thread.Sleep(nPause) '' Ritorno eventuale stop 'If m_bStopScript Then ' m_bStopScript = False ' Return 1 'Else ' Return 0 'End If Return 0 End Function Friend Function CalcSlice(bGenerate As Boolean, Optional bForceGenerate As Boolean = False) As Boolean ' Verifico nome progetto Dim sCurrProject As String = String.Empty EgtGetCurrFilePath(sCurrProject) If String.IsNullOrWhiteSpace(sCurrProject) Or EgtGetFileType(sCurrProject) <> FT.NGE Then Map.refSceneHostVM.SaveAsProject() End If EgtGetCurrFilePath(sCurrProject) If String.IsNullOrWhiteSpace(sCurrProject) Or EgtGetFileType(sCurrProject) <> FT.NGE Then MessageBox.Show("Save project before calculating slices!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) Return False End If ' mostro barre di caricamento SetLoadingVisibility(True) ' disabilito ProjManager, TopPanel, TFS, Slider, bottoni e uscita dal programma Map.refProjManagerVM.SetProjCmdIsEnabled(False) Map.refTopPanelVM.SetTopPanelIsEnabled(False) Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(False) Map.refTFSEditorVM.SetTFSEditorIsEnabled(False) Map.refSliderManagerVM.SetLayerIndexIsEnabled(False) Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(False) SetButtonsIsEnabled(False) ' verifico se eseguire slice m_bSlice = False m_bCalcTFS = False m_bGenerate = bGenerate Dim bOk As Boolean = True Dim bToRecalcSlice As Boolean = False Dim bToRecalcTFS As Boolean = False Dim bToRecalcGenerate As Boolean = False Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL Dim bTemp As Boolean = False If EgtGetInfo(nPartId, MAC_TORECALC_SLICE, bTemp) AndAlso bTemp Then bToRecalcSlice = True End If If EgtGetInfo(nPartId, MAC_TORECALC_TFS, bTemp) AndAlso bTemp Then bToRecalcTFS = True End If If EgtGetInfo(nPartId, MAC_TORECALC_GENERATE, bTemp) AndAlso bTemp Then bToRecalcGenerate = True End If nPartId = EgtGetNextPart(nPartId) End While If bToRecalcSlice Then m_bSlice = True m_bCalcTFS = True m_bGenerate = bForceGenerate OrElse (bGenerate AndAlso bToRecalcGenerate) Else m_bSlice = False m_bCalcTFS = bToRecalcTFS m_bGenerate = bForceGenerate OrElse (bGenerate AndAlso bToRecalcGenerate) End If If m_bSlice OrElse m_bCalcTFS Then nPartId = EgtGetFirstPart() While nPartId <> GDB_ID.NULL EgtSetInfo(nPartId, MAC_TORECALC_GENERATE, True) nPartId = EgtGetNextPart(nPartId) End While End If ' Aggiorno dati macchina If m_bCalcTFS Then Map.refTFSEditorVM.UpdateSpeedMinMax() ' eseguo calcolo slicing, toolpath e solidi bOk = ExecSlice(m_bSlice, m_bCalcTFS) ' se calcolo andato a buon fine If bOk Then ' rimuovo flag richiesta ricalcolo Dim nCurrPartId As Integer = EgtGetFirstPart() While nCurrPartId <> GDB_ID.NULL ' eseguo rimozione flag If m_bSlice Then EgtRemoveInfo(nCurrPartId, MAC_TORECALC_SLICE) If m_bCalcTFS Then EgtRemoveInfo(nCurrPartId, MAC_TORECALC_TFS) nCurrPartId = EgtGetNextPart(nCurrPartId) End While ' aggiorno massa Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) EgtGetInfo(nLayTFSCalcId, KEY_MASS, m_dMass) NotifyPropertyChanged(NameOf(ghMass)) End If Map.refTFSEditorVM.Refresh() Map.refTopPanelVM.SelPart.RefreshPrintLayers() ' in caso di errore, segnalazione If Not bOk Then MessageBox.Show("Error in slicing! See log file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error) End If If bOk And m_bGenerate Then ' verifico esistenza e correttezza machgroup InitMachGroup(True) ' eseguo generazione CN bOk = ExecGenerate() ' leggo stima tempo e la riporto in layer di calcolo EgtGetInfo(EgtGetFirstMachGroup(), "Ttot", m_dTime) NotifyPropertyChanged(NameOf(ghTime)) Dim nLayTFSCalcId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, LAY_TFSCALC) EgtSetInfo(nLayTFSCalcId, "Ttot", m_dTime) ' se calcolo andato a buon fine, rimuovo flag richiesta ricalcolo If bOk Then Dim nCurrPartId As Integer = EgtGetFirstPart() While nCurrPartId <> GDB_ID.NULL ' eseguo rimozione flag EgtRemoveInfo(nCurrPartId, MAC_TORECALC_GENERATE) nCurrPartId = EgtGetNextPart(nCurrPartId) End While Else MessageBox.Show("Error in NC code generation! See log file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error) End If End If ' Aggiorno intestazione programma Map.refSceneHostVM.EmitTitle() ' nascondo barre di caricamento SetLoadingVisibility(False) ' riabilito ProjManager, TopPanel e uscita dal programma Map.refProjManagerVM.SetProjCmdIsEnabled(True) Map.refTopPanelVM.SetTopPanelIsEnabled(True) Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(True) Map.refTFSEditorVM.SetTFSEditorIsEnabled(True) Map.refSliderManagerVM.SetLayerIndexIsEnabled(True) Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(True) SetButtonsIsEnabled(True) m_bSlice = False m_bCalcTFS = False m_bGenerate = False Return bOk End Function Friend Sub InitMachGroup(bGenerate As Boolean) If bGenerate Then Dim nMachGroupId As Integer = EgtGetFirstMachGroup() While nMachGroupId <> GDB_ID.NULL EgtRemoveMachGroup(nMachGroupId) nMachGroupId = EgtGetFirstMachGroup() End While ' Definisco e posiziono il grezzo sulla tavola EgtAddMachGroup("3dPrint") EgtSetTable("Tab") For Each CurrPart In Map.refTopPanelVM.PartList Dim b3Part As New BBox3d Dim b3PrintSolid As New BBox3d EgtGetBBoxGlob(CurrPart.nPartId, GDB_BB.STANDARD, b3Part) EgtGetBBoxGlob(CurrPart.nPrintSolidId, GDB_BB.STANDARD, b3PrintSolid) Dim nRawId As Integer = EgtAddRawPart(b3PrintSolid.Min, b3PrintSolid.DimX, b3PrintSolid.DimY, b3PrintSolid.DimZ, New Color3d(128, 128, 128, 30)) EgtAddPartToRawPart(CurrPart.nPartId, Point3d.ORIG() + (b3Part.Min - b3PrintSolid.Min), nRawId) EgtMoveToCornerRawPart(nRawId, b3PrintSolid.Min, MCH_CR.BL) Next EgtResetCurrMachGroup() Else ' esecuzione script prima di inizio Mach ExecInitMachScript() EgtSetCurrMachGroup(EgtGetFirstMachGroup()) End If End Sub Private Function ExecInitMachScript() As Boolean ' Recupero il nome dello script e verifico esista Dim sInitMachScriptPath As String = "" If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_INITSCRIPT, "", sInitMachScriptPath, CurrentMachine.sMachIniFile) = 0 Then Return True sInitMachScriptPath = (CurrentMachine.sMachScriptDir & "\" & sInitMachScriptPath).TrimEnd({"\"c}) If Not My.Computer.FileSystem.FileExists(sInitMachScriptPath) Then Return True ' Eseguo lo script EgtLuaCreateGlobTable("MACH") If Not EgtLuaExecFile(sInitMachScriptPath) Then EgtOutLog("Error executing Machining init script " & sInitMachScriptPath) MessageBox.Show(EgtMsg(5463) & " " & sInitMachScriptPath, EgtMsg(5461), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If Dim nErr As Integer = 999 EgtLuaGetGlobIntVar("MACH.ERR", nErr) EgtLuaResetGlobVar("MACH") Return nErr = 0 End Function Friend Function ExecExitMachScript() As Boolean ' Recupero il nome dello script e verifico esista Dim sExitMachScriptPath As String = "" If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_EXITSCRIPT, "", sExitMachScriptPath, CurrentMachine.sMachIniFile) = 0 Then Return True sExitMachScriptPath = CurrentMachine.sMachScriptDir & "\" & sExitMachScriptPath If Not My.Computer.FileSystem.FileExists(sExitMachScriptPath) Then Return True ' Eseguo lo script EgtLuaCreateGlobTable("MACH") If Not EgtLuaExecFile(sExitMachScriptPath) Then EgtOutLog("Error executing Machining exit script " & sExitMachScriptPath) MessageBox.Show(EgtMsg(5464) & " " & sExitMachScriptPath, EgtMsg(5461), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If Dim nErr As Integer = 999 EgtLuaGetGlobIntVar("MACH.ERR", nErr) EgtLuaResetGlobVar("MACH") Return nErr = 0 End Function #End Region ' METHODS #Region "COMMANDS" #Region "Slice" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Slice_Command As ICommand Get If m_cmdSlice Is Nothing Then m_cmdSlice = New Command(AddressOf Slice) End If Return m_cmdSlice End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Slice() If m_bCalculating Then Return m_bCalculating = True If IsNothing(Map.refTopPanelVM.SelPart) Then MessageBox.Show("No parts to slice!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) m_bCalculating = False Return End If If IsNothing(Map.refTopPanelVM.SelMaterial) Then MessageBox.Show("No print material set!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) m_bCalculating = False Return End If If IsNothing(Map.refTopPanelVM.SelMachining) OrElse IsNothing(Map.refTopPanelVM.CurrMachining) OrElse Map.refTopPanelVM.CurrMachining.dCurrStrandH <= 0 Then MessageBox.Show("No print parameters set!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) m_bCalculating = False Return End If ' esco da altre pagine Map.refTopPanelVM.SelPage = Pages.NULL ' eseguo calcoli CalcSlice(False) Map.refTopPanelVM.SelPage = Pages.SLICE Map.refSliderManagerVM.SetLayerIndexToMax() NotifyPropertyChanged(NameOf(Time_Visibility)) NotifyPropertyChanged(NameOf(Mass_Visibility)) m_bCalculating = False End Sub #End Region ' Slice #Region "Update" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Update_Command As ICommand Get If m_cmdUpdate Is Nothing Then m_cmdUpdate = New Command(AddressOf Update) End If Return m_cmdUpdate End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Update() If m_bCalculating Then Return m_bCalculating = True ' eseguo calcoli CalcSlice(False) NotifyPropertyChanged(NameOf(Time_Visibility)) NotifyPropertyChanged(NameOf(Mass_Visibility)) m_bCalculating = False End Sub #End Region ' Update #Region "Generate" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Generate_Command As ICommand Get If m_cmdGenerate Is Nothing Then m_cmdGenerate = New Command(AddressOf Generate) End If Return m_cmdGenerate End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Generate() If m_bCalculating Then Return m_bCalculating = True Dim bShiftPressed As Boolean = (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Dim bCtrlPressed As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control ' se shift chiedo nome Dim sIsoFilePath As String = "" Dim sExtension As String = "" GetPrivateProfileString(S_PARTPROGRAM, K_EXTENSION, "", sExtension, CurrentMachine.sMachIniFile) If String.IsNullOrWhiteSpace(sExtension) Then sExtension = ".cnc" End If If bCtrlPressed Then Dim sCurrFilePath As String = "" Dim sInitialDirectory As String = "" EgtGetCurrFilePath(sCurrFilePath) If Not IsNothing(sCurrFilePath) Then sInitialDirectory = System.IO.Path.ChangeExtension(sCurrFilePath, sExtension) End If Dim NewSaveFileDialog As New Windows.Forms.SaveFileDialog With {.Title = "ISO File Name", .Filter = "|*" & sExtension, .FilterIndex = 1, .InitialDirectory = System.IO.Path.GetDirectoryName(sInitialDirectory), .FileName = sInitialDirectory, .CreatePrompt = True, .OverwritePrompt = True, .ValidateNames = False} Dim bResult As Boolean? = NewSaveFileDialog.ShowDialog() If IsNothing(bResult) OrElse Not bResult Then m_bCalculating = False Return End If Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE) If nTabPartId <> GDB_ID.NULL Then EgtSetInfo(nTabPartId, KEY_ISOFILE_PATH, NewSaveFileDialog.FileName) sIsoFilePath = NewSaveFileDialog.FileName End If Else Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE) If nTabPartId <> GDB_ID.NULL Then EgtGetInfo(nTabPartId, KEY_ISOFILE_PATH, sIsoFilePath) If String.IsNullOrWhiteSpace(sIsoFilePath) OrElse Not Directory.Exists(Path.GetDirectoryName(sIsoFilePath)) Then EgtGetCurrFilePath(sIsoFilePath) sIsoFilePath = System.IO.Path.ChangeExtension(sIsoFilePath, sExtension) EgtSetInfo(nTabPartId, KEY_ISOFILE_PATH, sIsoFilePath) End If End If End If ' eseguo calcoli CalcSlice(True, True) If bShiftPressed Then ' Se esiste ne lancio l'editing If File.Exists(sIsoFilePath) Then Process.Start("Notepad.exe", sIsoFilePath) ' altrimenti lo segnalo Else MessageBox.Show("Edit failed, missing part program file" & " (" & sIsoFilePath & ")") End If End If NotifyPropertyChanged(NameOf(Time_Visibility)) NotifyPropertyChanged(NameOf(Mass_Visibility)) m_bCalculating = False End Sub #End Region ' Generate #Region "Simulate" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Simulate_Command As ICommand Get If m_cmdSimulate Is Nothing Then m_cmdSimulate = New Command(AddressOf Simulate) End If Return m_cmdSimulate End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub Simulate() m_bCalculating = True ' eseguo calcoli CalcSlice(True) m_bCalculating = False ' verifico esistenza e correttezza machgroup InitMachGroup(False) ' apro simulazione Map.refRightPanelVM.SetSelPanel(RightPanelVM.Panels.SIMULATION) End Sub #End Region ' Simulate #Region "Exit" ''' ''' Returns a command that do CPlaneTop. ''' Public ReadOnly Property Exit_Command As ICommand Get If m_cmdExit Is Nothing Then m_cmdExit = New Command(AddressOf ExitCmd) End If Return m_cmdExit End Get End Property ''' ''' Execute the CPlaneTop. This method is invoked by the CPlaneTopCommand. ''' Public Sub ExitCmd() ' se in simulazione If Map.refRightPanelVM.SelPanel = RightPanelVM.Panels.SIMULATION Then ' la chiudo Map.refSimulationPanelVM.Ok() End If Map.refTopPanelVM.SelPage = Pages.MODIFY End Sub #End Region ' Exit #End Region ' COMMANDS End Class