Public Class SelectPartFromFamilyWD
   Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)

   Private m_NumberOfParts As Integer = 1
   Public Property NumberOfParts As Integer
      Get
         Return m_NumberOfParts
      End Get
      Set(value As Integer)
         m_NumberOfParts = value
      End Set
   End Property

   Private m_NumberOfSelection As Integer = 1
   Public Property NumberOfSelection As Integer
      Get
         Return m_NumberOfSelection
      End Get
      Set(value As Integer)
         m_NumberOfSelection = value
      End Set
   End Property
   Public Sub New(Owner As Window, NbrParts As Integer)
      Me.Owner = Owner
      m_NumberOfParts = NbrParts
      InitializeComponent()
      Me.ShowDialog()
   End Sub

   ' inizializzo la finestra
   Private Sub SelectPartFromFamilyWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
      ' posiziono la fistra in centro alla pagina
      Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
      Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2

      TitleWDTxbl.Text = "Selection parts"
      NbrOfPartsMsg.Text = "Number of parts"
      NbrOfParts.Text = m_NumberOfParts.ToString
   End Sub

   ' seleziono il numero di elementi indicati
   Private Sub ConfirmSelection_Click(sender As Object, e As RoutedEventArgs) Handles ConfirmSelection.Click
      Dim nVal As Integer = 0
      StringToInt(NbrOfParts.Text, nVal)
      If nVal >= 0 Then
         m_NumberOfSelection = nVal
      Else
         ' indice non valido per la selezione
         m_NumberOfSelection = 0
      End If
      Me.Close()
   End Sub

   '' seleziona tutti
   'Private Sub SelectAllPart_Click(sender As Object, e As RoutedEventArgs) Handles SelectAllPart.Click
   '   m_NumberOfSelection = m_NumberOfParts
   '   Me.Close()
   'End Sub

   ' Deseleziomo tutto
   Private Sub CancelSelection_Click(sender As Object, e As RoutedEventArgs) Handles CancelSelection.Click
      m_NumberOfSelection = 0
      Me.Close()
   End Sub

End Class
