Public Class ChangeTableVM Inherits VMBase Private m_refChanTableV As ChangeTableV Public Enum EnumDialogResult OK CANCEL End Enum Private m_MyDialogResult As EnumDialogResult Public ReadOnly Property MyDialogResult As EnumDialogResult Get Return m_MyDialogResult End Get End Property Private m_sTitle As String = "Seleziona tavola di lavoro" Public ReadOnly Property sTitle As String Get Return m_sTitle End Get End Property Private m_nSelectedTable As Integer = 0 Public ReadOnly Property nSelectedTable As Integer Get Return m_nSelectedTable End Get End Property Private m_cmdOk As ICommand Private m_cmdCancel As ICommand Sub New(refV As ChangeTableV) m_refChanTableV = refV ' Procedo alla creazione della lista delle tavole disponibili Initialized() End Sub Private m_CurrTableList As New List(Of TableToChange) Public ReadOnly Property CurrTableList As List(Of TableToChange) Get Return m_CurrTableList End Get End Property Private Sub Initialized() ' recuepero l'inidce della tavola corrente Dim nIndeXCurrTab As Integer = GetCurrentTable() ' creo la lista delle tavole disponibili (attivo il bottone della tavola attualmente in uso) For nInd As Integer = 0 To GetTableCount() - 1 m_CurrTableList.Add(New TableToChange("Tab", (nInd + 1), ((nInd + 1) = nIndeXCurrTab))) Next End Sub Public ReadOnly Property OkCommand() 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 ReadOnly Property CancelCommand() As ICommand Get If m_cmdCancel Is Nothing Then m_cmdCancel = New Command(AddressOf Cancel) End If Return m_cmdCancel End Get End Property Private Sub Ok() ' recupero l'indice della tavola impostata For Each ItemTab As TableToChange In CurrTableList If ItemTab.IsActive Then m_nSelectedTable = ItemTab.nIndex Exit For End If Next m_MyDialogResult = EnumDialogResult.OK ' procedo alla chiusura della finetra m_refChanTableV.Close() End Sub Private Sub Cancel() m_MyDialogResult = EnumDialogResult.CANCEL ' procedo alla chiusura della finetra m_refChanTableV.Close() End Sub End Class Public Class TableToChange Inherits VMBase Private Property m_sName As String = "Tab" Public ReadOnly Property sName As String Get Return m_sName End Get End Property Private m_sImgTab As String = "\Resources\NewIcons\table.png" Public ReadOnly Property ImgTab As String Get Return If(m_bIsActive, "\Resources\NewIcons\table.png", "\Resources\NewIcons\tableS.png") End Get End Property Private Property m_nIndex As Integer = 3 Public ReadOnly Property nIndex As Integer Get Return m_nIndex End Get End Property Private m_bIsActive As Boolean = False Public Property IsActive As Boolean Get Return m_bIsActive End Get Set(value As Boolean) m_bIsActive = value If m_bIsActive Then m_sImgTab = "\Resources\NewIcons\table.png" Else m_sImgTab = "\Resources\NewIcons\tableS.png" End If NotifyPropertyChanged(NameOf(IsActive)) NotifyPropertyChanged(NameOf(ImgTab)) End Set End Property Public Sub New(Name As String, Ind As Integer, IsCurrent As Boolean) m_sName = Name & " " & Ind.ToString m_nIndex = Ind m_bIsActive = IsCurrent NotifyPropertyChanged("IsActive") End Sub End Class