7abeca0815
- aggiunta gestione direzione di vista standard da ini macchina ([General] StandardView=SE (ammessi SW, SE, NE, NW con SW default).
197 lines
6.2 KiB
VB.net
197 lines
6.2 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
Imports System.IO
|
|
Imports System.Windows.Threading
|
|
|
|
Public Class SecondaryWindowVM
|
|
Inherits VMBase
|
|
|
|
Private m_SplashScreen_Timer As New DispatcherTimer
|
|
Private m_WaitAfterRender As Integer = 0
|
|
|
|
Private m_Window_Opacity As Double = 0.2
|
|
Public ReadOnly Property Window_Opacity As Double
|
|
Get
|
|
Return m_Window_Opacity
|
|
End Get
|
|
End Property
|
|
|
|
' Titolo
|
|
Public ReadOnly Property sTitle As String
|
|
Get
|
|
Return "Icarus"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sProjectName As String
|
|
Get
|
|
Dim sFilePath As String = ""
|
|
EgtGetCurrFilePath(sFilePath)
|
|
If String.IsNullOrEmpty(sFilePath) Then
|
|
sFilePath = EgtMsg(MSG_TOPCOMMANDBAR + 1) & 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
|
|
sFilePath = EgtMsg(MSG_TOPCOMMANDBAR + 1) & Map.refMainWindowVM.MainWindowM.nInstance.ToString()
|
|
End If
|
|
Return sFilePath
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Visibility As Boolean
|
|
Public Property Visibility As Visibility
|
|
Get
|
|
Return If(m_Visibility, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_Visibility = (value = Visibility.Visible)
|
|
End Set
|
|
End Property
|
|
|
|
Friend Sub SetVisibility(bValue As Boolean)
|
|
If bValue <> m_Visibility Then
|
|
m_Visibility = bValue
|
|
NotifyPropertyChanged(NameOf(Visibility))
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub SetTitle()
|
|
NotifyPropertyChanged(NameOf(sTitle))
|
|
NotifyPropertyChanged(NameOf(sProjectName))
|
|
NotifyPropertyChanged(NameOf(sProjectPath))
|
|
End Sub
|
|
|
|
|
|
' definizione comandi
|
|
Private m_cmdAboutBox As ICommand
|
|
Private m_cmdCloseApplication As ICommand
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
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
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
Friend Sub ContentRendered()
|
|
Map.refTopPanelVM.SelPage = Pages.NULL
|
|
' Seleziono la macchina impostata nel file ini
|
|
Map.refMachinePanelVM.LoadCurrentMachine()
|
|
' imposto SnapPoint
|
|
Map.refMyStatusBarVM.SetSnapPointType(Map.refSceneHostVM.SnapType)
|
|
Map.refMyStatusBarVM.SetMeasureUnit(EgtUiUnitsAreMM)
|
|
EgtSetView(CurrentMachine.nStandardView, False)
|
|
' provo a caricare progetto da linea di comando
|
|
If Not ProcessCommandLine() Then
|
|
' altrimenti creo nuovo progetto di partenza
|
|
Map.refProjManagerVM.NewProject(False)
|
|
End If
|
|
' leggo stati visualizzazione layer
|
|
Map.refViewLayerManagerVM.UpdateIsVisibleFromIni()
|
|
' resetto segnalazione modifiche
|
|
EgtResetModified()
|
|
' segno su contatore splashscreen render finito
|
|
m_WaitAfterRender = 1
|
|
End Sub
|
|
|
|
Private Sub SplashScreenTimer_Tick()
|
|
If m_WaitAfterRender > 1 Then
|
|
m_Window_Opacity = 1
|
|
NotifyPropertyChanged(NameOf(Window_Opacity))
|
|
' 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)
|
|
m_Window_Opacity = 1
|
|
NotifyPropertyChanged(NameOf(Window_Opacity))
|
|
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.refProjManagerVM.OpenProject(sFile)
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "AboutBoxCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
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
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
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)
|
|
If Map.refSliceManagerVM.bCalculating Then
|
|
MessageBox.Show("Impossible closing software! Wait end of calculation!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Map.refMainWindowVM.CloseApplication()
|
|
End Sub
|
|
|
|
#End Region ' CloseApplicationCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|