Imports System.IO Imports EgtUILib Imports EgtWPFLib5 Imports Microsoft.Win32 Public Class ImportSceneHostVM Inherits EgtWPFLib5.SceneHostVM Friend m_bIsFocused As Boolean Friend Sub SetIsFocused(bValue As Boolean) m_bIsFocused = bValue End Sub ' Identificativi per pezzo da selezionare/deselezionare Private m_nIdToSel As Integer = GDB_ID.NULL Private m_nIdToDesel As Integer = GDB_ID.NULL ' Dati movimento Private m_dMaxStep As Double = 0 ' Dati per Drag Private m_nRestRadius As Integer = 5 Private m_bDrag As Boolean = False Private m_bDragToStart As Boolean = False Private m_bVerify As Boolean = False Private m_bFromParking As Boolean = False Private m_bDragging As Boolean = False Private m_locPrev As System.Drawing.Point Private m_ptPrev As Point3d Private m_vtTotMove As Vector3d Private m_dSnapDist As Double = 0 Private bReducedCut As Boolean = False Private m_bMagnetic As Boolean ' punto di snap per inizializzazione Private m_SnapType As SP Friend ReadOnly Property SnapType As SP Get Return m_SnapType End Get End Property #Region "CONSTRUCTOR" Sub New() MyBase.New() AddHandler MainController.OnNewProject, AddressOf OnNewProject AddHandler MainController.OnOpenProject, AddressOf OnOpenProject AddHandler MainController.OnSavingProject, AddressOf OnSavingProject AddHandler MainController.OnSavedProject, AddressOf OnSavedProject AddHandler MainController.OnInsertedProject, AddressOf OnInsertedProject AddHandler MainController.OnImportingProject, AddressOf OnImportingProject AddHandler MainController.OnImportedProject, AddressOf OnImportedProject AddHandler MainController.PrepareInputBox, AddressOf PrepareInputBox AddHandler MainController.SetInputBoxText, AddressOf SetInputBoxText AddHandler MainController.SetInputBoxCheck, AddressOf SetInputBoxCheck AddHandler MainController.AddInputBoxCombo, AddressOf AddInputBoxCombo AddHandler MainController.UpdateUI, AddressOf UpdateUI End Sub #End Region ' CONSTRUCTOR #Region "METHODS" Overrides Sub InitScene() InitSceneEvents() ' Inizializzazione Scena PreInitializeScene() ' Se tutto bene If MainScene.Init() And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT._3DPRINT) Then PostInitializeScene() ' Imposto stato gestione mouse diretto della scena a nessuno MainScene.SetStatusNull() EgtSetCurrentContext(MainScene.GetCtx()) ' inizializzo gestore lavorazioni EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir) Return End If ' Problemi ' Se manca la chiave If Map.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or Map.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then EgtOutLog("Missing Dongle") ' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore" Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3) Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) ' Altrimenti manca la licenza Else EgtOutLog("Problems with Licence") ' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore" Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 5) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 6) Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) If MessageBox.Show(sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then ' Apro dialogo per richiesta file licenza Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With { .DefaultExt = ".lic", .Filter = "Licences (.lic)|*.lic", .CheckFileExists = True, .ValidateNames = True } If LicDlg.ShowDialog() = True Then ' Recupero il direttorio del file Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName) ' Se il file non è già nel direttorio di configurazione lo copio If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(Map.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then Try File.Copy(LicDlg.FileName, Path.Combine(Map.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True) Catch ex As Exception End Try End If ' Imposto il nuovo file di licenza nell'Ini WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName) End If End If End If ' Chiudo il programma End End Sub Public Overrides Sub InitSceneEvents() AddHandler MainScene.OnCursorPos, AddressOf OnCursorPos AddHandler MainScene.OnMouseSetObjFilterForSelect, AddressOf OnMouseSetObjFilterForSelect AddHandler MainScene.OnMouseSelectedAll, AddressOf OnMouseSelectedAll AddHandler MainScene.OnMouseDeselectedAll, AddressOf OnMouseDeselectedAll AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene AddHandler MainScene.OnMouseMoveScene, AddressOf OnMouseMoveScene AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene AddHandler MainScene.OnMouseSelectedObj, AddressOf OnMouseSelectedObj AddHandler MainScene.OnMouseSelectedPart, AddressOf OnMouseSelectedPart AddHandler MainScene.OnMouseSelectedLayer, AddressOf OnMouseSelectedLayer AddHandler MainScene.OnMouseSelectedPath, AddressOf OnMouseSelectedPath AddHandler MainScene.OnMousePointFromSelection, AddressOf OnMousePointFromSelection AddHandler MainScene.OnMouseDone, AddressOf OnMouseDone AddHandler MainScene.OnMouseSelectedPoint, AddressOf OnMouseSelectedPoint AddHandler MainScene.OnMouseSelectedDir, AddressOf OnMouseSelectedDir AddHandler MainScene.OnMouseMoveSelPoint, AddressOf OnMouseMoveSelPoint AddHandler MainScene.OnShowDistance, AddressOf OnShowDistance AddHandler MainScene.KeyDown, AddressOf OnKeyDown AddHandler MainScene.OnCloseGetDist, AddressOf OnCloseGetDist AddHandler MainScene.OnChangedSnapPointType, AddressOf OnChangedSnapPointType End Sub Private Sub PreInitializeScene() ' imposto colore di default Dim DefColor As New Color3d(0, 0, 0) GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor) MainScene.SetDefaultMaterial(DefColor) ' imposto colori sfondo Dim BackTopColor As New Color3d(192, 192, 192) GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor) Dim BackBotColor As New Color3d(BackTopColor) GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor) MainScene.SetViewBackground(BackTopColor, BackBotColor) ' imposto spessore linee Dim nLineWidth As Integer = 1 nLineWidth = GetMainPrivateProfileInt(S_SCENE, K_LINEWIDTH, nLineWidth) MainScene.SetLineWidth(nLineWidth) ' imposto colore di evidenziazione Dim MarkColor As New Color3d(255, 255, 0) GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor) MainScene.SetMarkMaterial(MarkColor) ' imposto colore per superfici selezionate Dim SelSurfColor As New Color3d(255, 255, 192) GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor) MainScene.SetSelSurfMaterial(SelSurfColor) ' imposto tipo e colore del rettangolo di zoom Dim bOutline As Boolean = True Dim ZwColor As New Color3d(0, 0, 0) GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor) MainScene.SetZoomWinAttribs(bOutline, ZwColor) ' imposto colore della linea di distanza Dim DstLnColor As New Color3d(255, 0, 0) GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor) MainScene.SetDistLineMaterial(DstLnColor) ' imposto parametri OpenGL Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3) Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0) Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32) Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32) MainScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits) End Sub Private Sub PostInitializeScene() ' Impostazioni Controller MainController.SetScene(MainScene) MainController.SetSurfTmTolerance(0.05) MainController.SetUseCustomColors(True, S_SCENE, K_CUSTOMCOLORS) ' imposto unità di misura per interfaccia utente Dim nMeasureUnit As Integer = GetMainPrivateProfileInt(S_SCENE, K_MMUNITS, 1) EgtSetUiUnits(nMeasureUnit <> 0) 'Map.refMyStatusBarVM.SetMeasureUnit(nMeasureUnit <> 0) ' imposto visualizzazione riferimento globale EgtSetGlobFrameShow(True) ' imposto i dati della griglia 'LoadGridData() EgtSetGridFrame(Frame3d.GLOB) EgtSetGridGeo(10, 10, 100, 484) EgtSetGridColor(New Color3d(160, 160, 160), New Color3d(160, 160, 160)) EgtSetGridShow(True, False) ' imposto tipo coordinate MainScene.SetGridCursorPos(True) ' modo di visualizzazione Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING) '''Map.refShowPanelVM.SetShowMode(DirectCast(nShowMode, SM)) ' visualizzazione avanzata dei triangoli costituenti le superfici Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0) EgtSetShowTriaAdv(bShowTriaAdv) ' tipo visualizzazione per Zmap Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1) EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False) ' dimensione lineare max in pixel delle textures Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096) EgtSetTextureMaxLinPixels(nTxrMaxLinPix) ' tipo snap point MainScene.SetSnapPointType(SP.PT_SKETCH) ' visualizzazione assemblato Dim nShowBuilding As Boolean = GetMainPrivateProfileInt(S_SCENE, K_SHOWBUILDING, 0) <> 0 '''Map.refShowBeamPanelVM.SetShowBuilding(nShowBuilding) ' nascondo input box '''Map.refFreeContourInputVM.ResetInputBox() End Sub #End Region ' METHODS #Region "ProjectManager" Public Overrides Sub NewProject() EgtSetCurrentContext(MainScene.GetCtx()) Dim bOk As Boolean = MainController.NewProject() MainScene.SetStatusNull() End Sub Public Overrides Sub OpenProject(sFilePath As String) EgtSetCurrentContext(MainScene.GetCtx()) Dim bOk As Boolean = False If String.IsNullOrEmpty(sFilePath) Then ' Recupero cartella dell'ultimo progetto aperto Dim sDir As String = MainController.GetCurrFile() If String.IsNullOrWhiteSpace(sDir) Then GetMainPrivateProfileString(S_MRUFILES, K_FILE, "", sDir) End If If Not String.IsNullOrWhiteSpace(sDir) Then sDir = Path.GetDirectoryName(sDir) End If bOk = MainController.OpenProject(sDir) Else bOk = MainController.OpenProject(sFilePath, False) End If MainScene.SetStatusNull() End Sub Public Overrides Sub SaveProject() MyBase.SaveProject() ' Imposto stato gestione mouse diretto della scena a nessuno MainScene.SetStatusNull() End Sub Public Overrides Sub SaveAsProject() MyBase.SaveAsProject() ' Imposto stato gestione mouse diretto della scena a nessuno MainScene.SetStatusNull() End Sub Public Overrides Sub InsertProject() ' eseguo Dim sDir As String = String.Empty GetMainPrivateProfileString(S_MRUIMPORT, K_FILE & "1", "", sDir) Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert", .Filter = "Stereolithography (*.stl)|*.stl" & "|New geometry EgalTech(*.nge)|*.nge" & "|All Files (*.*)|*.*", .FilterIndex = 1, .InitialDirectory = sDir} If Not OpenFileDialog.ShowDialog Then Return End If Dim sFile As String = String.Empty sFile = OpenFileDialog.FileName Dim ChooseReferenceWndVM As New ChooseReferenceWndVM Dim ChooseReferenceWndV As New ChooseReferenceWndV(Application.Current.MainWindow, ChooseReferenceWndVM) If Not ChooseReferenceWndV.ShowDialog() Then Return Dim nImportContext As Integer = EgtInitContext() MainController.InsertProject(sFile, False) End Sub Public Overrides Sub ImportProject() Dim sDir As String = String.Empty GetMainPrivateProfileString(S_MRUIMPORT, K_FILE & "1", "", sDir) If Not String.IsNullOrWhiteSpace(sDir) Then sDir = Path.GetDirectoryName(sDir) End If sDir.TrimEnd("\"c) MainController.ImportProject(sDir) ' Imposto stato gestione mouse diretto della scena a nessuno MainScene.SetStatusNull() End Sub Friend Sub PreExecScript(bScriptInMru As Boolean) 'm_bScriptInMru = bScriptInMru End Sub Friend Sub ExecScript(sFilePath As String) If String.IsNullOrEmpty(sFilePath) Then Dim sDir As String = String.Empty 'GetMainPrivateProfileString(S_GENERAL, K_LASTLUADIR, "", sDir) MainController.Exec(sDir) Else MainController.Exec(sFilePath, False) End If Dim bMachiningMode As Boolean = EgtGetCurrMachGroup() <> GDB_ID.NULL If Not bMachiningMode And EgtGetCurrLayer() = GDB_ID.NULL Then Dim nCurrPart As Integer = EgtGetCurrPart() If nCurrPart = GDB_ID.NULL Or Not EgtSetCurrPartLayer(nCurrPart, EgtGetFirstLayer(nCurrPart, True)) Then EgtResetCurrPartLayer() End If End If End Sub #End Region ' ProjectManager #Region "SCENE EVENTS" Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) Map.refMyStatusBarVM.SetCurrPos(sCursorPos) End Sub Private Sub OnMouseSetObjFilterForSelect(sender As Object, bZeroDim As Boolean, bCurve As Boolean, bSurf As Boolean, bVolume As Boolean, bExtra As Boolean) End Sub Private Sub OnMouseSelectedAll(ByVal sender As Object, bOnlyVisble As Boolean) End Sub Private Sub OnMouseDeselectedAll(ByVal sender As Object) End Sub Private Sub OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return Basic_OnMouseDownScene(sender, e) 'Select Case Map.refMainMenuVM.SelPage ' Case Pages.VIEW ' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then ' If Map.refFreeContourManagerVM.bIsActive Then Return ' If Map.refShowBeamPanelVM.bShowAll Then ' View_Part_OnMouseDownScene(sender, e) ' Else ' View_Feature_OnMouseDownScene(sender, e) ' End If ' End If ' Case Pages.MACHINING ' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then ' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup ' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return ' If SelectedMachGroup.nType = BWType.BEAM Then ' Beam_OnMouseDownScene(sender, e) ' ElseIf SelectedMachGroup.nType = BWType.WALL Then ' Wall_OnMouseDownScene(sender, e) ' End If ' End If 'End Select End Sub Private Sub OnMouseMoveScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return Basic_OnMouseMoveScene(sender, e) 'Select Case Map.refMainMenuVM.SelPage ' Case Pages.VIEW ' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then ' If Map.refFreeContourManagerVM.bIsActive Then Return ' If Map.refShowBeamPanelVM.bShowAll Then ' View_Part_OnMouseMoveScene(sender, e) ' Else ' View_Feature_OnMouseMoveScene(sender, e) ' End If ' End If ' Case Pages.MACHINING ' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then ' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup ' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return ' If SelectedMachGroup.nType = BWType.BEAM Then ' Beam_OnMouseMoveScene(sender, e) ' ElseIf SelectedMachGroup.nType = BWType.WALL Then ' Wall_OnMouseMoveScene(sender, e) ' End If ' End If 'End Select End Sub Private Sub OnMouseUpScene(sender As Object, e As Forms.MouseEventArgs) If e.Button = Forms.MouseButtons.Middle Then Return If Map.refInstrumentPanelVM.GetDistIsChecked Then Return Basic_OnMouseUpScene(sender, e) 'Select Case Map.refMainMenuVM.SelPage ' Case Pages.VIEW ' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then ' If Map.refFreeContourManagerVM.bIsActive Then Return ' If Map.refShowBeamPanelVM.bShowAll Then ' View_Part_OnMouseUpScene(sender, e) ' Else ' View_Feature_OnMouseUpScene(sender, e) ' End If ' End If ' Case Pages.MACHINING ' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then ' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup ' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return ' If SelectedMachGroup.nType = BWType.BEAM Then ' Beam_OnMouseUpScene(sender, e) ' ElseIf SelectedMachGroup.nType = BWType.WALL Then ' Wall_OnMouseUpScene(sender, e) ' End If ' End If 'End Select End Sub Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' ' se sto editando testo angoli ' If Map.refFreeContourManagerVM.bIsModifyingTextAngle Then ' ' passo testo selezionato ' Map.refFreeContourManagerVM.TextAngleSelected(nId) ' End If ' MainController.MouseSelectedObj(nId, bLast) 'End If End Sub Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.MouseSelectedPart(nId) 'End If End Sub Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.MouseSelectedLayer(nId) 'End If End Sub Private Sub OnMouseSelectedPath(ByVal sender As Object, ByVal nId As Integer, ByVal bHaltOnFork As Boolean) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.MouseSelectedPath(nId, bHaltOnFork) 'End If End Sub Private Sub OnMousePointFromSelection(ByVal sender As Object, ByVal nId As Integer, ByVal PtP As Point3d, ByVal nAux As Integer) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.SetPointFromSelection(nId, PtP, nAux) 'End If End Sub Private Sub OnMouseDone(ByVal sender As Object) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.Done(Map.refFreeContourInputVM.Text) 'End If End Sub Private Sub OnMouseSelectedPoint(ByVal sender As Object, ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' Dim bDone As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) <> ModifierKeys.Control ' MainController.MouseSelectedPoint(PtP, nSep, nId, bDone) 'End If End Sub Private Sub OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.SetLastVector3d(VtDir) 'End If End Sub Private Sub OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' MainController.MouseMoveInSelectionPoint(PtP) 'End If End Sub Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String) Map.refMyStatusBarVM.SetOutputMessage(sDistance) End Sub Private Sub OnKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) '' Se in modalità edit L250 'If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then ' ' Con DEL eseguo cancellazione delle entità selezionate ' If e.KeyData = System.Windows.Forms.Keys.Delete Then ' MainController.SetLastInteger(GDB_ID.SEL) ' MainController.ExecuteCommand(Controller.CMD.DELETE) ' ' Con SPAZIO ripeto l'ultimo comando ' ElseIf e.KeyData = System.Windows.Forms.Keys.Space Then ' MainController.RepeatLastCommand() ' ' Con 'A' e in modalità continuazione, forzo il passaggio ad arco ' ElseIf e.KeyData = System.Windows.Forms.Keys.A And MainController.GetContinue() Then ' MainController.ContinueArcPDP() ' ' Con 'L' e in modalità continuazione, forzo il passaggio a retta ' ElseIf e.KeyData = System.Windows.Forms.Keys.L And MainController.GetContinue() Then ' MainController.ContinueLine2P() ' ' Con 'V' cambio lo stato del check ' ElseIf e.KeyData = System.Windows.Forms.Keys.V Then ' Map.refFreeContourInputVM.ChangeInputBoxCheck() ' End If 'End If End Sub Private Sub OnCloseGetDist(sender As System.Object) Map.refInstrumentPanelVM.SetGetDistance_IsChecked(False) End Sub Friend Sub OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean) m_SnapType = nSpType If Not IsNothing(Map.refMyStatusBarVM) Then Map.refMyStatusBarVM.SetSnapPointType(nSpType) End Sub #End Region ' SCENE EVENTS #Region "CONTROLLER EVENTS" Private Sub OnNewProject(sender As Object, bOk As Boolean) CurrentMachine.CreateMachineTable() If Not bOk Then MessageBox.Show(Application.Current.MainWindow, EgtMsg(10002), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error on new file - Error End If EgtZoom(ZM.ALL) MainScene.SetStatusNull() End Sub Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean) EgtZoom(ZM.ALL) WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile)) If bOk Then Map.refProjManagerVM.MruFiles.Add(sFile) Else Map.refProjManagerVM.MruFiles.Remove(sFile) Dim sMsg As String If My.Computer.FileSystem.FileExists(sFile) Then sMsg = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file Else sMsg = EgtMsg(10009) & " '" & sFile & "'" 'Missing file End If MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error End If MainScene.SetStatusNull() End Sub Private Sub OnSavingProject(ByVal sender As Object, sFile As String) End Sub Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile)) If bOk Then Map.refProjManagerVM.MruFiles.Add(sFile) Else Map.refProjManagerVM.MruFiles.Remove(sFile) Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error End If End Sub Private Sub OnInsertedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) ' Segnalo eventuale errore If Not bOk Then Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error Else ' lo aggiungo alla lista pezzi Map.refProjectVM.AddNewPart(sFile) End If EgtDraw() MainScene.SetStatusNull() End Sub Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer) If nType <> FT.NULL Then If nType = FT.CNC Then nFlag = GetMainPrivateProfileInt(S_IMPORT, K_CNCFLAG, EIC_FL.NONE) Else nFlag = 0 End If ' Abilito progress e bottone stop Map.refMyStatusBarVM.StartLoading("", True) Else MessageBox.Show(Application.Current.MainWindow, EgtMsg(10005), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' File type unknown - Error End If End Sub Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) EgtZoom(ZM.ALL) ' Disabilito progress e bottone stop Map.refMyStatusBarVM.EndLoading("") ' Salvo path WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile)) ' Segnalo eventuale errore If Not bOk Then Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error ElseIf Path.GetExtension(sFile) <> ".cnc" Then ' creo oggetto pezzo in lista 'Map.refProjectVM. End If MainScene.SetStatusNull() End Sub Private Sub PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String, ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean) 'Map.refFreeContourInputVM.PrepareInputBox(sTitle, sLabel, sCheckLabel, bShowCombo, bShowBtn) End Sub Private Sub SetInputBoxText(ByVal sText As String) 'Map.refFreeContourInputVM.SetInputBoxText(sText) End Sub Private Sub SetInputBoxCheck(ByVal bCheck As Boolean) 'Map.refFreeContourInputVM.SetInputBoxCheck(bCheck) End Sub Private Sub AddInputBoxCombo(ByVal sText As String, ByVal bSelected As Boolean) 'Map.refFreeContourInputVM.AddInputBoxCombo(sText, bSelected) End Sub Private Sub UpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean) '' pulisco input e relativi messaggi 'Map.refFreeContourInputVM.ResetInputBox() If MainController.GetContinue() Then Map.refMyStatusBarVM.SetOutputMessage(EgtMsg(399)) ' Continue : 'L' with line, 'A' with arc Else Map.refMyStatusBarVM.ClearOutputMessage() End If End Sub #End Region ' CONTROLLER EVENTS #Region "Part" Friend Sub Basic_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) ' Verifico se selezionato indicativo di pezzo EgtSetObjFilterForSelWin(True, True, True, True, True) Dim nSel As Integer EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) Dim nId As Integer = EgtGetFirstObjInSelWin() While nId <> GDB_ID.NULL ' Recupero l'identificativo del pezzo cui appartiene Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) Dim bFound As Boolean = False If EgtIsPart(nPartId) Then bFound = True If Not bFound Then nId = EgtGetNextObjInSelWin() Continue While End If Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nPartId, nStat) ' Se già selezionato If nStat = GDB_ST.SEL Then ' Memorizzo Id da deselezionare m_nIdToDesel = nPartId Else ' Memorizzo Id da selezionare m_nIdToSel = nPartId End If Exit While nId = EgtGetNextObjInSelWin() End While ' Dati per drag m_bDragToStart = True End Sub Friend Sub Basic_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) ' Se drag non abilitato o già in esecuzione, esco If Not m_bDragToStart Then Return ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel If m_bDragToStart Then If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then Return End If m_bDragToStart = False End If End Sub Friend Sub Basic_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) ' Se eseguito drag If Not m_bDragToStart Then ' Se selezione da eseguire ElseIf m_nIdToSel <> GDB_ID.NULL Then ' Se pezzo da selezionare non è già selezionato 'If EgtIsSelectedObj(m_nIdToSel) Then ' Eseguo la selezione Map.refProjectVM.SelPartFromId(m_nIdToSel) 'EgtDeselectAll() 'EgtSelectPartObjs(m_nIdToSel) 'EgtSelectObj(m_nIdToSel) 'EgtSetMark(m_nIdToSel) 'End If 'If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId <> m_nIdToSel Then ' ' Eseguo la selezione ' For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList ' If BTLPart.nPartId = m_nIdToSel Then ' BTLPart.SetIsSelected(True) ' ElseIf BTLPart.IsSelected Then ' BTLPart.SetIsSelected(False) ' End If ' Next ' End If End If ' Reset m_bDrag = False m_nIdToSel = GDB_ID.NULL m_nIdToDesel = GDB_ID.NULL EgtDraw() End Sub #End Region ' Part End Class