Imports EgtWPFLib5 Imports EgtUILib Imports System.Collections.ObjectModel Imports System.IO Imports System.Text Public Class TopPanelVM Inherits VMBase #Region "FIELDS & PROPERTIES" Friend Enum TopOption As Integer OPTIONS = 0 PARAMETRICO = 1 End Enum Private m_SelTopOption As TopOption = TopOption.OPTIONS Public Property SelTopOption As Integer Get Return m_SelTopOption End Get Set(value As Integer) m_SelTopOption = value End Set End Property Friend Sub SetSelTopOption(TopOtion As TopOption) m_SelTopOption = TopOtion NotifyPropertyChanged(NameOf(SelTopOption)) End Sub Private m_IsOpen As Boolean = False Public Property IsOpen As Boolean Get Return m_IsOpen End Get Set(value As Boolean) m_IsOpen = value End Set End Property Friend Sub SetIsOpen(bIsOpen As Boolean) m_IsOpen = bIsOpen NotifyPropertyChanged(NameOf(IsOpen)) End Sub Private m_IsOpenProspective As Boolean = False Public Property IsOpenProspective As Boolean Get Return m_IsOpenProspective End Get Set(value As Boolean) m_IsOpenProspective = value End Set End Property Friend Sub SetIsOpenProspective(bIsOpenProspective As Boolean) m_IsOpenProspective = bIsOpenProspective NotifyPropertyChanged(NameOf(IsOpenProspective)) End Sub Private m_View_Msg As String = "▼" & EgtMsg(110019) ' Vista Public ReadOnly Property View_Msg As String Get Return m_View_Msg End Get End Property Friend Sub SetView_Msg(sView_Msg As String) m_View_Msg = sView_Msg NotifyPropertyChanged(NameOf(View_Msg)) End Sub Private m_ProspectiveView_Msg As String = "▼" & EgtMsg(110027) ' Vista Prospettica Public ReadOnly Property ProspectiveView_Msg As String Get Return m_ProspectiveView_Msg End Get End Property Friend Sub SetProspectiveView_Msg(sProspectiveView_Msg As String) m_ProspectiveView_Msg = sProspectiveView_Msg NotifyPropertyChanged(NameOf(ProspectiveView_Msg)) End Sub Private m_MruFiles As New MruList Public ReadOnly Property MruFiles As MruList Get Return m_MruFiles End Get End Property Public ReadOnly Property MruFileNames As ObservableCollection(Of String) Get For Each FileName In m_MruFiles.FileNames.ToList() If Not File.Exists(FileName) Then m_MruFiles.Remove(FileName) End If Next Return m_MruFiles.FileNames End Get End Property Private m_MruImportFiles As New MruList Public ReadOnly Property MruImportFiles As MruList Get Return m_MruImportFiles End Get End Property Public ReadOnly Property MruImportFileNames As ObservableCollection(Of String) Get For Each FileName In m_MruImportFiles.FileNames.ToList() If Not File.Exists(FileName) Then m_MruImportFiles.Remove(FileName) End If Next Return m_MruImportFiles.FileNames End Get End Property Private m_FileSourceSVG As String = String.Empty Public Property FileSourceSVG As String Get Return m_FileSourceSVG End Get Set(value As String) m_FileSourceSVG = value NotifyPropertyChanged(NameOf(FileSourceSVG)) End Set End Property Friend Sub SetFileSourceSVG(sfileSourceSVG As String) m_FileSourceSVG = sfileSourceSVG NotifyPropertyChanged(NameOf(FileSourceSVG)) End Sub Public ReadOnly Property TopPanelListGroupBtn As List(Of GroupSceneBtn) Get Return Map.refSceneButtonVM.TopPanelListGroupBtn End Get End Property Public ReadOnly Property ParametricListGroupBtn As List(Of GroupSceneBtn) Get Return Map.refSceneButtonVM.ParametricListGroupBtn End Get End Property Private m_FileScriptSVG As String = String.Empty Public Property FileScriptSVG As String Get Return m_FileScriptSVG End Get Set(value As String) m_FileScriptSVG = value NotifyPropertyChanged(NameOf(FileScriptSVG)) End Set End Property Friend Sub SetFileScriptSVG(sFileScriptSVG As String) m_FileScriptSVG = sFileScriptSVG NotifyPropertyChanged(NameOf(FileScriptSVG)) End Sub #Region "Messages" Public ReadOnly Property NewFile_Msg Get Return EgtMsg(110012) ' Nuovo File End Get End Property Public ReadOnly Property Save_Msg Get Return EgtMsg(110013) ' Salva End Get End Property Public ReadOnly Property SaveAs_Msg Get Return EgtMsg(110014) ' Salva Come End Get End Property Public ReadOnly Property Open_Msg Get Return EgtMsg(110015) ' Apri End Get End Property Public ReadOnly Property Options_Msg Get Return EgtMsg(110016) ' Opzioni End Get End Property #End Region ' Messages ' Definizione Comandi Private m_NewFileCmd As ICommand Private m_SaveFileCmd As ICommand Private m_cmdSaveAs As ICommand Private m_OpenFileCmd As ICommand Private m_cmdOptionsCmd As ICommand Private m_cmdShowPopUpCmd As ICommand Private m_cmdShowPopUpProspectiveCmd As ICommand Private m_cmdOpenMruFile As ICommand Private m_cmdScriptFileCmd As ICommand #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New() Map.SetRefTopPanelVM(Me) ' Impostazioni MruLists m_MruFiles.Init(S_MRUFILES, 8) m_MruImportFiles.Init(S_MRUIMPORTFILES, 8) SetFileSourceSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\test.svg") SetFileScriptSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\ScriptLua.svg") End Sub #End Region ' Constructor #Region "METHODS" Friend Sub NewProject(bDialog As Boolean) ' Gestisco eventuale file corrente modificato If Not Map.refSceneHostVM.ManageModified() Then Return EgtResetModified() ' creo nuovo progetto Map.refSceneHostVM.MainController.NewProject(True) NotifyPropertyChanged(NameOf(MruFileNames)) End Sub Friend Function OpenProject(sFilePath As String) As Boolean Dim bOk As Boolean = Map.refSceneHostVM.OpenProject(sFilePath) SolidManagerM.CreatePartSolid() EgtDraw() Return bOk End Function Public Sub Save() Map.refSceneHostVM.SaveProject() End Sub ''' ''' Funzione che permette l'aggiornamento dei messaggi del Top Panel ''' Friend Sub UpdateMessagesTopPanel() NotifyPropertyChanged(NameOf(NewFile_Msg)) NotifyPropertyChanged(NameOf(Save_Msg)) NotifyPropertyChanged(NameOf(SaveAs_Msg)) NotifyPropertyChanged(NameOf(Open_Msg)) SetView_Msg("▼" & EgtMsg(110019)) ' Vista SetProspectiveView_Msg("▼" & EgtMsg(110027)) ' Vista Prospettica End Sub Private Sub GetFile() If File.Exists(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & "Prova.lua") Then Map.refScriptWindowVM.sNameFile = Path.GetFileNameWithoutExtension(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & "Prova.lua") If File.Exists(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & "Prova.lua") Then Map.refScriptWindowVM.sRichTextParagraph = File.ReadAllText(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & "Prova.lua", Encoding.UTF8) End Sub #End Region ' Methods #Region "COMMANDS" #Region "NewFileCmd" Public ReadOnly Property NewFileCmd As ICommand Get If IsNothing(m_NewFileCmd) Then m_NewFileCmd = New Command(AddressOf NewFile) End If Return m_NewFileCmd End Get End Property Friend Sub NewFile() NewProject(True) SolidManagerM.CreatePartSolid() End Sub #End Region ' NewFileCmd #Region "OpenFileCmd" Public ReadOnly Property OpenFileCmd As ICommand Get If IsNothing(m_OpenFileCmd) Then m_OpenFileCmd = New Command(AddressOf OpenFile) End If Return m_OpenFileCmd End Get End Property Friend Sub OpenFile() OpenProject("") End Sub #End Region ' OpenFileCmd #Region "SaveFileCmd" Public ReadOnly Property SaveFileCmd As ICommand Get If IsNothing(m_SaveFileCmd) Then m_SaveFileCmd = New Command(AddressOf SaveFile) End If Return m_SaveFileCmd End Get End Property Friend Sub SaveFile() Save() End Sub #End Region ' SaveFileCmd #Region "SaveAsCommand" ''' ''' Returns a command that do SaveAs. ''' Public ReadOnly Property SaveAsCommand As ICommand Get If m_cmdSaveAs Is Nothing Then m_cmdSaveAs = New Command(AddressOf SaveAs) End If Return m_cmdSaveAs End Get End Property ''' ''' Execute the SaveAs. This method is invoked by the SaveAsCommand. ''' Public Sub SaveAs(ByVal param As Object) Map.refSceneHostVM.SaveAsProject() End Sub #End Region ' SaveAsCommand #Region "OptionsCmd" Public ReadOnly Property OptionsCommand As ICommand Get If m_cmdOptionsCmd Is Nothing Then m_cmdOptionsCmd = New Command(AddressOf Options) End If Return m_cmdOptionsCmd End Get End Property Public Sub Options(ByVal param As Object) Dim OptionsWindow As New OptionWindowV With { .DataContext = New OptionWindowVM, .Owner = Application.Current.MainWindow } OptionsWindow.ShowDialog() End Sub #End Region ' OptionsCmd #Region "ShowPopUpCommand" Public ReadOnly Property ShowPopUpCommand As ICommand Get If m_cmdShowPopUpCmd Is Nothing Then m_cmdShowPopUpCmd = New Command(AddressOf ShowPopUp) End If Return m_cmdShowPopUpCmd End Get End Property Public Sub ShowPopUp(ByVal param As Object) If m_IsOpen Then SetIsOpen(False) SetView_Msg("▼" & EgtMsg(110019)) ' Vista Else SetIsOpen(True) SetView_Msg("▲" & EgtMsg(110019)) ' Vista SetIsOpenProspective(False) SetProspectiveView_Msg("▼" & EgtMsg(110027)) ' Vista Prospettica End If End Sub #End Region ' ShowPopUpCommand #Region "ShowPopUpProspectiveCommand" Public ReadOnly Property ShowPopUpProspectiveCommand As ICommand Get If m_cmdShowPopUpProspectiveCmd Is Nothing Then m_cmdShowPopUpProspectiveCmd = New Command(AddressOf ShowPopUpProspective) End If Return m_cmdShowPopUpProspectiveCmd End Get End Property Public Sub ShowPopUpProspective(ByVal param As Object) If m_IsOpenProspective Then SetIsOpenProspective(False) SetProspectiveView_Msg("▼" & EgtMsg(110027)) ' Vista Prospettica Else SetIsOpenProspective(True) SetProspectiveView_Msg("▲" & EgtMsg(110027)) ' Vista Prospettica SetIsOpen(False) SetView_Msg("▼" & EgtMsg(110019)) ' Vista End If End Sub #End Region ' ShowPopUpProspectiveCommand #Region "OpenMruFileCommand" ''' ''' Returns a command that do Open. ''' Public ReadOnly Property OpenMruFileCommand As ICommand Get If m_cmdOpenMruFile Is Nothing Then m_cmdOpenMruFile = New Command(AddressOf OpenMruFile) End If Return m_cmdOpenMruFile End Get End Property ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Public Sub OpenMruFile(ByVal param As Object) OpenProject(DirectCast(param, String).Replace("__", "_")) End Sub #End Region ' OpenMruFileCommand #Region "ScriptFileCmd" Public ReadOnly Property ScriptFileCmd As ICommand Get If m_cmdScriptFileCmd Is Nothing Then m_cmdScriptFileCmd = New Command(AddressOf OpenScriptFile) End If Return m_cmdScriptFileCmd End Get End Property Public Sub OpenScriptFile() Dim ScriptWindow As New ScriptWindowV With { .DataContext = New ScriptWindowVM, .Owner = Application.Current.MainWindow } GetFile() ScriptWindow.Show() End Sub #End Region ' ScriptFileCmd #End Region ' Commands End Class