Imports System.Windows
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5

Public Class SectionXMaterialToBeAdded
   Inherits SectionXMaterial

   Sub New(SectXMat As SectionXMaterial)
      MyBase.New(SectXMat.dW, SectXMat.dH, SectXMat.dL, SectXMat.sMaterial(0))
   End Sub

   Private m_Alias_IsChecked As Boolean
   Public Overrides Property Alias_IsChecked As Boolean
      Get
         Return m_Alias_IsChecked
      End Get
      Set(value As Boolean)
         m_Alias_IsChecked = value
         ' Se Alias è checkato seleziono subito il primo elemento nella CmBx altrimenti setto la selezione a Nothing
         SelMaterialForSameSection = If(m_Alias_IsChecked, MaterialForSameSection_List(0), Nothing)
         NotifyPropertyChanged(NameOf(SelMaterialForSameSection))
         ' Setto SelNewSectionXMaterial al suo stesso valore per aggiornare l'abilitazione della CmBx
         Map.refAddSectionXMaterialWndVM.SelNewSectionXMaterial = Map.refAddSectionXMaterialWndVM.SelNewSectionXMaterial
         Map.refAddSectionXMaterialWndVM.NotifyPropertyChanged(NameOf(Map.refAddSectionXMaterialWndVM.SelNewSectionXMaterial))
         NotifyPropertyChanged(NameOf(Alias_IsChecked))
         NotifyPropertyChanged(NameOf(Alias_IsNotChecked))
      End Set
   End Property

   Private m_Alias_IsNotChecked As Boolean
   Public ReadOnly Property Alias_IsNotChecked As Boolean
      Get
         Return Not Alias_IsChecked
      End Get
   End Property

   Public Property sNewW As String
      Get
         Return LenToString(dNewW, 3)
      End Get
      Set(value As String)
         Dim dTempNewW As Double
         If StringToLenAdv(value, dTempNewW, True) AndAlso dTempNewW > 0 Then
            dNewW = dTempNewW
         Else
            NotifyPropertyChanged(NameOf(sNewW))
         End If
      End Set
   End Property

   Public Property sNewL As String
      Get
         Return LenToString(dNewL, 3)
      End Get
      Set(value As String)
         Dim dTempNewL As Double
         If StringToLenAdv(value, dTempNewL, True) AndAlso dTempNewL > 0 Then
            dNewL = dTempNewL
         Else
            NotifyPropertyChanged(NameOf(sNewL))
         End If
      End Set
   End Property

   Public Property sQuantity As String
      Get
         Return nQuantity
      End Get
      Set(value As String)
         Dim nTempQuantity As Integer
         If Integer.TryParse(value, nTempQuantity) AndAlso nTempQuantity >= 0 Then
            nQuantity = nTempQuantity
         Else
            NotifyPropertyChanged(NameOf(sQuantity))
         End If
      End Set
   End Property

End Class

