138 lines
6.2 KiB
VB.net
138 lines
6.2 KiB
VB.net
Imports System.Reflection
|
|
Imports EgtBEAMWALL.Core.ConstGen
|
|
|
|
Public Class OnlyProdBTLPartListV
|
|
|
|
Private m_BTLPartListVM As BTLPartListVM
|
|
|
|
Private m_SelectBtn As MouseButton = MouseButton.Left
|
|
Private m_HighlightBtn As MouseButton = MouseButton.Right
|
|
|
|
Private m_NameDataGridType As Type
|
|
Private s_isDraggingSelectionField As FieldInfo
|
|
Private s_endDraggingMethod As MethodInfo
|
|
|
|
Sub New()
|
|
' This call is required by the designer.
|
|
InitializeComponent()
|
|
' Add any initialization after the InitializeComponent() call.
|
|
m_BTLPartListVM = DataContext
|
|
m_NameDataGridType = BTLPart_DataGrid.GetType()
|
|
s_isDraggingSelectionField = m_NameDataGridType.GetField("_isDraggingSelection", BindingFlags.Instance Or BindingFlags.NonPublic)
|
|
s_endDraggingMethod = m_NameDataGridType.GetMethod("EndDragging", BindingFlags.Instance Or BindingFlags.NonPublic)
|
|
SetSelButton(MouseButton.Right)
|
|
End Sub
|
|
|
|
Public Sub SetSelButton(SelButton As MouseButton)
|
|
Select Case SelButton
|
|
Case MouseButton.Right
|
|
m_SelectBtn = MouseButton.Right
|
|
m_HighlightBtn = MouseButton.Left
|
|
Case Else ' MouseButton.Left
|
|
m_SelectBtn = MouseButton.Left
|
|
m_HighlightBtn = MouseButton.Right
|
|
End Select
|
|
End Sub
|
|
|
|
Public Sub DataGrid_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
|
If e.ChangedButton = MouseButton.Left Then
|
|
If e.ChangedButton = m_SelectBtn Then
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
e.Handled = True
|
|
Else
|
|
Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_)
|
|
End If
|
|
ElseIf e.ChangedButton = m_HighlightBtn AndAlso (Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso
|
|
((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control)) Then
|
|
e.Handled = True
|
|
ElseIf e.ChangedButton = m_HighlightBtn Then
|
|
Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT)
|
|
End If
|
|
' imposto tipo di grid selezionata
|
|
If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PARTLIST)
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub DataGrid_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs)
|
|
If e.ChangedButton = MouseButton.Right Then
|
|
If e.ChangedButton = m_SelectBtn Then
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
e.Handled = True
|
|
Else
|
|
Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_)
|
|
End If
|
|
ElseIf e.ChangedButton = m_HighlightBtn Then
|
|
Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT)
|
|
End If
|
|
' imposto tipo di grid selezionata
|
|
If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART)
|
|
End If
|
|
End Sub
|
|
|
|
Public Shared Function FindVisualParent(Of T As DependencyObject)(ByVal child As DependencyObject) As T
|
|
Dim parentObject As DependencyObject = VisualTreeHelper.GetParent(child)
|
|
If parentObject Is Nothing Then Return Nothing
|
|
Dim parent As T = TryCast(parentObject, T)
|
|
|
|
If parent IsNot Nothing Then
|
|
Return parent
|
|
Else
|
|
Return FindVisualParent(Of T)(parentObject)
|
|
End If
|
|
End Function
|
|
|
|
Public Sub DataGrid_PreviewMouseMove(sender As Object, e As MouseEventArgs)
|
|
If m_SelectBtn = MouseButton.Left AndAlso e.LeftButton = MouseButtonState.Pressed Then
|
|
If CBool(If(s_isDraggingSelectionField?.GetValue(BTLPart_DataGrid), False)) Then s_endDraggingMethod.Invoke(BTLPart_DataGrid, New Object(-1) {})
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PartList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
|
If TypeOf sender Is DataGridRow Then
|
|
Dim Row As DataGridRow = DirectCast(sender, DataGridRow)
|
|
If Not Row.IsSelected Then Return
|
|
Select Case e.ChangedButton
|
|
Case MouseButton.Left
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
Return
|
|
Else
|
|
BTLPart_DataGrid.SelectedItem = Nothing
|
|
BTLPart_DataGrid.SelectedItem = Row.DataContext
|
|
End If
|
|
|
|
Case MouseButton.Right
|
|
|
|
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PartList_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs)
|
|
If TypeOf sender Is DataGridRow Then
|
|
Dim Row As DataGridRow = DirectCast(sender, DataGridRow)
|
|
If Not Row.IsSelected Then Return
|
|
Select Case e.ChangedButton
|
|
Case MouseButton.Right
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
|
|
Row.IsSelected = Not Row.IsSelected
|
|
Else
|
|
BTLPart_DataGrid.SelectedItem = Nothing
|
|
BTLPart_DataGrid.SelectedItem = Row.DataContext
|
|
' metto focus su cella selezionata per evitare errori di focus del sistema normale
|
|
Dim dep As DependencyObject = CType(e.OriginalSource, DependencyObject)
|
|
While (dep IsNot Nothing) AndAlso Not (TypeOf dep Is DataGridCell)
|
|
dep = VisualTreeHelper.GetParent(dep)
|
|
End While
|
|
If dep Is Nothing Then Return
|
|
If TypeOf dep Is DataGridCell Then
|
|
Dim cell As DataGridCell = TryCast(dep, DataGridCell)
|
|
cell.Focus()
|
|
End If
|
|
End If
|
|
End Select
|
|
End If
|
|
|
|
End Sub
|
|
|
|
End Class
|