Imports System.IO
Imports EgtUILib
Imports EgtWPFLib

Public Class EditValueWD

   ' Riferimento alla MainWindow
   Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
   Private m_sMsg As String = "Value"
   Private m_sValue As String = ""

   Sub New(Owner As Window, Optional sMsg As String = "")
      Me.Owner = Owner
      m_sMsg = sMsg
      InitializeComponent()
   End Sub

   Friend Function SetVal( dVal As Double) As Boolean
      m_sValue = DoubleToString( dVal, 3)
      ValueTxBx.Text = m_sValue
      Return true
   End Function

   Friend Function GetVal() As Double
      Dim dVal As Double = 0
      StringToDouble( m_sValue, dVal)
      Return dVal
   End Function

   Private Sub EditValueWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
      Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
      Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
      ValueTxbl.Text = m_sMsg
   End Sub

   Private Sub EditValueWD_Rendered(sender As Object, e As EventArgs) Handles Me.ContentRendered
      ' ValueTxBx.Focus()
      ' ValueTxBx.OpenKeyboard(ValueTxBx, ValueTxBx)
   End Sub

   'Private Sub ValueTxBx_Closed(Sender As Object, e As EventArgs) Handles ValueTxBx.EgtClosed
   '   m_sValue = ValueTxBx.Text
   '   DialogResult = True
   'End Sub

   Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
      m_sValue = ValueTxBx.Text
      DialogResult = True
   End Sub

   Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
      m_sValue = ""
      DialogResult = False
   End Sub

End Class
