Imports EgtBEAMWALL.Core
Imports System.ComponentModel

Public Class OnlyProdRawPartListV

   Sub New()

      ' This call is required by the designer.
      InitializeComponent()

      ' Add any initialization after the InitializeComponent() call.
      MyComparer.SetDataGrid(MachGroupDataGrid)
      AddHandler MachGroupDataGrid.ResetSort, AddressOf MachGroupDataGrid_ResetSort
   End Sub

   ' funzione che permette di selezionare un RawPart anche quando gia' selezionato
   Private Sub RawPartRow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
      If TypeOf sender Is DataGridRow Then
         Dim Row As DataGridRow = DirectCast(sender, DataGridRow)
         Dim RowVM As MyMachGroupVM = DirectCast(Row.DataContext, MyMachGroupVM)
         ' se gia' selezionato rifaccio selezione perche' potrbbe essere selezionato un BTLPart
         If Not IsNothing(Row) AndAlso Row.IsSelected Then
            Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup = Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup
         End If
      End If
   End Sub

   Private Sub MachGroupVMList_Sorting(sender As Object, e As DataGridSortingEventArgs)
      ' aggiorno direziona colonna
      Dim column As DataGridColumn = e.Column
      column.SortDirection = If((column.SortDirection <> ListSortDirection.Ascending), ListSortDirection.Ascending, ListSortDirection.Descending)
      ' ricalcolo colonne sort
      Dim datagrid As DataGrid = sender
      MyComparer.RefreshColumns()
      ' lancio sort custom
      Map.refSupervisorMachGroupPanelVM.RefreshMachGroupVMSort()
      e.Handled = True
   End Sub

   Private Sub MachGroupDataGrid_ResetSort()
      MyComparer.RefreshColumns()
      Map.refSupervisorMachGroupPanelVM.RefreshMachGroupVMSort()
   End Sub

End Class
