Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtUILib

Public Class RawPartListVM

#Region "FIELDS & PROPERTIES"

   Private m_bRawPartListSorted As Boolean
   Public ReadOnly Property bRawPartListSorted As Boolean
      Get
         Return m_bRawPartListSorted
      End Get
   End Property
   Friend Sub SetRawPartListSorted(value As Boolean)
      m_bRawPartListSorted = value
      Map.refLeftPanelVM.NotifyPropertyChanged(NameOf(Map.refLeftPanelVM.MoveRawPart_IsEnabled))
   End Sub

   Private m_colRawPart_StartCut As EgtDataGridColumn
   Public ReadOnly Property colRawPart_StartCut As EgtDataGridColumn
      Get
         Return m_colRawPart_StartCut
      End Get
   End Property

   Private m_colRawPart_PosZ As EgtDataGridColumn
   Public ReadOnly Property colRawPart_PosZ As EgtDataGridColumn
      Get
         Return m_colRawPart_PosZ
      End Get
   End Property

   Private m_RawPartColumns As New ObservableCollection(Of EgtDataGridColumn)
   Public Property RawPartColumns As ObservableCollection(Of EgtDataGridColumn)
      Get
         Return m_RawPartColumns
      End Get
      Set(value As ObservableCollection(Of EgtDataGridColumn))
         m_RawPartColumns = value
      End Set
   End Property

#Region "Messages"

   Public ReadOnly Property ID_Msg As String
      Get
         Return EgtMsg(61815)
      End Get
   End Property

   Public ReadOnly Property StartOffset_Msg As String
      Get
         Return EgtMsg(61816)
      End Get
   End Property

   Public ReadOnly Property W_Msg As String
      Get
         Return EgtMsg(61605)
      End Get
   End Property

   Public ReadOnly Property H_Msg As String
      Get
         Return EgtMsg(61606)
      End Get
   End Property

   Public ReadOnly Property L_Msg As String
      Get
         Return EgtMsg(61604)
      End Get
   End Property

   Public ReadOnly Property PosZ_Msg As String
      Get
         Return EgtMsg(61728)
      End Get
   End Property

   Public ReadOnly Property Material_Msg As String
      Get
         Return EgtMsg(61607)
      End Get
   End Property

   Public ReadOnly Property Used_Msg As String
      Get
         Return EgtMsg(61817)
      End Get
   End Property

   Public ReadOnly Property Waste_Msg As String
      Get
         Return EgtMsg(61818)
      End Get
   End Property

#End Region    ' Messages

#End Region    ' FIELDS & PROPERTIES

#Region "CONSTRUCTOR"

   Sub New()
      ' Aggiungo riferimento a Map
      Map.SetRefRawPartListVM(Me)
      ' carico le colonne della datagrid
      GetPrivateProfileColumns(S_RAWPARTLIST_SUPERVISOR, RawPartColumns)
      ' recupero riferimento a colonna StartCut e PosZ
      m_colRawPart_StartCut = m_RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_STARTCUT)
      m_colRawPart_PosZ = m_RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_POSZ)
   End Sub

#End Region    ' CONSTRUCTOR

   Friend Sub UpdateColumns(nMachType As MachineType)
      If nMachType = MachineType.BEAM Then
         ' aggiorno la visibilità delle colonne
         For Each col In RawPartColumns
            col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
         Next
         If Not IsNothing(m_colRawPart_StartCut) Then
            m_colRawPart_StartCut.ColumnVisibility = Visibility.Visible
         End If
         If Not IsNothing(m_colRawPart_PosZ) Then
            m_colRawPart_PosZ.ColumnVisibility = Visibility.Collapsed
         End If
         'RawPartColumns.Clear()
         'GetPrivateProfileColumns(S_RAWPARTLIST_BEAM, RawPartColumns)
      ElseIf nMachType = MachineType.WALL Then
         ' aggiorno la visibilità delle colonne
         For Each col In RawPartColumns
            col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
         Next
         If Not IsNothing(m_colRawPart_StartCut) Then
            m_colRawPart_StartCut.ColumnVisibility = Visibility.Collapsed
         End If
         If Not IsNothing(m_colRawPart_PosZ) Then
            m_colRawPart_PosZ.ColumnVisibility = Visibility.Visible
         End If
         'RawPartColumns.Clear()
         'GetPrivateProfileColumns(S_RAWPARTLIST_WALL, RawPartColumns)
      End If
   End Sub

End Class
