Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5

Public Class TopPanelVM
   Inherits VMBase

#Region "FIELDS & PROPERTIES"

   Private Property m_GridDims As New ObservableCollection(Of GridDimension)
   Public Property GridDims As ObservableCollection(Of GridDimension)
      Get
         Return m_GridDims
      End Get
      Set
         m_GridDims = Value
         NotifyPropertyChanged(NameOf(GridDims))
      End Set
   End Property

   Private m_QParSplitter_Visibility As Visibility
   Public ReadOnly Property QParSplitter_Visibility As Visibility
      Get
         Return If(Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE = BWType.WALL, Visibility.Visible, Visibility.Collapsed)
      End Get
   End Property

   Friend Enum Tabs As Integer
      OPTIMIZATION = 0
      STATISTICS = 1
   End Enum

   Private m_SelTab As Tabs = Tabs.OPTIMIZATION
   Public Property SelTab As Integer
      Get
         Return m_SelTab
      End Get
      Set(value As Integer)
         m_SelTab = value
      End Set
   End Property
   Friend Sub SetSelTab(SelTab As Tabs)
      If m_SelTab = Tabs.STATISTICS Then
         Map.refInstrumentPanelVM.SetStatisticsIsChecked(False)
      End If
      m_SelTab = SelTab
      NotifyPropertyChanged(NameOf(SelTab))
   End Sub

   Private m_TopPanel_IsEnabled As Boolean = True
   Public ReadOnly Property TopPanel_IsEnabled As Boolean
      Get
         Return m_TopPanel_IsEnabled
      End Get
   End Property

   Public ReadOnly Property QParameter_Visibility As Visibility
      Get
         Return If(Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL, Visibility.Visible, Visibility.Collapsed)
      End Get
   End Property

#Region "Messages"

   Public ReadOnly Property ResetCALCRawPart_ToolTip As String
      Get
         Return EgtMsg(61924)
      End Get
   End Property

#End Region    ' Messages

#End Region    'FIELDS & PROPERTIES

   Sub New()
      ' imposto riferimento su mappa
      Map.SetRefTopPanelVM(Me)
      ' imposto dimensioni colonne/righe della Grid
      DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims)
   End Sub

#Region "METHODS"

   Friend Sub SetTopPanelIsEnabled(bIsEnabled As Boolean)
      m_TopPanel_IsEnabled = bIsEnabled
      NotifyPropertyChanged(NameOf(TopPanel_IsEnabled))
   End Sub

   Friend Sub UpdateQParameterVisibility()
      NotifyPropertyChanged(NameOf(QParameter_Visibility))
   End Sub

   Friend Sub ManageQParamsRowVisibility(bVisible As Boolean)
      If bVisible Then
         DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims)
      Else
         GridDimension.SetSoftwareMod(True)
         Dim FeatureRow = m_GridDims(4)
         Dim QParRow = m_GridDims(5)
         m_GridDims(4).GridLen = New GridLength(1, GridUnitType.Star)
         m_GridDims(4).NotifyPropertyChanged(NameOf(FeatureRow.GridLen))
         m_GridDims(5).GridLen = New GridLength(0)
         m_GridDims(5).NotifyPropertyChanged(NameOf(QParRow.GridLen))
         GridDimension.SetSoftwareMod(False)
      End If
      NotifyPropertyChanged(NameOf(QParSplitter_Visibility))
   End Sub

#End Region    ' METHODS

End Class
