Files
egtstone3d/TopPanel/TopPanelVM.vb
T
2025-01-15 09:08:25 +01:00

364 lines
9.0 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_View_Msg As String = "" & EgtMsg(110019)
Public Property View_Msg As String
Get
Return m_View_Msg
End Get
Set(value As String)
m_View_Msg = value
End Set
End Property
Friend Sub SetView_Msg(sView_Msg As String)
m_View_Msg = sView_Msg
NotifyPropertyChanged(NameOf(View_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
#Region "Messages"
Public ReadOnly Property NewFile_Msg
Get
Return EgtMsg(110012)
End Get
End Property
Public ReadOnly Property Save_Msg
Get
Return EgtMsg(110013)
End Get
End Property
Public ReadOnly Property SaveAs_Msg
Get
Return EgtMsg(110014)
End Get
End Property
Public ReadOnly Property Open_Msg
Get
Return EgtMsg(110015)
End Get
End Property
Public ReadOnly Property Options_Msg
Get
Return EgtMsg(110016)
End Get
End Property
'Public ReadOnly Property View_Msg
' Get
' Return EgtMsg(110019)
' 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_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)
End Sub
#End Region ' Constructor
#Region "METHODS"
Friend Sub NewProject(bDialog As Boolean)
' Gestisco eventuale file corrente modificato
If Not Map.refSceneHostVM.MainController.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
#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
Private Sub NewFile()
NewProject(True)
Dim sDir As String = "C:\EgtData\EgtStone3D\Temp"
Dim od As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
.Title = EgtMsg(110015),
.Filter = "New geometry EgalTech(*.nge)|*.nge" &
"|vme files (*.vme)|*.vme",
.FileName = "New.nge",
.FilterIndex = 1,
.InitialDirectory = sDir
}
od.ShowDialog()
Dim sFilePath As String = od.FileName
EgtOpenFile(sFilePath)
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
Private Sub OpenFile()
Dim OpenFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
.Title = EgtMsg(110015),
.Filter = "nge files (*.nge)|*.nge" &
"|vme files (*.vme)|*.vme",
.FileName = "New.vme",
.FilterIndex = 2,
.InitialDirectory = "C:\EgtData\EgtStone3D\Temp",
.Mode = 1
}
If Not OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return
If String.IsNullOrEmpty(OpenFileDialog.FileName) Then Return
Dim sFilePath As String = OpenFileDialog.FileName
EgtOpenFile(sFilePath)
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
Private 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))
Else
SetIsOpen(True)
SetView_Msg("" & EgtMsg(110019))
End If
End Sub
#End Region ' ShowPopUpCommand
#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
#End Region ' Commands
End Class