0851ba19d0
- Implementato uso della EgtSaveFileDialog da EgtWPFLib5. - Abbozzata gestione dei file per GunStock. - Aggiunta virtualizzazione dell'albero dei layer. - Corretta visualizzazione pallini colorati nell'albero dei layer. - Miglioramenti nel salvataggio delle MTable e selezione di quella corrente. - Aggiunto colore Egaltech1 in IniFile per poterlo usare da codice.
1148 lines
72 KiB
VB.net
1148 lines
72 KiB
VB.net
Imports System.Windows.Forms.Integration
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports EgtWPFLib5.EgtFloating
|
|
|
|
Namespace EgtCAM5
|
|
|
|
Public Class ProjectViewModel
|
|
Inherits TabViewModel
|
|
|
|
#Region "FIELDS"
|
|
|
|
Private m_CloseProgram As Boolean = False
|
|
|
|
' Variabili in cui salvo i filtri di selezione della modalità Draw e che poi ripristino all'uscita dalla modalità Machining
|
|
Private m_bSelZeroDim As Boolean = True
|
|
Private m_bSelCurve As Boolean = True
|
|
Private m_bSelSurf As Boolean = True
|
|
Private m_bSelVolume As Boolean = True
|
|
Private m_bSelExtra As Boolean = True
|
|
|
|
Private m_bLoaded As Boolean = False
|
|
|
|
'PROJECT PAGE'S SCENE FIELDS AND PROPERTIES
|
|
' Reference to the ProjectScene
|
|
Private WithEvents m_ProjectScene As New Scene
|
|
' Reference to the ProjectSceneHost
|
|
Private SceneHost As WindowsFormsHost
|
|
' Property used to bind the scene to the WindowsFormsHost in XAML
|
|
Private m_bfirst As Boolean = True
|
|
Public ReadOnly Property ProjectSceneHost As WindowsFormsHost
|
|
Get
|
|
If m_bfirst Then
|
|
SceneHost = New WindowsFormsHost() With {.Child = m_ProjectScene}
|
|
m_bfirst = False
|
|
End If
|
|
Return SceneHost
|
|
End Get
|
|
End Property
|
|
' Scene controller
|
|
Private WithEvents m_Controller As New Controller
|
|
|
|
' Definizione comandi
|
|
Private m_cmdLoaded As ICommand
|
|
|
|
#End Region
|
|
|
|
#Region "EGTUILIB FIELDS"
|
|
|
|
Private m_bCPlaneTypePos As Boolean
|
|
'Private m_bStopExec As Boolean = False
|
|
'Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents)
|
|
'Private m_OutTextCallback As New OutTextCallback(AddressOf OutText)
|
|
|
|
' Variabile per implementazione eventi
|
|
Private m_InputText As String
|
|
#End Region
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
'Me.sTabName = EgtMsg(MSG_MAINWINDOW + 1)
|
|
' Creo classe di supporto per la visualizzazione dei parametri utensile e di lavorazione per Db e operazioni
|
|
SharedFieldsClass.bFirst = True
|
|
ManageClosingApplication()
|
|
RegisterMainWindowCommands()
|
|
' Inizializza i parametri della scena
|
|
'InitializeEgtProject()
|
|
RegisterControllerCommands()
|
|
ManageTopCommandBar()
|
|
' Funzione che contiene la registrazione di tutti le funzioni del DrawPanel
|
|
RegisterGridViewPanelCommands()
|
|
RegisterDrawPanelCommands()
|
|
' Funzione che contiene la registrazione di tutti i comandi del DrawOptionPanel
|
|
RegisterDrawOptionPanelCommands()
|
|
' Funzione che contiene la registrazione di tutti i comandi della StatusBar
|
|
RegisterStatusBarCommands()
|
|
' Cambio impostazioni griglia a seconda che sia in modalità Draw o Machining
|
|
Application.Msn.Register(Application.MACHININGMODE_ISCHECKED, Sub()
|
|
m_ProjectScene.GetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
|
|
Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bMachiningShowGrid, IniFile.m_bShowGridFrame))
|
|
End Sub)
|
|
Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub()
|
|
m_ProjectScene.SetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
|
|
Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bDrawShowGrid, IniFile.m_bShowGridFrame))
|
|
End Sub)
|
|
Application.Msn.Register(Application.SETSCENESELMODE, Sub(SceneSelMode As SceneSelModeOpt)
|
|
Me.SceneSelMode = SceneSelMode
|
|
End Sub)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "LoadedCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property LoadedCommand As ICommand
|
|
Get
|
|
If m_cmdLoaded Is Nothing Then
|
|
m_cmdLoaded = New RelayCommand(AddressOf Loaded, AddressOf CanLoaded)
|
|
End If
|
|
Return m_cmdLoaded
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub Loaded(ByVal param As Object)
|
|
If m_bLoaded Then Return
|
|
m_bLoaded = True
|
|
' Creazione scena
|
|
PreInitializeScene()
|
|
If Not m_ProjectScene.Init() Then
|
|
EgtOutLog("Error in Project scene creation")
|
|
SceneHost.Child = Nothing
|
|
' Box di avviso chiave mancante
|
|
MsgBox(EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3), MsgBoxStyle.OkOnly, EgtMsg(MSG_MISSINGKEYWD + 1))
|
|
' Chiudo il programma
|
|
Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
|
|
' Verifico abilitazione prodotto
|
|
ElseIf (IniFile.m_nKeyOptions And KEY_OPT.BASE) = 0 Then
|
|
m_CloseProgram = True
|
|
MsgBox(EgtMsg(MSG_MISSINGKEYWD + 5), MsgBoxStyle.OkOnly, EgtMsg(MSG_MISSINGKEYWD + 1))
|
|
' Chiudo il programma
|
|
Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
|
|
Else
|
|
IniFile.m_ProjectSceneContext = m_ProjectScene.GetCtx
|
|
PostInitializeScene()
|
|
' inizializzo gestore lavorazioni
|
|
EgtInitMachMgr(IniFile.m_sMachinesRoot)
|
|
End If
|
|
' Seleziono la macchina impostata nel file ini
|
|
Application.Msn.NotifyColleagues(Application.LOADCURRENTMACHINE)
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanLoaded(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' LoadedCommand
|
|
|
|
#End Region
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub PreInitializeScene()
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
|
|
m_ProjectScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(192, 192, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
|
|
Dim BackBotColor As New Color3d(BackTopColor)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
|
|
m_ProjectScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
|
|
m_ProjectScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
|
|
m_ProjectScene.SetSelSurfMaterial(SelSurfColor)
|
|
' imposto tipo e colore del rettangolo di zoom
|
|
Dim bOutline As Boolean = True
|
|
Dim ZwColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor)
|
|
m_ProjectScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
|
|
m_ProjectScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3)
|
|
Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0)
|
|
Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32)
|
|
Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32)
|
|
m_ProjectScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
End Sub
|
|
|
|
Private Sub PostInitializeScene()
|
|
' Impostazioni Controller
|
|
m_Controller.SetScene(m_ProjectScene)
|
|
Dim bLuaReg As Boolean = (GetPrivateProfileInt(S_GENERAL, K_COMMANDLOG, 0) <> 0)
|
|
Dim sCmdLogFile As String = CMDLOG_FILE_NAME.Replace("#", m_nInstance.ToString())
|
|
If Not m_Controller.SetCommandLog(bLuaReg, m_sTempDir, sCmdLogFile) Then
|
|
EgtOutLog("Command log not started")
|
|
If Environment.GetCommandLineArgs.Count() <= 1 Then
|
|
MessageBox.Show("Command log not started", "TestEIn Warning",
|
|
MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
End If
|
|
End If
|
|
' imposto unità di misura per interfaccia utente
|
|
IniFile.m_bMmUnits = (GetPrivateProfileInt(S_SCENE, K_MMUNITS, 1) <> 0)
|
|
Application.Msn.NotifyColleagues(Application.UPDATESTATUSUNITS, IniFile.m_bMmUnits)
|
|
' imposto visualizzazione riferimento globale
|
|
Dim bShowGlobFrame As Boolean = (GetPrivateProfileInt(S_SCENE, K_SHOWGFRAME, 1) <> 0)
|
|
EgtSetGlobFrameShow(bShowGlobFrame)
|
|
' imposto i dati della griglia
|
|
LoadGridData()
|
|
' imposto stato di visualizzazione della griglia
|
|
IniFile.m_bDrawShowGrid = (GetPrivateProfileInt(S_GRID, K_DRAWSHOWGRID, 1) <> 0)
|
|
IniFile.m_bMachiningShowGrid = (GetPrivateProfileInt(S_GRID, K_MACHININGSHOWGRID, 1) <> 0)
|
|
IniFile.m_bShowGridFrame = (GetPrivateProfileInt(S_GRID, K_SHOWFRAME, 1) <> 0)
|
|
Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bDrawShowGrid, IniFile.m_bShowGridFrame))
|
|
' imposto tipo coordinate
|
|
m_bCPlaneTypePos = True
|
|
Application.Msn.NotifyColleagues(Application.STATUSCURRPOSTYPETEXT, "GRID")
|
|
m_ProjectScene.SetGridCursorPos(m_bCPlaneTypePos)
|
|
' modo di visualizzazione
|
|
Dim nShowMode As Integer = GetPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING)
|
|
Application.Msn.NotifyColleagues(Application.SHOWMODESTATE, nShowMode)
|
|
' visualizzazione direzione curve
|
|
Dim nShowCurveDir As Integer = GetPrivateProfileInt(S_SCENE, K_CURVEDIR, 0)
|
|
Application.Msn.NotifyColleagues(Application.SHOWCURVEDIR, nShowCurveDir)
|
|
' visualizzazione avanzata dei triangoli costituenti le superfici
|
|
Dim bShowTriaAdv As Boolean = (GetPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
|
|
EgtSetShowTriaAdv(bShowTriaAdv)
|
|
' lettura da ini della variabile che abilita i gruppi di lavorazione
|
|
IniFile.m_bMachiningGroup = (GetPrivateProfileInt(S_MACH, K_MACHININGGROUP, 0) <> 0)
|
|
Application.Msn.NotifyColleagues(Application.DRAWMODE_ISCHECKED)
|
|
' ObjTree non selezionato
|
|
Application.Msn.NotifyColleagues(Application.UPDATEOBJTREEOLDID, GDB_ID.NULL)
|
|
' nascondo input box
|
|
Application.Msn.NotifyColleagues(Application.RESETINPUTBOX)
|
|
' Apro progetto vuoto
|
|
Application.Msn.NotifyColleagues(Application.NEWPROJECT)
|
|
' Imposto stato filtro selezione
|
|
m_ProjectScene.GetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
|
|
m_Controller.MouseSetObjFilterForSelect(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
|
|
End Sub
|
|
|
|
Private Sub ProcessCommandLine()
|
|
' Recupero eventuali parametri da linea di comando
|
|
Dim bOpen As Boolean = False
|
|
If Environment.GetCommandLineArgs.Count() > 1 Then
|
|
Dim sFile As String = Environment.GetCommandLineArgs(1)
|
|
If Not String.IsNullOrWhiteSpace(sFile) Then
|
|
Dim nFileType As Integer = EgtGetFileType(sFile)
|
|
Select Case nFileType
|
|
Case FT.NGE, FT.NFE
|
|
m_Controller.OpenProject(sFile, False)
|
|
bOpen = True
|
|
Case FT.DXF, FT.STL, FT.CNC, FT.CSF, FT.BTL
|
|
m_Controller.ImportProject(sFile, False)
|
|
bOpen = True
|
|
Case FT.TSC, FT.LUA
|
|
m_Controller.Exec(sFile, False)
|
|
bOpen = True
|
|
End Select
|
|
If IO.Path.GetExtension(sFile).ToLower() = ".ddf" Then
|
|
' Se manca direttorio uso quello di default
|
|
If String.IsNullOrWhiteSpace(IO.Path.GetDirectoryName(sFile)) Then
|
|
Dim sDefDir As String = String.Empty
|
|
GetPrivateProfileString(S_DOORS, K_DDFDEFAULTDIR, "", sDefDir)
|
|
sFile = sDefDir & "\" & sFile
|
|
End If
|
|
' Ricoscimento flag
|
|
Dim nPar2 As Integer = 0
|
|
If Environment.GetCommandLineArgs.Count() > 2 Then
|
|
nPar2 = CInt(Environment.GetCommandLineArgs(2))
|
|
End If
|
|
Dim bNcGen As Boolean = (nPar2 >= 1)
|
|
Dim bExit As Boolean = (nPar2 >= 2)
|
|
' Esecuzione
|
|
CreateDoors(sFile, bNcGen, bExit)
|
|
EgtZoom(ZM.ALL)
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
' Se richiesta uscita immediata
|
|
If bExit Then
|
|
Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub EmitTitle()
|
|
' nome file
|
|
Dim sTitle As String = m_Controller.GetCurrFile()
|
|
If String.IsNullOrEmpty(sTitle) Then
|
|
sTitle = EgtMsg(MSG_TOPCOMMANDBAR + 1) & m_nInstance.ToString()
|
|
End If
|
|
' indicazione di modificato
|
|
If m_Controller.GetModified() Then
|
|
sTitle += "*"
|
|
End If
|
|
' dati del prodotto
|
|
sTitle += " - EgtCAM5"
|
|
' emissione del titolo
|
|
Application.Msn.NotifyColleagues(Application.UPDATEMAINWINDOWTITLE, sTitle)
|
|
End Sub
|
|
|
|
Private Sub LoadGridData()
|
|
IniFile.dSnapStepMm = GetPrivateProfileDouble(S_GRID, K_SNAPSTEP, 10)
|
|
IniFile.dSnapStepInch = GetPrivateProfileDouble(S_GRID, K_SNAPSTEPINCH, 10)
|
|
IniFile.nMinLineSStep = GetPrivateProfileInt(S_GRID, K_MINLINESSTEP, 1)
|
|
IniFile.nMajLineSStep = GetPrivateProfileInt(S_GRID, K_MAJLINESSTEP, 10)
|
|
IniFile.nExtSStep = GetPrivateProfileInt(S_GRID, K_EXTSSTEP, 50)
|
|
IniFile.MinLnColor = New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MINLNCOLOR, IniFile.MinLnColor)
|
|
IniFile.MajLnColor = New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MAJLNCOLOR, IniFile.MajLnColor)
|
|
EgtSetGridFrame(Frame3d.GLOB)
|
|
UpdateGridData()
|
|
End Sub
|
|
|
|
Private Sub UpdateGridData()
|
|
If IniFile.m_bMmUnits Then
|
|
EgtSetGridGeo(IniFile.dSnapStepMm, IniFile.nMinLineSStep, IniFile.nMajLineSStep, IniFile.nExtSStep)
|
|
Else
|
|
EgtSetGridGeo(IniFile.dSnapStepInch, IniFile.nMinLineSStep, IniFile.nMajLineSStep, IniFile.nExtSStep)
|
|
End If
|
|
EgtSetGridColor(IniFile.MinLnColor, IniFile.MajLnColor)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that manage the visibility of the ProjectPage's Panels
|
|
''' </summary>
|
|
Sub RegisterGridViewPanelCommands()
|
|
Application.Msn.Register(Application.WIREFRAME, Sub()
|
|
m_ProjectScene.WireFrame()
|
|
End Sub)
|
|
Application.Msn.Register(Application.HIDDENLINE, Sub()
|
|
m_ProjectScene.HiddenLine()
|
|
End Sub)
|
|
Application.Msn.Register(Application.SHADING, Sub()
|
|
m_ProjectScene.Shading()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ZOOMALL, Sub()
|
|
m_ProjectScene.ZoomAll()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ZOOMIN, Sub()
|
|
m_ProjectScene.ZoomIn()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ZOOMOUT, Sub()
|
|
m_ProjectScene.ZoomOut()
|
|
End Sub)
|
|
Application.Msn.Register(Application.TOPVIEW, Sub()
|
|
m_ProjectScene.TopView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.FRONTVIEW, Sub()
|
|
m_ProjectScene.FrontView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.LEFTVIEW, Sub()
|
|
m_ProjectScene.LeftView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.BACKVIEW, Sub()
|
|
m_ProjectScene.BackView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.RIGHTVIEW, Sub()
|
|
m_ProjectScene.RightView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ISOVIEWSW, Sub()
|
|
m_ProjectScene.IsoViewSW()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ISOVIEWSE, Sub()
|
|
m_ProjectScene.IsoViewSE()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ISOVIEWNE, Sub()
|
|
m_ProjectScene.IsoViewNE()
|
|
End Sub)
|
|
Application.Msn.Register(Application.ISOVIEWNW, Sub()
|
|
m_ProjectScene.IsoViewNW()
|
|
End Sub)
|
|
Application.Msn.Register(Application.VIEWTOCPLANE, Sub()
|
|
m_ProjectScene.CPlaneView()
|
|
End Sub)
|
|
Application.Msn.Register(Application.SETSTATUSANALYZE, Sub()
|
|
m_ProjectScene.SetStatusAnalyze()
|
|
End Sub)
|
|
Application.Msn.Register(Application.RESETSTATUSANALYZE, Sub()
|
|
m_ProjectScene.ResetStatusAnalyze()
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREE, GDB_ID.NULL)
|
|
End Sub)
|
|
Application.Msn.Register(Application.SETSTATUSGETDISTANCE, Sub()
|
|
m_ProjectScene.SetStatusGetDistance()
|
|
End Sub)
|
|
Application.Msn.Register(Application.RESETSTATUSGETDISTANCE, Sub()
|
|
m_ProjectScene.ResetStatusGetDistance()
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, String.Empty)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANETOP, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.TOP)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEFRONT, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.FRONT)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANERIGHT, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.RIGHT)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEBACK, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.BACK)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANELEFT, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.LEFT)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEBOTTOM, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.BOTTOM)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEVIEW, Sub()
|
|
m_Controller.SetLastInteger(Controller.GRID_TYPE.VIEW)
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEELEVATION, Sub()
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_ELEVATION)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEORIGIN, Sub()
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_ORIGIN)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEROTATE, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_ROTATE)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_ROTATE3D)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANE3P, Sub()
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_3P)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEPERPOBJ, Sub()
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_PERPCURVE)
|
|
End Sub)
|
|
Application.Msn.Register(Application.CPLANEOBJ, Sub()
|
|
m_Controller.ExecuteCommand(Controller.CMD.GRID_OBJ)
|
|
End Sub)
|
|
End Sub
|
|
|
|
Sub RegisterDrawPanelCommands()
|
|
Application.Msn.Register(Application.GETCURRLAYER, Sub()
|
|
Dim CurrLayer As Integer = m_Controller.GetCurrLayer()
|
|
Application.Msn.NotifyColleagues(Application.SETCURRLAYER, CurrLayer)
|
|
End Sub)
|
|
|
|
Application.Msn.Register(Application.POINT, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.FRAME)
|
|
ElseIf (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.VECTOR)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.POINT)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.LINE2P, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
m_Controller.SetContinue()
|
|
'EmitStripStatusOutput(EgtMsg(399)) ' Continue : 'L' with line, 'A' with arc
|
|
End If
|
|
m_Controller.ExecuteCommand(Controller.CMD.LINE2P)
|
|
End Sub)
|
|
Application.Msn.Register(Application.LINEPDL, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.LINEPDL)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.LINEPVL)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.ARCPDP, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
m_Controller.SetContinue()
|
|
'EmitStripStatusOutput(EgtMsg(399)) ' Continue : 'L' with line, 'A' with arc
|
|
End If
|
|
m_Controller.ExecuteCommand(Controller.CMD.ARCPDP)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.ARCPVP)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.POLYGON, Sub()
|
|
'If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.POLYGON)
|
|
'Else
|
|
' m_Controller.ExecuteCommand(Controller.CMD.POLYGONSIDE)
|
|
'End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.TEXT, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.TEXT)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.TEXTPLUS)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.PLANE, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
|
|
m_Controller.ExecuteCommand(Controller.CMD.REGION)
|
|
Else
|
|
m_Controller.ExecuteCommand(Controller.CMD.PLANE)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.DELETE, Sub()
|
|
m_Controller.SetLastInteger(GDB_ID.SEL)
|
|
m_Controller.ExecuteCommand(Controller.CMD.DELETE)
|
|
End Sub)
|
|
Application.Msn.Register(Application.JOINCURVE, Sub()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
m_Controller.SetLastBoolean(False)
|
|
Else
|
|
m_Controller.SetLastBoolean(True)
|
|
End If
|
|
m_Controller.ExecuteCommand(Controller.CMD.JOINCURVE)
|
|
End Sub)
|
|
End Sub
|
|
|
|
Sub RegisterDrawOptionPanelCommands()
|
|
Application.Msn.Register(Application.NOTIFYINPUTTEXT, Sub(sInputText As String)
|
|
m_InputText = sInputText
|
|
End Sub)
|
|
Application.Msn.Register(Application.SETLASTBOOLEAN, Sub(bBoolean As Boolean)
|
|
m_Controller.SetLastBoolean(bBoolean)
|
|
End Sub)
|
|
Application.Msn.Register(Application.SETLASTINTEGER, Sub(nInteger As Integer)
|
|
m_Controller.SetLastInteger(nInteger)
|
|
End Sub)
|
|
Application.Msn.Register(Application.SHOW, Sub(sString As String)
|
|
m_Controller.Show(sString)
|
|
End Sub)
|
|
Application.Msn.Register(Application.DONE, Sub(sString As String)
|
|
m_Controller.Done(sString)
|
|
End Sub)
|
|
Application.Msn.Register(Application.SAVEOBJECT, Sub(SaveObjectParam As SaveObjectParam)
|
|
m_Controller.SaveObject(SaveObjectParam.nId, SaveObjectParam.sDir, SaveObjectParam.nType)
|
|
End Sub)
|
|
End Sub
|
|
|
|
Sub RegisterStatusBarCommands()
|
|
Application.Msn.Register(Application.STATUSCURRPOSTYPECOMMAND, Sub()
|
|
m_bCPlaneTypePos = Not m_bCPlaneTypePos
|
|
If m_bCPlaneTypePos Then
|
|
Application.Msn.NotifyColleagues(Application.STATUSCURRPOSTYPETEXT, "GRID")
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.STATUSCURRPOSTYPETEXT, "WORLD")
|
|
End If
|
|
m_ProjectScene.SetGridCursorPos(m_bCPlaneTypePos)
|
|
End Sub)
|
|
Application.Msn.Register(Application.STATUSUNITSCOMMAND, Sub()
|
|
IniFile.m_bMmUnits = Not IniFile.m_bMmUnits
|
|
Application.Msn.NotifyColleagues(Application.UPDATESTATUSUNITS, IniFile.m_bMmUnits)
|
|
UpdateGridData()
|
|
EgtDraw()
|
|
End Sub)
|
|
End Sub
|
|
|
|
Sub RegisterControllerCommands()
|
|
Application.Msn.Register(Application.EXECUTECOMMAND, Sub(nCmd As Controller.CMD)
|
|
m_Controller.ExecuteCommand(nCmd)
|
|
End Sub)
|
|
Application.Msn.Register(Application.MANAGEMODIFIED, Sub()
|
|
Dim AllowClose = m_Controller.ManageModified()
|
|
Application.Msn.NotifyColleagues(Application.ALLOWWINDOWTOCLOSE, AllowClose)
|
|
End Sub)
|
|
End Sub
|
|
|
|
Sub RegisterMainWindowCommands()
|
|
Application.Msn.Register(Application.LOADGRIDDATA, Sub()
|
|
LoadGridData()
|
|
End Sub)
|
|
Application.Msn.Register(Application.RESETSTATUS, Sub()
|
|
m_Controller.ResetStatus()
|
|
End Sub)
|
|
Application.Msn.Register(Application.EMITTITLE, Sub()
|
|
EmitTitle()
|
|
End Sub)
|
|
Application.Msn.Register(Application.MAINWINDOW_CONTENTRENDERED, Sub()
|
|
ProcessCommandLine()
|
|
End Sub)
|
|
|
|
End Sub
|
|
|
|
Private Sub ManageTopCommandBar()
|
|
Application.Msn.Register(Application.NEWPROJECT, Sub()
|
|
m_Controller.NewProject(True)
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREENOMARK, EgtGetCurrLayer())
|
|
End Sub)
|
|
Application.Msn.Register(Application.OPENPROJECT, Sub(sFilePath As String)
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
Dim sDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sDir)
|
|
m_Controller.OpenProject(sDir)
|
|
Else
|
|
m_Controller.OpenProject(sFilePath, False)
|
|
End If
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREENOMARK, EgtGetCurrLayer())
|
|
End Sub)
|
|
Application.Msn.Register(Application.SAVEPROJECT, Sub()
|
|
Dim nType As NGE = DirectCast(GetPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
|
|
If Not String.IsNullOrWhiteSpace(m_Controller.GetCurrFile()) Then
|
|
m_Controller.SaveProject(nType)
|
|
Else
|
|
Dim sFile As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sFile)
|
|
sFile.TrimEnd("\"c)
|
|
sFile += "\New" & m_nInstance.ToString() & ".nge"
|
|
m_Controller.SaveAsProject(sFile, nType)
|
|
End If
|
|
|
|
End Sub)
|
|
Application.Msn.Register(Application.SAVEASPROJECT, Sub()
|
|
Dim nType As NGE = DirectCast(GetPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
|
|
Dim sFile As String = m_Controller.GetCurrFile()
|
|
If String.IsNullOrWhiteSpace(sFile) Then
|
|
GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sFile)
|
|
sFile.TrimEnd("\"c)
|
|
sFile += "\New" & m_nInstance.ToString() & ".nge"
|
|
End If
|
|
m_Controller.SaveAsProject(sFile, nType)
|
|
End Sub)
|
|
Application.Msn.Register(Application.INSERTPROJECT, Sub()
|
|
' eseguo
|
|
Dim sDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sDir)
|
|
m_Controller.InsertProject(sDir)
|
|
End Sub)
|
|
Application.Msn.Register(Application.IMPORTPROJECT, Sub()
|
|
Dim sDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
|
|
m_Controller.ImportProject(sDir)
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREENOMARK, EgtGetCurrLayer())
|
|
End Sub)
|
|
Application.Msn.Register(Application.EXPORTPROJECT, Sub()
|
|
m_Controller.ExportProject(Path.ChangeExtension(m_Controller.GetCurrFile(), "dxf"))
|
|
End Sub)
|
|
Application.Msn.Register(Application.EXECSCRIPT, Sub(sFilePath As String)
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
Dim sDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LASTLUADIR, "", sDir)
|
|
m_Controller.Exec(sDir)
|
|
Else
|
|
m_Controller.Exec(sFilePath, False)
|
|
End If
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREE, EgtGetCurrLayer())
|
|
If EgtGetCurrMachGroup() <> GDB_ID.NULL Then
|
|
Application.Msn.NotifyColleagues(Application.SETMACHININGMODE)
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.DOORSSCRIPT, Sub(sFilePath As String)
|
|
Dim bOk As Boolean
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
bOk = ExecDoors(m_ProjectScene, String.Empty)
|
|
Else
|
|
bOk = ExecDoors(m_ProjectScene, sFilePath)
|
|
End If
|
|
EgtResetCurrPartLayer()
|
|
OnUpdateUI(Nothing, True)
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREE, EgtGetCurrLayer())
|
|
If bOk Then
|
|
IniFile.m_MruDoors.Add(IniFile.m_DDFFilePath)
|
|
Dim sFile As String = String.Empty
|
|
If EgtGetCurrFilePath(sFile) Then
|
|
IniFile.m_MruFiles.Add(sFile)
|
|
End If
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_DOORSERRORS + 2))
|
|
IniFile.m_MruDoors.Remove(IniFile.m_DDFFilePath)
|
|
Try
|
|
Dim sErrFilePath As String = Path.ChangeExtension(IniFile.m_DDFFilePath, ".txt")
|
|
Dim fileReader As String = My.Computer.FileSystem.ReadAllText(sErrFilePath)
|
|
Dim Lines() As String = fileReader.Split(ControlChars.CrLf.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
|
|
Dim values() As String = Lines(0).Split(CChar("=")).ToArray
|
|
Lines(0) = EgtMsg(MSG_DOORSERRORS + 1) & " " & Convert.ToInt32(values(1))
|
|
fileReader = String.Empty
|
|
For Index = 1 To Lines.Count - 1
|
|
fileReader &= (Lines(Index) + ControlChars.CrLf.ToCharArray())
|
|
Next
|
|
MessageBox.Show(fileReader, Lines(0).ToUpper, MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Catch ex As Exception
|
|
MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 7))
|
|
End Try
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.DMACHSCRIPT, Sub()
|
|
Dim bOk As Boolean = ExecDoorsMachining(m_ProjectScene)
|
|
OnUpdateUI(Nothing, True)
|
|
If EgtGetCurrMachGroup() <> GDB_ID.NULL Then
|
|
Application.Msn.NotifyColleagues(Application.SETMACHININGMODE)
|
|
End If
|
|
If Not bOk Then Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_DOORSERRORS + 2))
|
|
End Sub)
|
|
Application.Msn.Register(Application.GUNSTOCKSCRIPT, Sub(sFilePath As String)
|
|
Dim bOk As Boolean
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
bOk = ExecGunStock(m_ProjectScene, String.Empty)
|
|
Else
|
|
bOk = ExecGunStock(m_ProjectScene, sFilePath)
|
|
End If
|
|
EgtResetCurrPartLayer()
|
|
OnUpdateUI(Nothing, True)
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREE, EgtGetCurrLayer())
|
|
If EgtGetCurrMachGroup() <> GDB_ID.NULL Then
|
|
Application.Msn.NotifyColleagues(Application.SETMACHININGMODE)
|
|
End If
|
|
If bOk Then
|
|
IniFile.m_MruNewGunStock.Add(IniFile.m_MODFilePath)
|
|
Dim sFile As String = String.Empty
|
|
If EgtGetCurrFilePath(sFile) Then
|
|
IniFile.m_MruFiles.Add(sFile)
|
|
End If
|
|
Else
|
|
IniFile.m_MruNewGunStock.Remove(IniFile.m_MODFilePath)
|
|
Try
|
|
Dim sErrFilePath As String = Path.ChangeExtension(IniFile.m_MODFilePath, ".txt")
|
|
Dim fileReader As String = My.Computer.FileSystem.ReadAllText(sErrFilePath)
|
|
Dim Lines() As String = fileReader.Split(ControlChars.CrLf.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
|
|
Dim values() As String = Lines(0).Split(CChar("=")).ToArray
|
|
Lines(0) = EgtMsg(MSG_DOORSERRORS + 1) & " " & Convert.ToInt32(values(1))
|
|
fileReader = String.Empty
|
|
For Index = 1 To Lines.Count - 1
|
|
fileReader &= (Lines(Index) + ControlChars.CrLf.ToCharArray())
|
|
Next
|
|
MessageBox.Show(fileReader, Lines(0).ToUpper, MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Catch ex As Exception
|
|
MessageBox.Show(EgtMsg(MSG_DOORSERRORS + 7))
|
|
End Try
|
|
End If
|
|
End Sub)
|
|
|
|
End Sub
|
|
|
|
Private Sub ManageClosingApplication()
|
|
Application.Msn.Register(Application.CLOSEAPPLICATION, Sub()
|
|
' Salvo modo di visualizzazione
|
|
WritePrivateProfileString(S_SCENE, K_SHOWMODE, EgtGetShowMode().ToString)
|
|
' Salvo stato visualizzazione direzione curve
|
|
WritePrivateProfileString(S_SCENE, K_CURVEDIR, If(EgtGetShowCurveDirection(), 1, 0).ToString)
|
|
' Salvo stato visualizzazione griglia
|
|
WritePrivateProfileString(S_GRID, K_DRAWSHOWGRID, If(IniFile.m_bDrawShowGrid, 1, 0).ToString)
|
|
WritePrivateProfileString(S_GRID, K_MACHININGSHOWGRID, If(IniFile.m_bMachiningShowGrid, 1, 0).ToString)
|
|
' Salvo stato unità di misura per interfaccia utente
|
|
WritePrivateProfileString(S_SCENE, K_MMUNITS, If(IniFile.m_bMmUnits, 1, 0).ToString)
|
|
' Salvo dimensioni griglie in Mm e Inch
|
|
WritePrivateProfileString(S_GRID, K_SNAPSTEP, DoubleToString(IniFile.dSnapStepMm, 4))
|
|
WritePrivateProfileString(S_GRID, K_SNAPSTEPINCH, DoubleToString(IniFile.dSnapStepInch, 4))
|
|
End Sub)
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "SCENE EVENTS"
|
|
|
|
Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) Handles m_ProjectScene.OnCursorPos
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYCURRPOS, sCursorPos)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSetObjFilterForSelect(sender As Object, bZeroDim As Boolean, bCurve As Boolean,
|
|
bSurf As Boolean, bVolume As Boolean, bExtra As Boolean) Handles m_ProjectScene.OnMouseSetObjFilterForSelect
|
|
m_Controller.MouseSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedAll(ByVal sender As Object) Handles m_ProjectScene.OnMouseSelectedAll
|
|
' Se in modalità Draw seleziono tutto
|
|
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then m_Controller.MouseSelectedAll()
|
|
' Sono in modalità Machining, se la modalità di selezione è NULL non seleziono nulla ed esco
|
|
If m_SceneSelMode = SceneSelModeOpt.NULL Then Return
|
|
' Cerco i pezzi all'interno dei grezzi
|
|
Dim nRawPart As Integer = EgtGetFirstRawPart()
|
|
While nRawPart <> GDB_ID.NULL
|
|
Dim nPart As Integer = EgtGetFirstPartInRawPart(nRawPart)
|
|
While nPart <> GDB_ID.NULL
|
|
Dim nLayer As Integer = EgtGetFirstGroupInGroup(nPart)
|
|
While nLayer <> GDB_ID.NULL
|
|
Dim nObj As Integer = EgtGetFirstInGroup(nLayer)
|
|
While nObj <> GDB_ID.NULL
|
|
EgtSelectObj(nObj)
|
|
nObj = EgtGetNext(nObj)
|
|
End While
|
|
nLayer = EgtGetNextGroup(nLayer)
|
|
End While
|
|
nPart = EgtGetNextPartInRawPart(nPart)
|
|
End While
|
|
nRawPart = EgtGetNextRawPart(nRawPart)
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub OnMouseDeselectedAll(ByVal sender As Object) Handles m_ProjectScene.OnMouseDeselectedAll
|
|
m_Controller.MouseDeselectedAll()
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectingObj(ByVal sender As Object, ByVal nId As Integer, ByRef bOk As Boolean) Handles m_ProjectScene.OnMouseSelectingObj
|
|
' Se oggetto già rifiutato non faccio le verifiche
|
|
If Not bOk Then Return
|
|
' Se in modalità Draw accetto tutto
|
|
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then Return
|
|
' Sono in modalità Machining
|
|
Select Case m_SceneSelMode
|
|
Case SceneSelModeOpt.NULL
|
|
bOk = False
|
|
Case SceneSelModeOpt.PARTCURVES, SceneSelModeOpt.PARTSURFACES, SceneSelModeOpt.PARTCURVESANDSURFACES
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
If Not IsPartInRaw(nPartId) Then
|
|
bOk = False
|
|
End If
|
|
Case Else
|
|
bOk = False
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) Handles m_ProjectScene.OnMouseSelectedObj
|
|
m_Controller.MouseSelectedObj(nId, bLast)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) Handles m_ProjectScene.OnMouseSelectedPart
|
|
m_Controller.MouseSelectedPart(nId)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer) Handles m_ProjectScene.OnMouseSelectedLayer
|
|
m_Controller.MouseSelectedLayer(nId)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedPath(ByVal sender As Object, ByVal nId As Integer, ByVal bHaltOnFork As Boolean) Handles m_ProjectScene.OnMouseSelectedPath
|
|
m_Controller.MouseSelectedPath(nId, bHaltOnFork)
|
|
End Sub
|
|
|
|
Private Sub OnMousePointFromSelection(ByVal sender As Object, ByVal nId As Integer, ByVal PtP As Point3d, ByVal nAux As Integer) Handles m_ProjectScene.OnMousePointFromSelection
|
|
m_Controller.SetPointFromSelection(nId, PtP, nAux)
|
|
End Sub
|
|
|
|
Private Sub OnMouseDone(ByVal sender As Object) Handles m_ProjectScene.OnMouseDone
|
|
m_Controller.Done(m_InputText)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedPoint(ByVal sender As Object, ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer) Handles m_ProjectScene.OnMouseSelectedPoint
|
|
Dim bDone As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) <> ModifierKeys.Control
|
|
m_Controller.MouseSelectedPoint(PtP, nSep, nId, bDone)
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d) Handles m_ProjectScene.OnMouseSelectedDir
|
|
m_Controller.SetLastVector3d(VtDir)
|
|
End Sub
|
|
|
|
Private Sub OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d) Handles m_ProjectScene.OnMouseMoveSelPoint
|
|
m_Controller.MouseMoveInSelectionPoint(PtP)
|
|
End Sub
|
|
|
|
Private Sub OnMouseAnalyzed(ByVal sender As Object, ByVal nId As Integer) Handles m_ProjectScene.OnMouseAnalyzed
|
|
Application.Msn.NotifyColleagues(Application.UPDATEOBJINOBJTREE, nId)
|
|
Application.Msn.NotifyColleagues(Application.SELECTIDINOBJTREE, nId)
|
|
End Sub
|
|
|
|
Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String) Handles m_ProjectScene.OnShowDistance
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, sDistance)
|
|
End Sub
|
|
|
|
Private Sub Scene1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles m_ProjectScene.KeyDown
|
|
' Con DEL eseguo cancellazione delle entità selezionate
|
|
If e.KeyData = System.Windows.Forms.Keys.Delete Then
|
|
m_Controller.SetLastInteger(GDB_ID.SEL)
|
|
m_Controller.ExecuteCommand(Controller.CMD.DELETE)
|
|
' Con SPAZIO ripeto l'ultimo comando
|
|
ElseIf e.KeyData = System.Windows.Forms.Keys.Space Then
|
|
m_Controller.RepeatLastCommand()
|
|
' Con 'A' e in modalità continuazione, forzo il passaggio ad arco
|
|
ElseIf e.KeyData = System.Windows.Forms.Keys.A And m_Controller.GetContinue() Then
|
|
m_Controller.ContinueArcPDP()
|
|
' Con 'L' e in modalità continuazione, forzo il passaggio a retta
|
|
ElseIf e.KeyData = System.Windows.Forms.Keys.L And m_Controller.GetContinue() Then
|
|
m_Controller.ContinueLine2P()
|
|
' Con 'V' cambio lo stato del check
|
|
ElseIf e.KeyData = System.Windows.Forms.Keys.V Then
|
|
Application.Msn.NotifyColleagues(Application.CHANGEINPUTBOXCHECK)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "CONTROLLER EVENTS"
|
|
|
|
Private Sub OnNewProject(ByVal sender As Object, ByVal bOk As Boolean) Handles m_Controller.OnNewProject
|
|
If Not bOk Then
|
|
MessageBox.Show(EgtMsg(10002), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error on new file - Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnOpeningProject(ByVal sender As Object) Handles m_Controller.OnOpeningProject
|
|
Application.Msn.NotifyColleagues(Application.CLEAROBJTREE)
|
|
End Sub
|
|
|
|
Private Sub OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnOpenProject
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile))
|
|
If bOk Then
|
|
IniFile.m_MruFiles.Add(sFile)
|
|
Else
|
|
IniFile.m_MruFiles.Remove(sFile)
|
|
Dim sMsg As String = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file
|
|
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnSavingProject(ByVal sender As Object) Handles m_Controller.OnSavingProject
|
|
End Sub
|
|
|
|
Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnSavedProject
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile))
|
|
If bOk Then
|
|
IniFile.m_MruFiles.Add(sFile)
|
|
Else
|
|
IniFile.m_MruFiles.Remove(sFile)
|
|
Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file
|
|
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnSavingObject(ByVal sender As Object) Handles m_Controller.OnSavingObject
|
|
End Sub
|
|
|
|
Private Sub OnSavedObject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnSavedObject
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNGEOBJDIR, Path.GetDirectoryName(sFile))
|
|
If bOk Then
|
|
IniFile.m_MruFiles.Add(sFile)
|
|
Else
|
|
IniFile.m_MruFiles.Remove(sFile)
|
|
Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file
|
|
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean) Handles m_Controller.OnImportingProject
|
|
If bOkType Then
|
|
Application.Msn.NotifyColleagues(Application.CLEAROBJTREE)
|
|
Else
|
|
MessageBox.Show(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) Handles m_Controller.OnImportedProject
|
|
WritePrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile))
|
|
If Not bOk Then
|
|
Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file
|
|
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnExportingProject(ByVal sender As Object) Handles m_Controller.OnExportingProject
|
|
End Sub
|
|
|
|
Private Sub OnExportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnExportedProject
|
|
WritePrivateProfileString(S_GENERAL, K_LASTEXPDIR, Path.GetDirectoryName(sFile))
|
|
If Not bOk Then
|
|
Dim sMsg As String = EgtMsg(10007) & " '" & sFile & "'" 'Error exporting file
|
|
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnExecutingScript(ByVal sender As Object) Handles m_Controller.OnExecutingScript
|
|
Application.Msn.NotifyColleagues(Application.CLEAROBJTREE)
|
|
'Abilito progress e bottone stop
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSPROGRESS, 0)
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSSTOP, True)
|
|
' Dichiaro script in esecuzione
|
|
m_bScriptRunning = True
|
|
End Sub
|
|
|
|
Private Sub OnExecutedScript(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean, ByVal sError As String) Handles m_Controller.OnExecutedScript
|
|
' Salvo path dello script in lista recenti
|
|
WritePrivateProfileString(S_GENERAL, K_LASTLUADIR, Path.GetDirectoryName(sFile))
|
|
If bOk Then
|
|
IniFile.m_MruScripts.Add(sFile)
|
|
Else
|
|
IniFile.m_MruScripts.Remove(sFile)
|
|
MessageBox.Show(sError, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
' Disabilito progress e bottone stop
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSPROGRESS, 0)
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSSTOP, False)
|
|
'' Dichiaro terminata esecuzione script
|
|
m_bScriptRunning = False
|
|
End Sub
|
|
|
|
Private Sub OnPrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String,
|
|
ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean) Handles m_Controller.PrepareInputBox
|
|
Application.Msn.NotifyColleagues(Application.PREPAREINPUTBOX, New PrepareInputBoxParam(sTitle, sLabel, sCheckLabel, bShowCombo, bShowBtn))
|
|
End Sub
|
|
|
|
Private Sub OnSetInputBoxText(ByVal sText As String) Handles m_Controller.SetInputBoxText
|
|
Application.Msn.NotifyColleagues(Application.SETINPUTBOXTEXT, sText)
|
|
End Sub
|
|
|
|
Private Sub OnSetInputBoxCheck(ByVal bCheck As Boolean) Handles m_Controller.SetInputBoxCheck
|
|
Application.Msn.NotifyColleagues(Application.SETINPUTBOXCHECK, bCheck)
|
|
End Sub
|
|
|
|
Private Sub OnAddInputBoxCombo(ByVal sText As String, ByVal bSelected As Boolean) Handles m_Controller.AddInputBoxCombo
|
|
Application.Msn.NotifyColleagues(Application.ADDINPUTBOXCOMBO, New AddInputBoxComboParam(sText, bSelected))
|
|
End Sub
|
|
|
|
Private Sub OnUpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean) Handles m_Controller.UpdateUI
|
|
' pulisco input e relativi messaggi
|
|
Application.Msn.NotifyColleagues(Application.RESETINPUTBOX)
|
|
If m_Controller.GetContinue() Then
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, (EgtMsg(399))) ' Continue : 'L' with line, 'A' with arc
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, (""))
|
|
End If
|
|
' aggiorno dati correnti
|
|
EmitTitle()
|
|
EmitCurrPartLayer()
|
|
If bReloadUI Then
|
|
Application.Msn.NotifyColleagues(Application.LOADOBJTREE)
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.UPDATEOBJTREE)
|
|
End If
|
|
' aggiorno macchina corrente
|
|
Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE)
|
|
End Sub
|
|
|
|
Private Sub OutputInfo(ByVal sender As Object, ByVal sText As String) Handles m_Controller.OutputInfo
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, sText)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "STATUSBAR EVENTS"
|
|
|
|
Private Sub ProjectScene_OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean) Handles m_ProjectScene.OnChangedSnapPointType
|
|
If bUser Then
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPEBACKGROUND, New SolidColorBrush(SystemColors.ControlColor))
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPEBACKGROUND, Brushes.Bisque)
|
|
End If
|
|
Select Case nSpType
|
|
Case SP.PT_SKETCH
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1102)) 'Sketch Point
|
|
Case SP.PT_GRID
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1104)) 'Grid Point
|
|
Case SP.PT_END
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1106)) 'End Point
|
|
Case SP.PT_MID
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1108)) 'Mid Point
|
|
Case SP.CENTER
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1110)) 'Center
|
|
Case SP.CENTROID
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1112)) 'Centroid
|
|
Case SP.PT_NEAR
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1114)) 'Near Point
|
|
Case SP.PT_INTERS
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1116)) 'Inters Point
|
|
Case SP.PT_TANGENT
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1118)) 'Tang Point
|
|
Case SP.PT_PERPENDICULAR
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1120)) 'Perp Point
|
|
Case SP.PT_MINDIST
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, EgtMsg(1122)) 'MinDist Point
|
|
Case Else
|
|
Application.Msn.NotifyColleagues(Application.STATUSSNAPPOINTTYPETEXT, "---")
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' StatusBar events
|
|
|
|
#Region "DrawOptionPanel"
|
|
|
|
Private Sub EmitCurrPartLayer()
|
|
Dim sText As String = " "
|
|
Dim sName As String = String.Empty
|
|
Dim colObj As Color3d
|
|
EgtGetColor(GDB_ID.ROOT, colObj)
|
|
Dim nCurrPart As Integer = m_Controller.GetCurrPart()
|
|
If nCurrPart <> GDB_ID.NULL Then
|
|
If EgtGetName(nCurrPart, sName) Then
|
|
sText = sName
|
|
Else
|
|
sText = "Part " + nCurrPart.ToString()
|
|
End If
|
|
EgtGetCalcColor(nCurrPart, colObj)
|
|
Dim nCurrLayer As Integer = m_Controller.GetCurrLayer()
|
|
If nCurrLayer <> GDB_ID.NULL And EgtExistsObj(nCurrLayer) Then
|
|
If EgtGetName(nCurrLayer, sName) Then
|
|
sText += " --> " + sName
|
|
Else
|
|
sText += " --> Layer " + nCurrLayer.ToString()
|
|
End If
|
|
EgtGetCalcColor(nCurrLayer, colObj)
|
|
End If
|
|
End If
|
|
Application.Msn.NotifyColleagues(Application.UPDATEHEADERNAME, sText)
|
|
colObj.A = 100
|
|
Application.Msn.NotifyColleagues(Application.UPDATEHEADERCOLOR, colObj)
|
|
End Sub
|
|
|
|
#End Region 'DrawOptionPanel
|
|
|
|
#Region "Scene selection"
|
|
|
|
Private m_SceneSelMode As SceneSelModeOpt
|
|
Friend Property SceneSelMode As SceneSelModeOpt
|
|
Get
|
|
Return m_SceneSelMode
|
|
End Get
|
|
Set(value As SceneSelModeOpt)
|
|
If value <> m_SceneSelMode Then
|
|
m_SceneSelMode = value
|
|
Select Case m_SceneSelMode
|
|
Case SceneSelModeOpt.NULL
|
|
m_ProjectScene.SetObjFilterForSel(False, False, False, False, False)
|
|
EgtSetObjFilterForSelect(True, True, True, True, True)
|
|
Case SceneSelModeOpt.PARTCURVES
|
|
m_ProjectScene.SetObjFilterForSel(False, True, False, False, False)
|
|
Case SceneSelModeOpt.PARTSURFACES
|
|
m_ProjectScene.SetObjFilterForSel(False, False, True, False, False)
|
|
Case SceneSelModeOpt.PARTCURVESANDSURFACES
|
|
m_ProjectScene.SetObjFilterForSel(False, True, True, False, False)
|
|
Case SceneSelModeOpt.ALL
|
|
m_ProjectScene.SetObjFilterForSel(True, True, True, True, True)
|
|
Case Else
|
|
m_ProjectScene.SetObjFilterForSel(False, False, False, False, False)
|
|
End Select
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Friend Function IsPartInRaw(nSearchedPartId As Integer) As Boolean
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
If nPartId = nSearchedPartId Then
|
|
Return True
|
|
End If
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' Scene selection
|
|
|
|
End Class
|
|
|
|
End Namespace |