diff --git a/AttachedBehaviours/ScrollIntoView.vb b/AttachedBehaviours/ScrollIntoView.vb new file mode 100644 index 0000000..879a2be --- /dev/null +++ b/AttachedBehaviours/ScrollIntoView.vb @@ -0,0 +1,152 @@ +Imports System.Windows.Interactivity +Imports System.Collections.Specialized + +Public Class ScrollIntoViewForListBox + Inherits Behavior(Of ListBox) + + Private ItemsSource As INotifyCollectionChanged + + Private ListControl As ListBox + + ''' + ''' When Beahvior is attached + ''' + Protected Overrides Sub OnAttached() + MyBase.OnAttached() + ListControl = Me.AssociatedObject + AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + End Sub + + + Private Sub AssociatedObject_CollectionChanged(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs) + If ListControl.SelectedItem IsNot Nothing Then + Dim SelectedItemIndex As Integer = ListControl.Items.IndexOf(ListControl.SelectedItem) + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + If ListControl.SelectedItem IsNot Nothing Then + ListControl.ScrollIntoView(ListControl.SelectedItem) + End If + End Sub, Action)) + If SelectedItemIndex > 0 Then + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex - 1)) + End Sub, Action)) + End If + If SelectedItemIndex < ListControl.Items.Count - 2 Then + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex + 1)) + End Sub, Action)) + End If + End If + End Sub + + ''' + ''' On Selection Changed + ''' + ''' + ''' + Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + If IsNothing(ItemsSource) Then + Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource + ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged) + AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + + ' SE SI CAMBIA ITEMSSOURCE PERDE IL RIFERIMENTO E SMETTE DI FUNZIONARE + ' PER RIATTIVARLO USARE IL SEGUENTE CODICE COMMENTATO + 'ElseIf ItemsSource IsNot Me.AssociatedObject.ItemsSource Then + ' Dim PreviousItemsSourceList As INotifyCollectionChanged = TryCast(ItemsSource, INotifyCollectionChanged) + ' RemoveHandler PreviousItemsSourceList.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + ' Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource + ' ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged) + ' AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + End If + End Sub + + ''' + ''' When behavior is detached + ''' + Protected Overrides Sub OnDetaching() + MyBase.OnDetaching() + 'RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + RemoveHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + End Sub + +End Class + +Public Class ScrollIntoViewForDataGrid + Inherits Behavior(Of DataGrid) + + Private ItemsSource As INotifyCollectionChanged + + Private ListControl As DataGrid + + ''' + ''' When Beahvior is attached + ''' + Protected Overrides Sub OnAttached() + MyBase.OnAttached() + ListControl = Me.AssociatedObject + AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + End Sub + + + Private Sub AssociatedObject_CollectionChanged(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs) + If ListControl.SelectedItem IsNot Nothing Then + Dim SelectedItemIndex As Integer = ListControl.Items.IndexOf(ListControl.SelectedItem) + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + If ListControl.SelectedItem IsNot Nothing Then + ListControl.ScrollIntoView(ListControl.SelectedItem) + End If + End Sub, Action)) + If SelectedItemIndex > 0 Then + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex - 1)) + End Sub, Action)) + End If + If SelectedItemIndex < ListControl.Items.Count - 2 Then + ListControl.Dispatcher.BeginInvoke(DirectCast(Sub() + ListControl.UpdateLayout() + ListControl.ScrollIntoView(ListControl.Items(SelectedItemIndex + 1)) + End Sub, Action)) + End If + End If + End Sub + + ''' + ''' On Selection Changed + ''' + ''' + ''' + Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + If IsNothing(ItemsSource) Then + Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource + ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged) + AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + + ' SE SI CAMBIA ITEMSSOURCE PERDE IL RIFERIMENTO E SMETTE DI FUNZIONARE + ' PER RIATTIVARLO USARE IL SEGUENTE CODICE COMMENTATO + 'ElseIf ItemsSource IsNot Me.AssociatedObject.ItemsSource Then + ' Dim PreviousItemsSourceList As INotifyCollectionChanged = TryCast(ItemsSource, INotifyCollectionChanged) + ' RemoveHandler PreviousItemsSourceList.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + ' Dim CurrItemsSource As IEnumerable = Me.AssociatedObject.ItemsSource + ' ItemsSource = TryCast(CurrItemsSource, INotifyCollectionChanged) + ' AddHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + End If + End Sub + + ''' + ''' When behavior is detached + ''' + Protected Overrides Sub OnDetaching() + MyBase.OnDetaching() + 'RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + RemoveHandler ItemsSource.CollectionChanged, AddressOf AssociatedObject_CollectionChanged + End Sub + +End Class diff --git a/AttachedBehaviours/ScrollIntoViewForListBox.vb b/AttachedBehaviours/ScrollIntoViewForListBox.vb deleted file mode 100644 index 7c4f6e4..0000000 --- a/AttachedBehaviours/ScrollIntoViewForListBox.vb +++ /dev/null @@ -1,42 +0,0 @@ -Imports System.Windows.Interactivity - -Public Class ScrollIntoViewForListBox - Inherits Behavior(Of ListBox) - - ''' - ''' When Beahvior is attached - ''' - Protected Overrides Sub OnAttached() - MyBase.OnAttached() - AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged - End Sub - - ''' - ''' On Selection Changed - ''' - ''' - ''' - Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) - If TypeOf sender Is ListBox Then - Dim listBox As ListBox = TryCast(sender, ListBox) - If listBox.SelectedItem IsNot Nothing Then - listBox.Dispatcher.BeginInvoke(DirectCast(Sub() - listBox.UpdateLayout() - If listBox.SelectedItem IsNot Nothing Then - listBox.ScrollIntoView(listBox.SelectedItem) - End If - - End Sub, Action)) - End If - End If - End Sub - ''' - ''' When behavior is detached - ''' - Protected Overrides Sub OnDetaching() - MyBase.OnDetaching() - RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged - - End Sub - -End Class diff --git a/Constants/ConstDoors.vb b/Constants/ConstDoors.vb new file mode 100644 index 0000000..71f5562 --- /dev/null +++ b/Constants/ConstDoors.vb @@ -0,0 +1,6 @@ +Module ConstDoors + + Public Const S_OPERATIONS As String = "Operations" + Public Const S_GEOMETRYNAMES As String = "GeometryNames" + +End Module diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index e15ec6c..59904e4 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -120,22 +120,25 @@ - + + + MTableDbView.xaml + OptionsView.xaml diff --git a/EgtCAM5Resources.xaml b/EgtCAM5Resources.xaml index c958cd8..43290c2 100644 --- a/EgtCAM5Resources.xaml +++ b/EgtCAM5Resources.xaml @@ -33,6 +33,7 @@ + - - diff --git a/MTableDb/MTableDbView.xaml b/MTableDb/MTableDbView.xaml index 86d9279..f790d0b 100644 --- a/MTableDb/MTableDbView.xaml +++ b/MTableDb/MTableDbView.xaml @@ -1,6 +1,8 @@  - + - - + + + + + - + + + + +