From 37abbd79d546a24757f034ed0e819b4caca77a16 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Wed, 4 Oct 2023 10:18:53 +0200 Subject: [PATCH] - Gestito progetto modificato all'interno del programma --- Icarus/EgtMessageBox/EgtMessageBoxVM.vb | 30 +++++++++++++------------ Icarus/MainWindow/MainWindowVM.vb | 9 +------- Icarus/SceneHost/MySceneHostVM.vb | 27 ++++++++++++++++++++++ Icarus/Utility/Dictionary.xaml | 1 - 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Icarus/EgtMessageBox/EgtMessageBoxVM.vb b/Icarus/EgtMessageBox/EgtMessageBoxVM.vb index 8918007..715d410 100644 --- a/Icarus/EgtMessageBox/EgtMessageBoxVM.vb +++ b/Icarus/EgtMessageBox/EgtMessageBoxVM.vb @@ -23,6 +23,7 @@ Public Class EgtMessageBoxVM End Property Private m_Button As MessageBoxButton + Private m_Icon As MessageBoxImage Public ReadOnly Property sIconSource As String Get @@ -165,6 +166,7 @@ Public Class EgtMsgBoxButton Friend Sub SetIsDefault(bValue As Boolean) m_bIsDefault = bValue End Sub + ' Definizione comandi Private m_cmdCommand As ICommand @@ -176,26 +178,26 @@ Public Class EgtMsgBoxButton m_Type = Type Select Case m_Type Case Types.OK - m_sMessage = EgtMsg(35001) - Case Types.CANCEL - m_sMessage = EgtMsg(35002) - Case Types.YES - m_sMessage = EgtMsg(35003) - Case Types.NO - m_sMessage = EgtMsg(35004) - End Select + m_sMessage = EgtMsg(35001) + Case Types.CANCEL + m_sMessage = EgtMsg(35002) + Case Types.YES + m_sMessage = EgtMsg(35003) + Case Types.NO + m_sMessage = EgtMsg(35004) + End Select End Sub - Sub New(Type As Types, bIsDefault As Boolean) - MyClass.New(Type) - m_bIsDefault = bIsDefault - End Sub + Sub New(Type As Types, bIsDefault As Boolean) + MyClass.New(Type) + m_bIsDefault = bIsDefault + End Sub #End Region ' CONTRUCTORS #Region "METHODS" - Friend Shared Sub SetOwner(value As EgtMessageBoxVM) + Friend Shared Sub SetOwner(value As EgtMessageBoxVM) Owner = value End Sub @@ -227,7 +229,7 @@ Public Class EgtMsgBoxButton End Select End Sub -#End Region ' Ok +#End Region ' Command #End Region ' COMMANDS diff --git a/Icarus/MainWindow/MainWindowVM.vb b/Icarus/MainWindow/MainWindowVM.vb index 99dd899..c839239 100644 --- a/Icarus/MainWindow/MainWindowVM.vb +++ b/Icarus/MainWindow/MainWindowVM.vb @@ -166,14 +166,7 @@ Public Class MainWindowVM If Map.refRightPanelVM.SelPanel = RightPanelVM.Panels.SIMULATION AndAlso Not IsNothing(Map.refSimulationPanelVM) Then Map.refSimulationPanelVM.MySimul.ResetSimulation() End If - ' Gestisco eventuale file corrente modificato - Dim bOk As Boolean = True - 'bOk = ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) - ' se salvataggio annullato, rimango - If Not bOk Then Return - Dim bAllowClose As Boolean = Map.refSceneHostVM.MainController.ManageModified() - ' Salvo impostazione macchina corrente - 'Map.refMachinePanelVM.SaveCurrentMachine() + Dim bAllowClose As Boolean = Map.refSceneHostVM.ManageModified() ' Se non confermata chiusura, esco If Not bAllowClose Then Return ' salvo modo di visualizzazione diff --git a/Icarus/SceneHost/MySceneHostVM.vb b/Icarus/SceneHost/MySceneHostVM.vb index 21b9cec..39b0716 100644 --- a/Icarus/SceneHost/MySceneHostVM.vb +++ b/Icarus/SceneHost/MySceneHostVM.vb @@ -726,6 +726,33 @@ Public Class MySceneHostVM Return bOk End Function + Public Function ManageModified() As Boolean + ' se non modificato, procedo normalmente + If Not EgtGetModified() Then + Return True + End If + ' chiedo cosa fare + Dim sMsg As String = "Save changes" + Dim sCurrFile = "" + EgtGetCurrFilePath(sCurrFile) + sCurrFile = Path.GetFileName(sCurrFile) + If Not String.IsNullOrEmpty(sCurrFile) Then + sMsg = String.Format("Save changes to {0}?", sCurrFile) + Else + sMsg = "Save changes?" + End If + Dim nRes = EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Select Case nRes + Case Windows.Forms.DialogResult.Yes + SaveProject() + Return True + Case Windows.Forms.DialogResult.No + Return True + Case Else + Return False + End Select + End Function + #End Region ' ProjectManager #Region "SCENE EVENTS" diff --git a/Icarus/Utility/Dictionary.xaml b/Icarus/Utility/Dictionary.xaml index cb4257e..87a99af 100644 --- a/Icarus/Utility/Dictionary.xaml +++ b/Icarus/Utility/Dictionary.xaml @@ -3,7 +3,6 @@ xmlns:PrintApp="clr-namespace:Icarus" xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5" - xmlns:EgtWPFLib48="clr-namespace:EgtWPFLib48;assembly=EgtWPFLib48" xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5" xmlns:sys="clr-namespace:System;assembly=mscorlib" >