Imports EgtUILib Public Class DispositionOpListBoxItem Inherits OperationListBoxItem Public Property StatusAll As Boolean? Get ' Recupero gli indici delle operazioni della Disposizione corrente Dim OpIndexes As List(Of Integer) = GetOpIndexes() ' Ritorno il valore specificato in base agli stati delle operazioni di cui abbiamo raccolto gli indici If OpIndexes.Count = 0 Then Return False Dim bTemp As Boolean = DirectCast(Map.refOperationsListExpanderVM.OperationList.Item(OpIndexes(0)), MachiningOpListBoxItem).Status For OpInDispIndex = 1 To OpIndexes.Count - 1 If DirectCast(Map.refOperationsListExpanderVM.OperationList.Item(OpIndexes(OpInDispIndex)), MachiningOpListBoxItem).Status <> bTemp Then Return Nothing Next Return bTemp End Get Set(value As Boolean?) ' Recupero gli indici delle operazioni della Disposizione corrente Dim OpIndexes As List(Of Integer) = GetOpIndexes() If OpIndexes.Count = 0 Then NotifyPropertyChanged(NameOf(StatusAll)) Return End If For Each OpInDispIndex In OpIndexes DirectCast(Map.refOperationsListExpanderVM.OperationList.Item(OpInDispIndex), MachiningOpListBoxItem).Status = If(IsNothing(value), False, CBool(value)) Next End Set End Property Private m_Image As String = String.Empty Public Property Image As String Get Return m_Image End Get Set(value As String) m_Image = value End Set End Property Sub New(nId As Integer, sName As String, nType As Integer) m_Id = nId Me.Name = sName m_Type = nType End Sub Public Function GetOpIndexes() As List(Of Integer) ' Ciclo la lista alla ricerca dell'indice della Disposizione corrente Dim DispIndex As Integer = 0 For index As Integer = 0 To Map.refOperationsListExpanderVM.OperationList.Count - 1 If Map.refOperationsListExpanderVM.OperationList.Item(index).Id = Me.Id Then DispIndex = index Exit For End If Next ' Inserisco in una lista gli indici delle operazioni della Disposizione (a partire dunque dall'indice trovato) Dim OpIndexes As New List(Of Integer)() Dim OpIndex As Integer = DispIndex + 1 While OpIndex < Map.refOperationsListExpanderVM.OperationList.Count AndAlso EgtGetOperationType(Map.refOperationsListExpanderVM.OperationList.Item(OpIndex).Id) <> MCH_OY.DISP OpIndexes.Add(OpIndex) OpIndex += 1 End While Return OpIndexes End Function End Class