197 lines
6.4 KiB
VB.net
197 lines
6.4 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
Imports System.IO
|
|
Imports System.Windows.Threading
|
|
|
|
Public Class SecondaryWindowVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_SplashScreen_Timer As New DispatcherTimer
|
|
Private m_WaitAfterRender As Integer = 0
|
|
|
|
Public ReadOnly Property sTitle As String
|
|
Get
|
|
Return "EgtStone3D"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sProjectName As String
|
|
Get
|
|
Dim sFilePath As String = ""
|
|
EgtGetCurrFilePath(sFilePath)
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
' Nuovo
|
|
sFilePath = EgtMsg(30501) & Map.refMainWindowVM.MainWindowM.nInstance.ToString()
|
|
Return sFilePath
|
|
Else
|
|
Return Path.GetFileNameWithoutExtension(sFilePath) & If(EgtGetModified(), "*", "")
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sProjectPath As String
|
|
Get
|
|
Dim sFilePath As String = ""
|
|
EgtGetCurrFilePath(sFilePath)
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
' Nuovo
|
|
sFilePath = EgtMsg(30501) & Map.refMainWindowVM.MainWindowM.nInstance.ToString()
|
|
End If
|
|
Return sFilePath
|
|
End Get
|
|
End Property
|
|
|
|
' Definizione Comandi
|
|
Private m_cmdAboutBox As ICommand
|
|
Private m_cmdCloseApplication As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Map.SetRefSecondaryWindowVM(Me)
|
|
' imposto e avvio contatore SplashScreen
|
|
m_SplashScreen_Timer.Interval = New TimeSpan(0, 0, 0, 0, 500)
|
|
AddHandler m_SplashScreen_Timer.Tick, AddressOf SplashScreenTimer_Tick
|
|
AddHandler Application.Current.MainWindow.KeyDown, AddressOf SecondaryWindow_KeyDown
|
|
If Not IsNothing(Map.refSplashScreen) Then
|
|
m_SplashScreen_Timer.Start()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub ContentRendered()
|
|
EgtSetView(VT.ISO_SE, False)
|
|
' provo a caricare progetto da linea di comando
|
|
|
|
'If Not ProcessCommandLine() Then
|
|
' ' altrimenti creo nuovo progetto di partenza
|
|
' Map.refTopPanelVM.NewProject(False)
|
|
If GetMainPrivateProfileInt(S_GENERAL, K_AUTOLOADLASTPROJ, 0) = 1 Then
|
|
Dim sLastProjectPath As String = String.Empty
|
|
GetMainPrivateProfileString(S_GENERAL, K_LASTPROJ, String.Empty, sLastProjectPath)
|
|
If Not String.IsNullOrWhiteSpace(sLastProjectPath) AndAlso File.Exists(sLastProjectPath) Then
|
|
Map.refTopPanelVM.OpenProject(sLastProjectPath)
|
|
End If
|
|
Else
|
|
Map.refTopPanelVM.NewProject(False)
|
|
End If
|
|
|
|
' resetto segnalazione modifiche
|
|
EgtResetModified()
|
|
' segno su contatore splashscreen render finito
|
|
m_WaitAfterRender = 1
|
|
'
|
|
End Sub
|
|
|
|
Private Sub SplashScreenTimer_Tick()
|
|
If m_WaitAfterRender > 1 Then
|
|
' chiudo SplashScreen
|
|
Map.refSplashScreen.Close()
|
|
m_SplashScreen_Timer.Stop()
|
|
ElseIf m_WaitAfterRender > 0 Then
|
|
m_WaitAfterRender += 1
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function ProcessCommandLine() As Boolean
|
|
' Se non ci sono veri parametri su linea di comando, esco (il primo è sempre il nome del programma)
|
|
If Environment.GetCommandLineArgs.Count() <= 1 Then Return False
|
|
' Recupero il primo vero parametro che dovrebbe essere il nome con estensione di un file
|
|
Dim sFile As String = Environment.GetCommandLineArgs(1)
|
|
Dim sExt As String = IO.Path.GetExtension(sFile).ToLower()
|
|
If String.IsNullOrWhiteSpace(sFile) OrElse String.IsNullOrWhiteSpace(sExt) Then Return False
|
|
Dim bOk As Boolean = OpenStdFile(sFile)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function OpenStdFile(sFile As String) As Boolean
|
|
Dim nFileType As Integer = EgtGetFileType(sFile)
|
|
Select Case nFileType
|
|
Case FT.NGE
|
|
Return Map.refTopPanelVM.OpenProject(sFile)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Friend Sub UpdateTitle()
|
|
NotifyPropertyChanged(NameOf(sTitle))
|
|
NotifyPropertyChanged(NameOf(sProjectName))
|
|
NotifyPropertyChanged(NameOf(sProjectPath))
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "EVENTS"
|
|
|
|
Private Sub SecondaryWindow_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
|
|
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control AndAlso e.Key = Key.N Then
|
|
Map.refTopPanelVM.NewFile()
|
|
ElseIf (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control AndAlso e.Key = Key.O Then
|
|
Map.refTopPanelVM.OpenFile()
|
|
ElseIf (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control AndAlso e.Key = Key.S Then
|
|
Map.refTopPanelVM.SaveFile()
|
|
ElseIf (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control AndAlso e.Key = Key.Z Then
|
|
SceneCmd.Undo()
|
|
ElseIf (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control AndAlso e.Key = Key.Y Then
|
|
SceneCmd.Redo()
|
|
ElseIf e.Key = Key.Delete Then
|
|
SolidManagerM.Delete(Map.refSceneHostVM.m_nIdPart)
|
|
Map.refSceneHostVM.m_nIdPart = GDB_ID.NULL
|
|
ElseIf e.Key = Key.Escape Then
|
|
If Not IsNothing(Map.refScriptWindowVM) Then Map.refScriptWindowVM.Annulla()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Events
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "AboutBoxCommand"
|
|
|
|
Public ReadOnly Property AboutBoxCommand As ICommand
|
|
Get
|
|
If m_cmdAboutBox Is Nothing Then
|
|
m_cmdAboutBox = New Command(AddressOf AboutBox)
|
|
End If
|
|
Return m_cmdAboutBox
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub AboutBox(ByVal param As Object)
|
|
Dim AboutBoxWindow As New AboutBoxV
|
|
AboutBoxWindow.Owner = Application.Current.MainWindow
|
|
AboutBoxWindow.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' AboutBoxCommand
|
|
|
|
#Region "CloseApplicationCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property CloseApplicationCommand As ICommand
|
|
Get
|
|
If m_cmdCloseApplication Is Nothing Then
|
|
m_cmdCloseApplication = New Command(AddressOf CloseApplication)
|
|
End If
|
|
Return m_cmdCloseApplication
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub CloseApplication(ByVal param As Object)
|
|
Map.refMainWindowVM.CloseApplication()
|
|
End Sub
|
|
|
|
#End Region ' CloseApplicationCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|