Imports EgtUILib

Public Class UnderDrillUC

   ' Riferimento alla MainWindow
   Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
   ' Riferimento alla pagina che ha aperto SideAngleUC
   Private m_CallingPage As MainWindow.Pages

   ' Profondità dei fori
   Private m_dDrillDepth As Double = 0
   Friend ReadOnly Property DrillDepth As Double
      Get
         Return m_dDrillDepth
      End Get
   End Property


   Private Sub DripDrillUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
      ' Imposto riferimenti ad altre pagine
      m_CallingPage = m_MainWindow.m_ActivePage

      ' Imposto messaggi
      Parameter2TxBl.Text = EgtMsg(MSG_IMPORTPAGEUC + 11)      ' Affondamento

      ' Imposto contesto corrente
      EgtSetCurrentContext(m_MainWindow.m_ImportPageUC.ImportScene.GetCtx())

      ' Gestisco visualizzazione dei parametri
      Parameter2TxBl.Visibility = Windows.Visibility.Visible
      Parameter2TxBx.Visibility = Windows.Visibility.Visible

      ' Aggiorno valori
      m_dDrillDepth = GetPrivateProfileDouble(S_SIDES, K_UNDERDRILLDEPTH, 10, m_MainWindow.GetIniFile())
      Parameter2TxBx.Text = LenToString(m_dDrillDepth, 3)
   End Sub

   Private Sub Parameter2TxBx_EgtClosed(sender As Object, e As EventArgs) Handles Parameter2TxBx.EgtClosed
      ' Recupero il valore
      StringToLen(Parameter2TxBx.Text, m_dDrillDepth)
      WritePrivateProfileString(S_SIDES, K_UNDERDRILLDEPTH, DoubleToString(m_dDrillDepth, 2), m_MainWindow.GetIniFile())
      ' Aggiorno affondamento dei fori da sotto già definiti
      Dim nPartId As Integer = EgtGetFirstPart()
      While nPartId <> GDB_ID.NULL
         Dim nLayId As Integer = EgtGetFirstLayer(nPartId)
         While nLayId <> GDB_ID.NULL
            Dim sLayName As String = ""
            If EgtGetName(nLayId, sLayName) And sLayName = NAME_UNDERDRILL Then
               Dim nEntId As Integer = EgtGetFirstInGroup(nLayId)
               EgtSetInfo(nEntId, INFO_DEPTH, m_dDrillDepth)
            End If
            nLayId = EgtGetNextLayer(nLayId)
         End While
         nPartId = EgtGetNextPart(nPartId)
      End While
   End Sub

End Class
