From a1c3a9fb30b5d2c1f216b335efbae061d01cd70f Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Thu, 27 Oct 2022 11:14:51 +0200 Subject: [PATCH] - Gestita apertura diretta del progetto da file senza SplashScreen - Impostata versione da note programma in SplashScreen --- Icarus/Application.xaml.vb | 12 ++++---- Icarus/ProjManager/ProjManagerVM.vb | 8 +++--- Icarus/SecondaryWindow/SecondaryWindowVM.vb | 32 +++++++++++++++++++-- Icarus/SplashScreen/SplashScreen.xaml | 2 +- Icarus/SplashScreen/SplashScreen.xaml.vb | 7 +++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/Icarus/Application.xaml.vb b/Icarus/Application.xaml.vb index e8ea040..0869aee 100644 --- a/Icarus/Application.xaml.vb +++ b/Icarus/Application.xaml.vb @@ -5,11 +5,13 @@ Protected Overrides Sub OnStartup(e As StartupEventArgs) MyBase.OnStartup(e) ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose - ' creo finestra SplashScreen - Dim SplashScreen As New SplashScreen - Me.MainWindow = SplashScreen - Me.MainWindow.Show() - Map.SetRefSplashScreen(SplashScreen) + If e.Args.Count = 0 Then + ' creo finestra SplashScreen + Dim SplashScreen As New SplashScreen + Me.MainWindow = SplashScreen + Me.MainWindow.Show() + Map.SetRefSplashScreen(SplashScreen) + End If ' Creo la View principale Me.MainWindow = New MainWindowV diff --git a/Icarus/ProjManager/ProjManagerVM.vb b/Icarus/ProjManager/ProjManagerVM.vb index d285a06..763f004 100644 --- a/Icarus/ProjManager/ProjManagerVM.vb +++ b/Icarus/ProjManager/ProjManagerVM.vb @@ -202,7 +202,7 @@ Public Class ProjManagerVM OpenProject(Nothing) End Sub - Friend Sub OpenProject(sFilePath As String) + Friend Function OpenProject(sFilePath As String) As Boolean If String.IsNullOrEmpty(sFilePath) Then ' Recupero cartella dell'ultimo progetto aperto Dim sDir As String = Map.refSceneHostVM.MainController.GetCurrFile() @@ -212,11 +212,11 @@ Public Class ProjManagerVM If Not String.IsNullOrWhiteSpace(sDir) Then sDir = Path.GetDirectoryName(sDir) End If - Map.refSceneHostVM.MainController.OpenProject(sDir) + Return Map.refSceneHostVM.MainController.OpenProject(sDir) Else - Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) + Return Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) End If - End Sub + End Function #End Region ' OpenCommand diff --git a/Icarus/SecondaryWindow/SecondaryWindowVM.vb b/Icarus/SecondaryWindow/SecondaryWindowVM.vb index 6c959b3..514b4dd 100644 --- a/Icarus/SecondaryWindow/SecondaryWindowVM.vb +++ b/Icarus/SecondaryWindow/SecondaryWindowVM.vb @@ -54,7 +54,9 @@ Public Class SecondaryWindowVM ' imposto e avvio contatore SplashScreen m_SplashScreen_Timer.Interval = New TimeSpan(0, 0, 0, 0, 500) AddHandler m_SplashScreen_Timer.Tick, AddressOf SplashScreenTimer_Tick - m_SplashScreen_Timer.Start() + If Not IsNothing(Map.refSplashScreen) Then + m_SplashScreen_Timer.Start() + End If End Sub #End Region ' CONSTRUCTOR @@ -67,8 +69,11 @@ Public Class SecondaryWindowVM Map.refMyStatusBarVM.SetSnapPointType(Map.refSceneHostVM.SnapType) Map.refMyStatusBarVM.SetMeasureUnit(EgtUiUnitsAreMM) EgtSetView(VT.ISO_SW, False) - ' creo nuovo progetto di partenza - Map.refProjManagerVM.NewProject(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 @@ -86,6 +91,27 @@ Public Class SecondaryWindowVM 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 + Return OpenStdFile(sFile) + 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) + 'Case FT.DXF, FT.STL, FT._3MF, FT.OBJ, FT.CNC, FT.CSF, FT.BTL, FT.BTLX, FT.IMG, FT.PNT, FT.IGES, FT.STEP_, FT.ACIS, FT.PARASOLID, FT.JT, FT.VRML, FT.C3D + ' Return m_Controller.ImportProject(sFile, False) + End Select + Return False + End Function + #Region "COMMANDS" #Region "AboutBoxCommand" diff --git a/Icarus/SplashScreen/SplashScreen.xaml b/Icarus/SplashScreen/SplashScreen.xaml index da01676..0218b4f 100644 --- a/Icarus/SplashScreen/SplashScreen.xaml +++ b/Icarus/SplashScreen/SplashScreen.xaml @@ -18,7 +18,7 @@ FontFamily="/Resources/Fonts/#Roboto" FontWeight="Light" Margin="463,125,0,0"/> - diff --git a/Icarus/SplashScreen/SplashScreen.xaml.vb b/Icarus/SplashScreen/SplashScreen.xaml.vb index 8703223..be37936 100644 --- a/Icarus/SplashScreen/SplashScreen.xaml.vb +++ b/Icarus/SplashScreen/SplashScreen.xaml.vb @@ -1,3 +1,10 @@ Public Class SplashScreen + Private Sub SplashScreen_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized + VersionTxBl.Text = "Version " & My.Application.Info.Version.Major.ToString() & + "." & My.Application.Info.Version.Minor.ToString() & + (ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() & + My.Application.Info.Version.Revision.ToString() + End Sub + End Class