ad38e4d3e1
This reverts commit 00a338c202.
212 lines
6.0 KiB
VB.net
212 lines
6.0 KiB
VB.net
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class SceneHostVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_MainScene As Scene
|
|
Public ReadOnly Property MainScene As Scene
|
|
Get
|
|
Return m_MainScene
|
|
End Get
|
|
End Property
|
|
|
|
' Scene controller
|
|
Private WithEvents m_MainController As New Controller
|
|
Public ReadOnly Property MainController As Controller
|
|
Get
|
|
Return m_MainController
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in LibMap
|
|
LibMap.SetRefSceneHostVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Sub SetMainScene(ViewMainScene As Scene)
|
|
m_MainScene = ViewMainScene
|
|
InitScene()
|
|
End Sub
|
|
|
|
Public Overridable Sub InitScene()
|
|
End Sub
|
|
|
|
Public Overridable Sub InitSceneEvents()
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "ProjectManager"
|
|
|
|
Public Overridable Function NewProject() As Boolean
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
Return m_MainController.NewProject()
|
|
End Function
|
|
|
|
Public Overridable Function OpenProject(sFilePath As String) As Boolean
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
' Recupero cartella dell'ultimo progetto aperto
|
|
Dim sDir As String = m_MainController.GetCurrFile()
|
|
If String.IsNullOrWhiteSpace(sDir) Then
|
|
GetMainPrivateProfileString(S_MRUFILES, K_FILE & "1", "", sDir)
|
|
End If
|
|
If Not String.IsNullOrWhiteSpace(sDir) Then
|
|
sDir = Path.GetDirectoryName(sDir)
|
|
End If
|
|
Return m_MainController.OpenProject(sDir)
|
|
Else
|
|
Return m_MainController.OpenProject(sFilePath, False)
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function SaveProject() As Boolean
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
Dim nType As NGE = DirectCast(GetMainPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
|
|
Dim sFile As String = m_MainController.GetCurrFile()
|
|
If Not String.IsNullOrWhiteSpace(sFile) Then
|
|
Return m_MainController.SaveProject(nType)
|
|
Else
|
|
Return SaveAsProject()
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function SaveAsProject() As Boolean
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
Dim nType As NGE = DirectCast(GetMainPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
|
|
Dim sFile As String = m_MainController.GetCurrFile()
|
|
If String.IsNullOrWhiteSpace(sFile) Then
|
|
GetMainPrivateProfileString(S_MRUFILES, K_FILE & "1", "", sFile)
|
|
If Not String.IsNullOrWhiteSpace(sFile) Then
|
|
sFile = Path.GetDirectoryName(sFile) & "\"
|
|
End If
|
|
End If
|
|
|
|
Return m_MainController.SaveAsProject(sFile, nType)
|
|
End Function
|
|
|
|
Public Overridable Function InsertProject() As Boolean
|
|
Dim sDir As String = String.Empty
|
|
GetMainPrivateProfileString(S_MRUFILES, K_FILE & "1", "", sDir)
|
|
If Not String.IsNullOrWhiteSpace(sDir) Then
|
|
sDir = Path.GetDirectoryName(sDir)
|
|
End If
|
|
sDir.TrimEnd("\"c)
|
|
Return m_MainController.InsertProject(sDir)
|
|
End Function
|
|
|
|
Public Overridable Function ImportProject() As Boolean
|
|
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)
|
|
Return m_MainController.ImportProject(sDir)
|
|
End Function
|
|
|
|
Public Overridable Function ExportProject() As Boolean
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
Return m_MainController.ExportProject(Path.ChangeExtension(m_MainController.GetCurrFile(), "dxf"))
|
|
End Function
|
|
|
|
Public Overridable Function ExecScript(sFilePath As String) As Boolean
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
Dim sDir As String = String.Empty
|
|
GetMainPrivateProfileString(S_MRUSCRIPTS, K_FILE & "1", "", sDir)
|
|
If Not String.IsNullOrWhiteSpace(sDir) Then
|
|
sDir = Path.GetDirectoryName(sDir)
|
|
End If
|
|
sDir.TrimEnd("\"c)
|
|
Return m_MainController.Exec(sDir)
|
|
Else
|
|
Return m_MainController.Exec(sFilePath, False)
|
|
End If
|
|
End Function
|
|
|
|
#End Region ' ProjectManager
|
|
|
|
#Region "ShowMode"
|
|
|
|
Public Sub ShowMode(nType As SM)
|
|
Select Case nType
|
|
Case SM.WIREFRAME
|
|
MainScene.WireFrame()
|
|
Case SM.HIDDENLINE
|
|
MainScene.HiddenLine()
|
|
Case SM.SHADING
|
|
MainScene.Shading()
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' ShowMode
|
|
|
|
#Region "Zoom"
|
|
|
|
Public Sub ZoomMode(nType As ZM)
|
|
Select Case nType
|
|
Case ZM.ALL
|
|
MainScene.ZoomAll()
|
|
Case ZM.IN_
|
|
MainScene.ZoomIn()
|
|
Case ZM.OUT
|
|
MainScene.ZoomOut()
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' Zoom
|
|
|
|
#Region "ViewMode"
|
|
|
|
Public Sub ViewMode(nType As VT)
|
|
Select Case nType
|
|
Case VT.TOP
|
|
MainScene.TopView()
|
|
Case VT.FRONT
|
|
MainScene.FrontView()
|
|
Case VT.RIGHT
|
|
MainScene.RightView()
|
|
Case VT.BACK
|
|
MainScene.BackView()
|
|
Case VT.LEFT
|
|
MainScene.LeftView()
|
|
Case VT.BOTTOM
|
|
MainScene.BottomView()
|
|
Case VT.ISO_SW
|
|
MainScene.IsoViewSW()
|
|
Case VT.ISO_SE
|
|
MainScene.IsoViewSE()
|
|
Case VT.ISO_NE
|
|
MainScene.IsoViewNE()
|
|
Case VT.ISO_NW
|
|
MainScene.IsoViewNW()
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' ViewMode
|
|
|
|
#Region "GetDistance"
|
|
|
|
Public Sub GetDistanceON()
|
|
MainScene.SetStatusGetDistance()
|
|
End Sub
|
|
|
|
Public Sub GetDistanceOFF()
|
|
MainScene.ResetStatusGetDistance()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
End Class
|