Imports System.IO 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 Public Shared Function GetTargetSplitter(d As DependencyObject) As GridSplitter Return CType(d.GetValue(TargetSplitterProperty), GridSplitter) End Function Public Shared Sub SetTargetSplitter(d As DependencyObject, value As GridSplitter) d.SetValue(TargetSplitterProperty, value) End Sub Public Shared ReadOnly TargetSplitterProperty As DependencyProperty = DependencyProperty.RegisterAttached( "TargetSplitter", GetType(GridSplitter), GetType(DrawOptionPanelVM), New PropertyMetadata(Nothing) ) 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 splitter = DrawOptionPanelVM.GetTargetSplitter(row) If splitter IsNot Nothing Then splitter.IsEnabled = isExpanded splitter.Visibility = If(isExpanded, Visibility.Visible, Visibility.Collapsed) End If 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) row.MinHeight = 0 Else If File.Exists(Map.refMainWindowVM.DimensionDir) Then DynamicGridModule.RestoreDrawGridLayout(Map.refDrawOptionPanelV.DrawGrid, "ManageLayer", 0, If(IniFile.IsActivePlugin(), DynamicGridModule.PROJECT_DRAW_PLUGIN, DynamicGridModule.PROJECT_DRAW)) DynamicGridModule.RestoreDrawGridLayout(Map.refDrawOptionPanelV.DrawGrid, "Info", 1, If(IniFile.IsActivePlugin(), DynamicGridModule.PROJECT_DRAW_PLUGIN, DynamicGridModule.PROJECT_DRAW)) Map.refDrawOptionPanelV.DrawGrid.UpdateLayout() Else row.Height = New GridLength(rowHeight) End If End If End Sub #End Region ' Depency Property End Class