Files
icarus/Icarus/ChooseMachineWnd/ChooseMachineWndVM.vb
T
2023-05-26 10:21:46 +02:00

78 lines
2.1 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class ChooseMachineWndVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Friend Event m_CloseWindow(bDialogResult As Boolean)
' recupero la lista delle Macchine da MachinePanel
Private m_MachineList As ObservableCollection(Of Machine) = Map.refMachinePanelVM.MachineList
Public ReadOnly Property MachineList As ObservableCollection(Of Machine)
Get
Return m_MachineList
End Get
End Property
' La Macchina selezionata di default sarà quella correntemente selezionata in MachinePanel
Private m_SelMachine As Machine = MachineList.FirstOrDefault(Function(x) x.Name = Map.refMachinePanelVM.SelectedMachine.Name)
Public Property SelMachine As Machine
Get
Return m_SelMachine
End Get
Set(value As Machine)
If value IsNot m_SelMachine Then
m_SelMachine = value
End If
End Set
End Property
' Definizione comandi
Private m_cmdOk As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "MESSAGES"
Public ReadOnly Property ChooseMachine_Msg As String
Get
Return "Select the new project machine from the list"
End Get
End Property
#End Region ' MESSAGES
#Region "COMMANDS"
#Region "Ok"
Public ReadOnly Property Ok_Command As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
If Not IsNothing(SelMachine) Then
' setto la macchina
Map.refMachinePanelVM.SelectedMachine = MachineList(MachineList.IndexOf(SelMachine))
RaiseEvent m_CloseWindow(True)
Else
' se non seleziono nessuna macchina lo segnalo con un MessageBox
' MessageBox.Show("No machine selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
EgtMessageBoxV.Show(Application.Current.MainWindow, "No machine selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
End If
End Sub
#End Region ' Ok
#End Region ' COMMANDS
End Class