Files
EgtCAM5/OptionPanel/DrawOptionPanelVM.vb
T
2026-03-12 11:31:10 +01:00

143 lines
4.2 KiB
VB.net

Public Class DrawOptionPanelVM
Inherits ViewModelBase
' GRAPHICAL ELEMENTS
Private m_ManageLayerExpander As ManageLayerExpanderV
Public ReadOnly Property ManageLayerExpander As ContentControl
Get
If IsNothing(m_ManageLayerExpander) Then
m_ManageLayerExpander = New ManageLayerExpanderV
m_ManageLayerExpander.DataContext = New ManageLayerExpanderVM
End If
Return m_ManageLayerExpander
End Get
End Property
Private m_InfoExpander As InfoExpanderV
Public ReadOnly Property InfoExpander As ContentControl
Get
If IsNothing(m_InfoExpander) Then
m_InfoExpander = New InfoExpanderV
m_InfoExpander.DataContext = New InfoExpanderVM
End If
Return m_InfoExpander
End Get
End Property
Private m_InputExpander As InputExpanderV
Public ReadOnly Property InputExpander As ContentControl
Get
If IsNothing(m_InputExpander) Then
m_InputExpander = New InputExpanderV
m_InputExpander.DataContext = New InputExpanderVM
End If
Return m_InputExpander
End Get
End Property
Private m_ManageLayerRowIsExpanded As Boolean = True
Public ReadOnly Property ManageLayerRowIsExpanded As Boolean
Get
Return m_ManageLayerRowIsExpanded
End Get
End Property
Friend Sub SetManageLayerRowIsExpanded(value As Boolean)
m_ManageLayerRowIsExpanded = value
OnPropertyChanged("ManageLayerRowIsExpanded")
End Sub
Private m_InfoRowIsExpanded As Boolean = True
Public ReadOnly Property InfoRowIsExpanded As Boolean
Get
Return m_InfoRowIsExpanded
End Get
End Property
Friend Sub SetInfoRowIsExpanded(value As Boolean)
m_InfoRowIsExpanded = value
OnPropertyChanged("InfoRowIsExpanded")
End Sub
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in Map
Map.SetRefDrawOptionPanelVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Function InitDrawOptionPanel() As Boolean
'EgtZoom(ZM.ALL)
Return True
End Function
Friend Function ExitDrawOptionPanel() As Boolean
Return True
End Function
#End Region ' METHODS
#Region "DEPENCY PROPERTY"
Public Shared ReadOnly RowIdProperty As DependencyProperty =
DependencyProperty.RegisterAttached(
"RowId",
GetType(String),
GetType(DrawOptionPanelVM),
New PropertyMetadata(Nothing)
)
Public Shared Sub SetRowId(element As DependencyObject, value As String)
element.SetValue(RowIdProperty, value)
End Sub
Public Shared Function GetRowId(element As DependencyObject) As String
Return CType(element.GetValue(RowIdProperty), String)
End Function
Public Shared ReadOnly IsExpandedProperty As DependencyProperty =
DependencyProperty.RegisterAttached(
"IsExpanded",
GetType(Boolean),
GetType(DrawOptionPanelVM),
New PropertyMetadata(True, AddressOf OnIsExpandedChanged)
)
Public Shared Sub SetIsExpanded(element As DependencyObject, value As Boolean)
element.SetValue(IsExpandedProperty, value)
End Sub
Public Shared Function GetIsExpanded(element As DependencyObject) As Boolean
Return CType(element.GetValue(IsExpandedProperty), Boolean)
End Function
Private Shared Sub OnIsExpandedChanged(d As DependencyObject, e As DependencyPropertyChangedEventArgs)
Dim row As RowDefinition = TryCast(d, RowDefinition)
If IsNothing(row) Then Return
Dim isExpanded As Boolean = CBool(e.NewValue)
Dim rowId As String = GetRowId(row)
Dim rowHeight As Double = 0
If rowId = "ManageLayer" Then
rowHeight = 400
ElseIf rowId = "Info" Then
rowHeight = 150
End If
If Not isExpanded Then
row.ClearValue(RowDefinition.HeightProperty)
row.Height = New GridLength(1, GridUnitType.Auto)
Else
row.Height = New GridLength(rowHeight)
End If
End Sub
#End Region ' Depency Property
End Class