Imports EgtUILib Imports EgtWPFLib5 Imports EgtPHOTOLib Imports System.IO Public Class MainWindowVM Inherits VMBase ' Riferimento al Model della MainWindow Private m_MainWindowM As MainWindowM Friend ReadOnly Property MainWindowM As MainWindowM Get Return m_MainWindowM End Get End Property ' Variabile che indica che il programma è stato avviato correttamente (sia la mappa che l'ambiente Egt) Private m_bInitStatus As Boolean Friend ReadOnly Property bInitStatus As Boolean Get Return m_bInitStatus End Get End Property ' Titolo Private m_Title As String Public Property Title As String Get Return m_Title End Get Set(value As String) m_Title = value NotifyPropertyChanged("Title") End Set End Property ' Oggetto di gestione della macchina fotografica Friend m_Camera As New Camera ' definizione comandi Private m_cmdAboutBox As ICommand Private m_cmdCloseApplication As ICommand #Region "CONSTRUCTOR" Sub New() ' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM Map.BeginInit(Me) ' Creo Model della MainWindow m_MainWindowM = New MainWindowM End Sub #End Region ' CONSTRUCTOR #Region "METHODS" Friend Sub SetTitle(sTitle As String) m_Title = sTitle NotifyPropertyChanged("Title") End Sub Friend Sub ContentRendered() ' Verifico che l'inizializzazione di tutte le parti del programma sia andata a buon fine altrimenti chiudo If Not Map.EndInit() Then End ' mi preparo a gestire l'evento definito dal cambio pagina AddHandler PhotoMap.refProjectVM.SlabIsSelected, AddressOf Map.refTopCommandBarVM.SetSearch_IsEnable ' Aggiorno visualizzazione unità di misura Map.refStatusBarVM.SetMeasureUnit(If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH)) ' Apro in modalità lista PhotoMap.refProjectVM.SelProjectMode = ProjectSlabVM.ProjectModeOpt.LIST ' Se macchina fotografica abilitata, ne inizializzo il gestore If m_MainWindowM.GetKeyOption(KEY_OPT.MAN_PHOTO) Then m_Camera.Init() End If ' Eseguo backup del Db ManageDb.ManageBackUp() 'ManageDb.CreateFileToClear() End Sub #End Region ' METHODS #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) ' chiedo verifico se devo salvare le modifiche If Not IsNothing(EgtPHOTOLib.PhotoMap.refProjectVM) AndAlso Not IsNothing(EgtPHOTOLib.PhotoMap.refProjectVM.SelSlab) AndAlso EgtPHOTOLib.PhotoMap.refProjectVM.SelSlab.IsModified() Then ' 91125=Salvare le modifiche correnti? ' 91126=Avviso If MessageBox.Show(EgtMsg(91125), EgtMsg(91122), MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.OK Then EgtPHOTOLib.PhotoMap.refOptionPanelVM.Ok(Nothing) End If End If ' deseleziono la lastra corrente If Not IsNothing(EgtPHOTOLib.PhotoMap.refProjectVM) AndAlso Not IsNothing(EgtPHOTOLib.PhotoMap.refProjectVM.SelSlab) Then EgtPHOTOLib.PhotoMap.refOptionPanelVM.Cancel(Nothing) End If ' Imposto contesto principale EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx()) ' Chiudo il gestore della macchina fotografica m_Camera.Close() ' Termino il Model m_MainWindowM.Close() ' Termino il programma Application.Current.Shutdown() End Sub #End Region ' CloseApplicationCommand #End Region ' COMMANDS End Class