Imports System.Collections.ObjectModel Imports EgtWPFLib5 Imports EgtUILib Imports EgtBEAMWALL.Core Public Class AddRawPartWndVM Inherits VMBase #Region "FIELDS & PROPERTIES" Friend Event m_CloseWindow(bDialogResult As Boolean) ' flag che indica se trave o parete Private m_nMachineType As ConstBeam.MachineType = 1 ' lista delle varibili da mostrare Private m_VariableList As ObservableCollection(Of Variable) Public ReadOnly Property VariableList As ObservableCollection(Of Variable) Get Return m_VariableList End Get End Property 'Private m_dL As Double 'Public ReadOnly Property dL As Double ' Get ' Return m_dL ' End Get 'End Property 'Public Property sL As String ' Get ' Return LenToString(m_dL, 3) ' End Get ' Set(value As String) ' Dim dTempL As Double ' If StringToLen(value, dTempL) AndAlso dTempL > 0 Then ' m_dL = dTempL ' Else ' NotifyPropertyChanged("sL") ' End If ' End Set 'End Property 'Private m_dPOSX As Double 'Public Property dPOSX As Double ' Get ' Return m_dPOSX ' End Get ' Set(value As Double) ' m_dPOSX = value ' End Set 'End Property 'Public Property sPOSX As String ' Get ' Return LenToString(m_dPOSX, 3) ' End Get ' Set(value As String) ' Dim dTempPOSX As Double ' If StringToLen(value, dTempPOSX) AndAlso dTempPOSX > 0 Then ' m_dPOSX = dTempPOSX ' Else ' NotifyPropertyChanged("sPOSX") ' End If ' End Set 'End Property ' Definizione comandi Private m_cmdOk As ICommand #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New(MachineType As Integer, dL As Double, dW As Double, dPosx As Double) m_nMachineType = MachineType Select Case m_nMachineType Case ConstBeam.MachineType.BEAM m_VariableList = New ObservableCollection(Of Variable)({New Variable(Variable.VariableType.LENGTH, "Lunghezza", dL), New Variable(Variable.VariableType.LENGTH, "Ritaglio iniziale", dPosx)}) Case ConstBeam.MachineType.WALL m_VariableList = New ObservableCollection(Of Variable)({New Variable(Variable.VariableType.LENGTH, "Lunghezza", dL), New Variable(Variable.VariableType.LENGTH, "Larghezza", dW)}) End Select End Sub #End Region ' CONSTRUCTOR #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() 'verifico che tutti i campi contengano un valore valido For Each Variable In m_VariableList If (Variable.nType = Variable.VariableType.STRING_ AndAlso IsNothing(Variable.sValue)) OrElse ((Variable.nType = Variable.VariableType.DOUBLE_ OrElse Variable.nType = Variable.VariableType.LENGTH) AndAlso IsNothing(Variable.dValue)) Then MessageBox.Show(If(m_nMachineType = MachineType.BEAM, EgtMsg(61854), EgtMsg(61855)), EgtMsg(30007)) Return End If Next ' se non ci sono problemi esco restituendo vero RaiseEvent m_CloseWindow(True) 'If Not IsNothing(m_dL) AndAlso m_dL > 0 AndAlso ' Not IsNothing(m_dPOSX) AndAlso m_dPOSX >= 0 Then ' RaiseEvent m_CloseWindow(True) 'Else ' MessageBox.Show("Errore! Impossibile creare una barra con questi parametri", "Errore") 'End If End Sub #End Region ' Ok #End Region ' COMMANDS End Class Public Class Variable Inherits VMBase Public Enum VariableType As Integer DOUBLE_ = 1 STRING_ = 2 COMBO = 3 LENGTH = 4 End Enum Private m_nType As VariableType Public ReadOnly Property nType As VariableType Get Return m_nType End Get End Property Private m_sMsg As String Public Property sMsg As String Get Return m_sMsg End Get Set(value As String) m_sMsg = value End Set End Property Private m_dValue As Double = 0 Friend ReadOnly Property dValue As Double Get Return m_dValue End Get End Property Private m_sValue As String = "" Public Property sValue As String Get Select Case m_nType Case VariableType.STRING_ Return m_sValue Case VariableType.LENGTH Return LenToString(m_dValue, 3) Case Else ' VariableType.DOUBLE_ Return DoubleToString(m_dValue, 3) End Select End Get Set(value As String) Select Case m_nType Case VariableType.STRING_ m_sValue = value Case VariableType.LENGTH Dim dTempValue As Double If StringToLen(value, dTempValue) Then m_dValue = dTempValue Else NotifyPropertyChanged("sValue") End If Case Else ' VariableType.DOUBLE_ Dim dTempValue As Double If StringToDouble(value, dTempValue) Then m_dValue = dTempValue Else NotifyPropertyChanged("sValue") End If End Select End Set End Property Sub New(Type As VariableType, Msg As String, Value As String) m_nType = Type m_sMsg = Msg sValue = Value End Sub End Class