Files
egtstone3d/SecondaryWindow/SecondaryWindowVM.vb
T
2025-01-31 16:49:02 +01:00

168 lines
4.8 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
If Not IsNothing(Map.refSplashScreen) Then
m_SplashScreen_Timer.Start()
End If
UpdateTitle()
End Sub
#End Region ' Constructor
#Region "METHODS"
Friend Sub ContentRendered()
EgtSetView(VT.ISO_SE, False)
' provo a caricare progetto da linea di comando
' commentato per debug
'If Not ProcessCommandLine() Then
' ' altrimenti creo nuovo progetto di partenza
' Map.refTopPanelVM.NewProject(False)
'End If
' commentato per debug
' 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 "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