Files
egtstone3d/TopPanel/TopPanelVM.vb
T
2025-02-03 09:03:14 +01:00

424 lines
11 KiB
VB.net

Imports EgtWPFLib5
Imports EgtUILib
Imports System.Collections.ObjectModel
Imports System.IO
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
#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
#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")
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
Return Map.refSceneHostVM.OpenProject(sFilePath)
End Function
Public Sub Save()
Map.refSceneHostVM.SaveProject()
End Sub
''' <summary>
''' Funzione che permette l'aggiornamento dei messaggi del Top Panel
''' </summary>
Friend Sub UpdateMessagesTopPanel()
NotifyPropertyChanged(NameOf(NewFile_Msg))
NotifyPropertyChanged(NameOf(Save_Msg))
NotifyPropertyChanged(NameOf(SaveAs_Msg))
NotifyPropertyChanged(NameOf(Open_Msg))
SetView_Msg("" & EgtMsg(110019))
SetProspectiveView_Msg("" & EgtMsg(110027))
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)
Map.refSecondaryWindowVM.UpdateTitle()
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("")
Map.refSecondaryWindowVM.UpdateTitle()
SolidManagerM.CreatePartSolid()
EgtDraw()
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"
''' <summary>
''' Returns a command that do SaveAs.
''' </summary>
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
''' <summary>
''' Execute the SaveAs. This method is invoked by the SaveAsCommand.
''' </summary>
Public Sub SaveAs(ByVal param As Object)
Map.refSceneHostVM.SaveAsProject()
End Sub
#End Region ' SaveAsCommand
#Region "OptionsCmd"
''' <summary>
''' Returns a command that do Export.
''' </summary>
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
''' <summary>
''' Execute the Export. This method is invoked by the ExportCommand.
''' </summary>
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"
''' <summary>
''' Returns a command that do Export.
''' </summary>
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
''' <summary>
''' Execute the Export. This method is invoked by the ExportCommand.
''' </summary>
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"
''' <summary>
''' Returns a command that do Export.
''' </summary>
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
''' <summary>
''' Execute the Export. This method is invoked by the ExportCommand.
''' </summary>
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"
''' <summary>
''' Returns a command that do Open.
''' </summary>
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
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Public Sub OpenMruFile(ByVal param As Object)
OpenProject(DirectCast(param, String).Replace("__", "_"))
Map.refSecondaryWindowVM.UpdateTitle()
End Sub
#End Region ' OpenMruFileCommand
#End Region ' Commands
End Class