ae5a2467da
- Modificata behaviour che apre e chiude gli expander automaticamente. - Modificato calcolo dell'altezza massima dei parametri operazione di lavorazione. - Migliorie varie.
84 lines
3.8 KiB
VB.net
84 lines
3.8 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports EgtWPFLib5.EgtFloating
|
|
|
|
Public Class MachiningParameterExpanderView
|
|
|
|
Private EgtFloatingTray As EgtFloatingTray
|
|
Private EgtFloatingPanel As EgtFloatingPanel
|
|
|
|
Private m_bFirst As Boolean = True
|
|
|
|
Private Sub OperationExpanderView_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
|
|
If m_bFirst Then
|
|
EgtFloatingTray = FindAncestor(Of EgtFloatingTray)(Me)
|
|
EgtFloatingPanel = FindAncestor(Of EgtFloatingPanel)(Me)
|
|
AddHandler EgtFloatingTray.SizeChanged, AddressOf EgtFloatingTray_SizeChanged
|
|
PanelHeight = EgtFloatingPanel.ActualHeight
|
|
Me.AutomaticCloseExpanderStackPanelHeight = AutomaticCloseExpanderStackPanel.ActualHeight
|
|
m_bFirst = False
|
|
End If
|
|
CalculateOperationParametersStackPanelMaxHeight()
|
|
End Sub
|
|
|
|
Dim m_bSizeChanging As Boolean = False
|
|
|
|
Private Sub EgtFloatingTray_SizeChanged(sender As Object, e As System.Windows.SizeChangedEventArgs)
|
|
If m_bSizeChanging Then Return
|
|
m_bSizeChanging = True
|
|
CalculateOperationParametersStackPanelMaxHeight()
|
|
m_bSizeChanging = False
|
|
End Sub
|
|
|
|
Dim PanelHeight As Double = 0
|
|
Dim AutomaticCloseExpanderStackPanelHeight As Double = 0
|
|
|
|
Private Sub CalculateOperationParametersStackPanelMaxHeight()
|
|
Dim AutomaticCloseExpanderStackPanelHeight As Double = 0
|
|
Dim OpenedExpanderList As New List(Of Boolean)
|
|
For Index = 0 To AutomaticCloseExpanderStackPanel.Children.Count - 1
|
|
If TypeOf AutomaticCloseExpanderStackPanel.Children(Index) Is Expander Then
|
|
Dim IndexedExpander As Expander = DirectCast(AutomaticCloseExpanderStackPanel.Children(Index), Expander)
|
|
If IndexedExpander.IsExpanded Then
|
|
OpenedExpanderList.Add(True)
|
|
IndexedExpander.IsExpanded = False
|
|
Dim CurrExpanderContent As FrameworkElement = DirectCast(IndexedExpander.Content, FrameworkElement)
|
|
CurrExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
|
|
AutomaticCloseExpanderStackPanelHeight -= CurrExpanderContent.DesiredSize.Height
|
|
' Sottraggo anche i padding
|
|
AutomaticCloseExpanderStackPanelHeight -= (IndexedExpander.Padding.Top + IndexedExpander.Padding.Bottom)
|
|
Else
|
|
OpenedExpanderList.Add(False)
|
|
End If
|
|
Else
|
|
OpenedExpanderList.Add(False)
|
|
End If
|
|
Next
|
|
Dim RemainingHeight As Double = EgtFloatingTray.ActualHeight - PanelHeight
|
|
AutomaticCloseExpanderStackPanel.MaxHeight = Me.AutomaticCloseExpanderStackPanelHeight + RemainingHeight
|
|
For Index = AutomaticCloseExpanderStackPanel.Children.Count - 1 To 0 Step -1
|
|
If TypeOf AutomaticCloseExpanderStackPanel.Children(Index) Is Expander Then
|
|
Dim IndexedExpander As Expander = DirectCast(AutomaticCloseExpanderStackPanel.Children(Index), Expander)
|
|
If OpenedExpanderList(Index) Then
|
|
IndexedExpander.IsExpanded = True
|
|
End If
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
' Funzione che permette di trovare il primo contenitore di tipo T di un elemento grafico dependencyObject
|
|
Public Function FindAncestor(Of T As Class)(dependencyObject As DependencyObject) As T
|
|
Dim target As DependencyObject = dependencyObject
|
|
Do
|
|
target = LogicalTreeHelper.GetParent(target)
|
|
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
|
|
If IsNothing(target) Then
|
|
target = dependencyObject
|
|
Do
|
|
target = VisualTreeHelper.GetParent(target)
|
|
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
|
|
End If
|
|
Return TryCast(target, T)
|
|
End Function
|
|
|
|
End Class
|