9c2729d278
- migliorie a taglio diretto singolo - aggiunta gestione lavoro in corso - migliorie varie.
245 lines
8.4 KiB
VB.net
245 lines
8.4 KiB
VB.net
Imports System.Globalization
|
|
Imports EgtUILib
|
|
|
|
Public Class NumericKeyboardWD
|
|
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Friend m_DoubleResult As Double = 0
|
|
Friend m_CurrentTxBx As TextBox
|
|
Friend m_CurrentLbl As String = String.Empty
|
|
Private m_sErrorString As String = String.Empty
|
|
Friend m_bErrorState As Boolean = False
|
|
|
|
Sub New()
|
|
' This call is required by the designer.
|
|
InitializeComponent()
|
|
' Altre inizializzazioni
|
|
Owner = m_MainWindow
|
|
' Imposto Dimensioni e posizione della calcolatrice
|
|
Top = m_MainWindow.Top + (m_MainWindow.Height / 12)
|
|
Left = m_MainWindow.Left + (m_MainWindow.Width / 15 * 3)
|
|
Height = m_MainWindow.Height / 12 * 5
|
|
Width = m_MainWindow.Width / 15 * 5
|
|
End Sub
|
|
|
|
Sub New(ByVal sTitle As String, ByVal sValue As String, Optional ByVal CurrentTxBx As TextBox = Nothing)
|
|
' This call is required by the designer.
|
|
InitializeComponent()
|
|
' Altre inizializzazioni
|
|
Owner = m_MainWindow
|
|
NumericKeyboardWDTitle.Text = sTitle
|
|
NumericKeyboardWDTextBox.Text = sValue
|
|
' Text box per valore di ritorno
|
|
m_CurrentTxBx = CurrentTxBx
|
|
' Imposto Dimensioni e posizione della calcolatrice
|
|
Top = m_MainWindow.Top + (m_MainWindow.Height / 12)
|
|
Left = m_MainWindow.Left + (m_MainWindow.Width / 15 * 3)
|
|
Height = m_MainWindow.Height / 12 * 5
|
|
Width = m_MainWindow.Width / 15 * 5
|
|
End Sub
|
|
|
|
Private Sub NumericKeyboardWD_Initialized(sender As Object, e As EventArgs)
|
|
m_sErrorString = EgtMsg(MSG_NUMERICKEYBOARDWD + 1)
|
|
End Sub
|
|
|
|
Private Sub NumericKeyboardWD_Loaded(sender As Object, e As RoutedEventArgs)
|
|
'NumericKeyboardWDTextBox.Text = m_CurrentTxBx.Text
|
|
'NumericKeyboardWDTitle.Text = m_CurrentLbl
|
|
End Sub
|
|
|
|
Private Sub NumericKeyboardWD_IsVisibleChanged(sender As Object, e As DependencyPropertyChangedEventArgs)
|
|
If Me.IsVisible Then
|
|
'NumericKeyboardWDTextBox.Text = m_CurrentTxBx.Text
|
|
'NumericKeyboardWDTitle.Text = m_CurrentLbl
|
|
Else
|
|
NumericKeyboardWDTitle.Text = String.Empty
|
|
NumericKeyboardWDTitle.Foreground = Brushes.Black
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub NumericKeyboardWD_Unloaded(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTitle.Foreground = Brushes.Black
|
|
m_MainWindow.Focus()
|
|
End Sub
|
|
|
|
Private Sub NumericKeyboardWD_KeyDown(sender As Object, e As KeyEventArgs)
|
|
Select Case e.Key
|
|
Case Key.D0
|
|
If Input.Keyboard.Modifiers = ModifierKeys.Shift Then
|
|
BtnEvaluateWD_Click(Me, Nothing)
|
|
Else
|
|
Btn0WD_Click(Me, Nothing)
|
|
End If
|
|
Case Key.NumPad0
|
|
Btn0WD_Click(Me, Nothing)
|
|
Case Key.D1, Key.NumPad1
|
|
Btn1WD_Click(Me, Nothing)
|
|
Case Key.D2, Key.NumPad2
|
|
Btn2WD_Click(Me, Nothing)
|
|
Case Key.D3, Key.NumPad3
|
|
Btn3WD_Click(Me, Nothing)
|
|
Case Key.D4, Key.NumPad4
|
|
Btn4WD_Click(Me, Nothing)
|
|
Case Key.D5, Key.NumPad5
|
|
Btn5WD_Click(Me, Nothing)
|
|
Case Key.D6, Key.NumPad6
|
|
Btn6WD_Click(Me, Nothing)
|
|
Case Key.D7
|
|
If Input.Keyboard.Modifiers = ModifierKeys.Shift Then
|
|
BtnDivisionWD_Click(Me, Nothing)
|
|
Else
|
|
Btn7WD_Click(Me, Nothing)
|
|
End If
|
|
Case Key.NumPad7
|
|
Btn7WD_Click(Me, Nothing)
|
|
Case Key.D8, Key.NumPad8
|
|
Btn8WD_Click(Me, Nothing)
|
|
Case Key.D9, Key.NumPad9
|
|
Btn9WD_Click(Me, Nothing)
|
|
Case Key.OemPeriod, Key.Decimal
|
|
BtnDotWD_Click(Me, Nothing)
|
|
Case Key.OemPlus
|
|
If Input.Keyboard.Modifiers = ModifierKeys.Shift Then
|
|
BtnMultiplicationWD_Click(Me, Nothing)
|
|
Else
|
|
BtnPlusWD_Click(Me, Nothing)
|
|
End If
|
|
Case Key.Add
|
|
BtnPlusWD_Click(Me, Nothing)
|
|
Case Key.OemMinus, Key.Subtract
|
|
BtnMinusWD_Click(Me, Nothing)
|
|
Case Key.Multiply
|
|
BtnMultiplicationWD_Click(Me, Nothing)
|
|
Case Key.Divide
|
|
BtnDivisionWD_Click(Me, Nothing)
|
|
Case Key.C
|
|
BtnCancelWD_Click(Me, Nothing)
|
|
Case Key.Back
|
|
BtnDeleteWD_Click(Me, Nothing)
|
|
Case Key.Enter, Key.Execute
|
|
BtnApplyWD_Click(Me, Nothing)
|
|
e.Handled = True
|
|
Case Key.Escape
|
|
BtnExitWD_Click(Me, Nothing)
|
|
e.Handled = True
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub Btn0WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "0"
|
|
End Sub
|
|
|
|
Private Sub Btn1WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "1"
|
|
End Sub
|
|
|
|
Private Sub Btn2WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "2"
|
|
End Sub
|
|
|
|
Private Sub Btn3WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "3"
|
|
End Sub
|
|
|
|
Private Sub Btn4WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "4"
|
|
End Sub
|
|
|
|
Private Sub Btn5WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "5"
|
|
End Sub
|
|
|
|
Private Sub Btn6WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "6"
|
|
End Sub
|
|
|
|
Private Sub Btn7WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "7"
|
|
End Sub
|
|
|
|
Private Sub Btn8WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "8"
|
|
End Sub
|
|
|
|
Private Sub Btn9WD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "9"
|
|
End Sub
|
|
|
|
Private Sub BtnDotWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "."
|
|
End Sub
|
|
|
|
Private Sub BtnEvaluateWD_Click(sender As Object, e As RoutedEventArgs)
|
|
Evaluate()
|
|
End Sub
|
|
|
|
Private Sub BtnPlusWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "+"
|
|
End Sub
|
|
|
|
Private Sub BtnMinusWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "-"
|
|
End Sub
|
|
|
|
Private Sub BtnMultiplicationWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "*"
|
|
End Sub
|
|
|
|
Private Sub BtnDivisionWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text &= "/"
|
|
End Sub
|
|
|
|
Private Sub BtnDeleteWD_Click(sender As Object, e As RoutedEventArgs)
|
|
If Not String.IsNullOrEmpty(NumericKeyboardWDTextBox.Text) Then
|
|
NumericKeyboardWDTextBox.Text = NumericKeyboardWDTextBox.Text.Substring(0, NumericKeyboardWDTextBox.Text.Length - 1)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnCancelWD_Click(sender As Object, e As RoutedEventArgs)
|
|
If m_bErrorState Then
|
|
NumericKeyboardWDTextBox.Text = String.Empty
|
|
NumericKeyboardWDTitle.Foreground = Brushes.Black
|
|
NumericKeyboardWDTitle.Text = m_CurrentLbl
|
|
m_bErrorState = False
|
|
Else
|
|
NumericKeyboardWDTextBox.Text = String.Empty
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnExitWD_Click(sender As Object, e As RoutedEventArgs)
|
|
NumericKeyboardWDTextBox.Text = String.Empty
|
|
NumericKeyboardWDTitle.Text = String.Empty
|
|
Me.DialogResult = False
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub BtnApplyWD_Click(sender As Object, e As RoutedEventArgs)
|
|
Evaluate()
|
|
If Not m_bErrorState Then
|
|
If m_CurrentTxBx IsNot Nothing Then
|
|
m_CurrentTxBx.Text = NumericKeyboardWDTextBox.Text
|
|
End If
|
|
NumericKeyboardWDTextBox.Text = String.Empty
|
|
NumericKeyboardWDTitle.Text = String.Empty
|
|
Me.DialogResult = True
|
|
Me.Close()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Evaluate()
|
|
Dim bOk As Boolean = EgtUILib.EgtLuaEvalNumExpr(NumericKeyboardWDTextBox.Text, m_DoubleResult)
|
|
If bOk Then
|
|
NumericKeyboardWDTextBox.Text = m_DoubleResult.ToString(CultureInfo.InvariantCulture)
|
|
If m_bErrorState Then
|
|
m_bErrorState = False
|
|
NumericKeyboardWDTitle.Foreground = Brushes.Black
|
|
NumericKeyboardWDTitle.Text = m_CurrentLbl
|
|
End If
|
|
Else
|
|
m_bErrorState = True
|
|
NumericKeyboardWDTitle.Foreground = Brushes.Red
|
|
NumericKeyboardWDTitle.Text = m_sErrorString
|
|
End If
|
|
End Sub
|
|
|
|
End Class |