565 lines
16 KiB
VB.net
565 lines
16 KiB
VB.net
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
|
|
OFFICE = 2
|
|
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
|
|
|
|
Public ReadOnly Property InfoListBtn As List(Of GroupSceneBtn)
|
|
Get
|
|
Return Map.refSceneButtonVM.InfoListBtn
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TopPanelOfficeListBtn As List(Of GroupSceneBtn)
|
|
Get
|
|
Return Map.refSceneButtonVM.TopPanelOfficeListBtn
|
|
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
|
|
|
|
Private m_FileLuaNames As New ObservableCollection(Of String)
|
|
Public Property FileLuaNames As ObservableCollection(Of String)
|
|
Get
|
|
Return m_FileLuaNames
|
|
End Get
|
|
Set(value As ObservableCollection(Of String))
|
|
m_FileLuaNames = value
|
|
NotifyPropertyChanged(NameOf(FileLuaNames))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsEnableScriptBtn As Boolean = True
|
|
Public ReadOnly Property IsEnableScriptBtn As Boolean
|
|
Get
|
|
Return m_bIsEnableScriptBtn
|
|
End Get
|
|
End Property
|
|
Public Sub SetIsEnableScriptBtn(value As Boolean)
|
|
m_bIsEnableScriptBtn = value
|
|
NotifyPropertyChanged(NameOf(IsEnableScriptBtn))
|
|
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
|
|
|
|
Public ReadOnly Property Script_Msg
|
|
Get
|
|
Return EgtMsg(110076) ' Script File
|
|
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
|
|
Private m_cmdOpenFileLua 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")
|
|
GetFileLuaList()
|
|
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
|
|
|
|
''' <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)) ' Vista
|
|
SetProspectiveView_Msg("▼" & EgtMsg(110027)) ' Vista Prospettica
|
|
End Sub
|
|
|
|
Private Sub Get_ReadFile(fileName As String)
|
|
Map.refScriptWindowVM.sNameFile = Path.GetFileNameWithoutExtension(fileName)
|
|
Map.refScriptWindowVM.sScriptText = File.ReadAllText(fileName, Encoding.UTF8)
|
|
End Sub
|
|
|
|
Private Sub GetFile()
|
|
' Verifica se la cartella esiste
|
|
If Directory.Exists(Map.refMainWindowVM.MainWindowM.sTempDir) Then
|
|
' Recupero tutti i nomi dei file nella cartella
|
|
Dim fileNames() As String = Directory.GetFiles(Map.refMainWindowVM.MainWindowM.sTempDir, "*.lua")
|
|
If fileNames.Length > 0 Then
|
|
' Recupero il file con l'ultima modifica
|
|
Dim lastModifyFile As New FileInfo(fileNames(0))
|
|
For Each fileName As String In fileNames
|
|
Dim fileInfo As New FileInfo(fileName)
|
|
If fileInfo.LastWriteTime >= lastModifyFile.LastWriteTime Then
|
|
lastModifyFile = fileInfo
|
|
Get_ReadFile(fileName)
|
|
End If
|
|
Next
|
|
ElseIf fileNames.Length = 0 Then
|
|
If EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(110078), EgtMsg(110077), MessageBoxButton.OK, MessageBoxImage.Information) = MessageBoxResult.OK Then
|
|
Dim OpenDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(110015), ' Importa
|
|
.Filter = "lua files (*.lua)|*.lua",
|
|
.FilterIndex = 1,
|
|
.Mode = 1
|
|
}
|
|
If Not OpenDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return
|
|
If String.IsNullOrEmpty(OpenDialog.FileName) Then Return
|
|
Get_ReadFile(OpenDialog.FileName)
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GetFileLuaList()
|
|
If Directory.Exists(Map.refMainWindowVM.MainWindowM.sTempDir) Then
|
|
' Recupera tutti i nomi dei file nella cartella
|
|
Dim fileNames() As String = Directory.GetFiles(Map.refMainWindowVM.MainWindowM.sTempDir, "*.lua")
|
|
For Each fileName As String In fileNames
|
|
m_FileLuaNames.Add(fileName)
|
|
Next
|
|
End If
|
|
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"
|
|
|
|
''' <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"
|
|
|
|
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"
|
|
|
|
''' <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("__", "_"))
|
|
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()
|
|
SetIsEnableScriptBtn(False)
|
|
End Sub
|
|
|
|
#End Region ' ScriptFileCmd
|
|
|
|
#Region "OpenFileLuaCommand"
|
|
|
|
Public ReadOnly Property OpenFileLuaCommand As ICommand
|
|
Get
|
|
If m_cmdOpenFileLua Is Nothing Then
|
|
m_cmdOpenFileLua = New Command(AddressOf OpenFileLua)
|
|
End If
|
|
Return m_cmdOpenFileLua
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub OpenFileLua(ByVal param As Object)
|
|
Dim fileName = DirectCast(param, String)
|
|
Dim ScriptWindow As New ScriptWindowV With {
|
|
.DataContext = New ScriptWindowVM,
|
|
.Owner = Application.Current.MainWindow
|
|
}
|
|
Get_ReadFile(fileName)
|
|
ScriptWindow.Show()
|
|
SetIsEnableScriptBtn(False)
|
|
End Sub
|
|
|
|
#End Region ' OpenFileLuaCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|