Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/ProjectTypeWnd/ProjectTypeWndVM.vb
T
2024-08-01 17:27:33 +02:00

145 lines
5.2 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class ProjectTypeWndVM
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
Dim nMachType As MachineType = DirectCast(SelMachine, MyMachine).nType
IsBoth_Visibility = If(nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed)
End If
End Set
End Property
' Se la Macchina selezionata è di tipo BOTH verrà mostrata anche la selezione del Tipo
Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) AndAlso
DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProd), Visibility.Visible, Visibility.Collapsed)
Public Property IsBoth_Visibility As Visibility
Get
Return m_IsBoth_Visibility
End Get
Set(value As Visibility)
If value <> m_IsBoth_Visibility Then
m_IsBoth_Visibility = value
NotifyPropertyChanged(NameOf(IsBoth_Visibility))
End If
End Set
End Property
Private m_TypeList As New ObservableCollection(Of BWType)({BWType.BEAM, BWType.WALL})
Public ReadOnly Property TypeList As ObservableCollection(Of BWType)
Get
Return m_TypeList
End Get
End Property
' Se la Macchina selezionata è di tipo BOTH verrà selezionato di default il Tipo del progetto corrente
Private m_nSelType As BWType = If(Not IsNothing(Map.refProjManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProj) AndAlso Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) AndAlso
DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, ProjectManagerVM.CurrProj.nType, Nothing)
Public Property nSelType As BWType
Get
Return m_nSelType
End Get
Set(value As BWType)
If value <> m_nSelType Then
m_nSelType = 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 EgtMsg(61884)
End Get
End Property
Public ReadOnly Property ChooseType_Msg As String
Get
Return EgtMsg(61879)
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
Dim nMachType As MachineType = DirectCast(SelMachine, MyMachine).nType
' se la macchina selezionata è sia travi che pareti valuto anche tipo scelto di progetto da aprire/importare
If nMachType = MachineType.BOTH Then
Select Case nSelType
Case BWType.BEAM, BWType.WALL
Map.refMachinePanelVM.SelectedMachine = MachineList(MachineList.IndexOf(SelMachine))
RaiseEvent m_CloseWindow(True)
Case Else
' se non seleziono nessuna tipo progetto lo segnalo con un MessageBox
'MessageBox.Show(EgtMsg(61880), EgtMsg(30009))
If bOnlyProd Then
EgtBEAMWALL.Core.OnlyProdEgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(61880), EgtMsg(30009))
Else
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(61880), EgtMsg(30009))
End If
End Select
Else
' altrimenti setto la macchina e il tipo associato ad essa
Map.refMachinePanelVM.SelectedMachine = MachineList(MachineList.IndexOf(SelMachine))
nSelType = nMachType
RaiseEvent m_CloseWindow(True)
End If
Else
' se non seleziono nessuna macchina lo segnalo con un MessageBox
'MessageBox.Show(EgtMsg(61880), EgtMsg(30009))
If bOnlyProd Then
EgtBEAMWALL.Core.OnlyProdEgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(61880), EgtMsg(30009))
Else
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(61880), EgtMsg(30009))
End If
End If
End Sub
#End Region ' Ok
#End Region ' COMMANDS
End Class