Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5

Public MustInherit Class WallMachGroupVM
   Inherits MyMachGroupVM

   Public ReadOnly Property m_WallMachGroupM As WallMachGroupM
      Get
         Return m_MachGroupM
      End Get
   End Property

#Region "CONSTRUCTORS"

   Sub New(WallMachGroupM As WallMachGroupM)
      MyBase.New(WallMachGroupM)
      AddHandler m_WallMachGroupM.PartAdded, AddressOf OnWallAdded
      AddHandler m_WallMachGroupM.PartRemoved, AddressOf OnWallRemoved
      CreateWallVMList()
      ' Aggiorno stato da stati feature
      CalcGlobalUpdate()
      NotifyPropertyChanged(NameOf(CALC_FALL_Visibility))
   End Sub

#End Region    ' CONSTRUCTORS

#Region "METHODS"

   Protected MustOverride Sub CreateWallVMList()

#End Region    ' METHODS

   Public Overrides Sub RefreshPartList()
   End Sub

   Public Overrides Sub RefreshGroupData()
   End Sub

#Region "COMMANDS"

#End Region    ' COMMANDS

#Region "EVENTS"

   Protected MustOverride Sub OnWallAdded(sender As Object, e As PartAddedEventArgs)

   Private Sub OnWallRemoved(sender As Object, e As PartAddedEventArgs)
      Dim WallVM As WallVM = PartVMList.FirstOrDefault(Function(x) x.PartM Is e.m_NewPart)
      If Not IsNothing(WallVM) Then PartVMList.Remove(WallVM)
   End Sub

   Protected Sub OnWallVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
      If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
         For Each WallVM As WallVM In e.NewItems
            AddHandler WallVM.PropertyChanged, AddressOf OnWallVMPropertyChanged
         Next
      End If
      If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
         For Each WallVM As WallVM In e.OldItems
            RemoveHandler WallVM.PropertyChanged, AddressOf OnWallVMPropertyChanged
         Next
      End If
   End Sub

   Protected Sub OnWallVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
      'Select Case e.PropertyName
      '   Case NameOf(sender.nSelGRP), NameOf(sender.nSelSIDE)
      'End Select
   End Sub

#End Region

End Class
