Files
EgtWPFLib/EgtKeyboard.xaml.vb

766 lines
28 KiB
VB.net

'----------------------------------------------------------------------------
' EgalTech 2014-2015
'----------------------------------------------------------------------------
' File : EgtKeyboard.xaml.vb Data : 13.12.15 Versione : 1
' Contenuto : Tastiera alfanumerica ridotta touch per EgtWPFLib.
'
' Creato da : Emmanuele Sassi
' Modificato da :
'
' Modifiche :
'
'----------------------------------------------------------------------------
Public Class EgtKeyboard
Private Const ASPECTRATIO = 12 / 5
Private Const WIDTHFONTRATIO = 22 / 1024
Private Const OFFSET = 3 'Offset per non mostrare la tastiera attaccata alla TextboxBase
' Variabile statica che indica se è già aperta una tastiera
Private Shared bIsActive As Boolean = False
' Riferimento alla TxBx che ha attivato la tastiera
Private m_SourceTxBx As Primitives.TextBoxBase
' Testo contenuto all'apertura
Private m_sOrigTxt As String = String.Empty
' Variabili di posizionamento
Private m_Position As Positions = Positions.CenteredInOwner
Private m_RelativeToSourcePosition As RelativeToSourcePositions = RelativeToSourcePositions.Bottom
Private m_SourceTop As Double = 0
Private m_SourceLeft As Double = 0
' Variabili che contengono lo stato dei tasti Shift, Alt e Caps Lock
Private m_bShift As Boolean = False
Private m_bAlt As Boolean = False
Private m_bCapsLock As Boolean = False
' Evento che indica la chiusura della tastiera
Public Event EgtClosed As EventHandler
'Funzione che restituisce il valore di bIsActive per usarlo all'esterno della libreria
Public Shared Function GetbIsActive() As Boolean
Return bIsActive
End Function
#Region "Constructors and support functions"
Sub New(TextBoxBase As Primitives.TextBoxBase, Owner As Window)
InitializeComponent()
'Me.Owner = Owner
bIsActive = True
m_SourceTxBx = TextBoxBase
m_sOrigTxt = DirectCast(m_SourceTxBx, TextBox).Text
Me.Width = Owner.ActualWidth / 2
Me.Height = Me.Width * (1 / ASPECTRATIO)
If InitializeEgtWPFLib.ResourceDictionary = 0 Then
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
Else
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDarkDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
End If
Dim FontSize As Double = Width * WIDTHFONTRATIO
Me.Resources("EgtKeyboard_FontSize") = New FontSizeConverter().ConvertFrom(CStr(FontSize))
'Me.Top = Owner.Top + (Owner.Height / 2 - Me.Height / 2)
'Me.Left = Owner.Left + (Owner.Width / 2 - Me.Width / 2)
End Sub
Sub New(TextBoxBase As Primitives.TextBoxBase, Owner As Window, Width As Double)
InitializeComponent()
'Me.Owner = Owner
bIsActive = True
m_SourceTxBx = TextBoxBase
m_sOrigTxt = DirectCast(m_SourceTxBx, TextBox).Text
Me.Width = Width
Me.Height = Width * (1 / ASPECTRATIO)
If InitializeEgtWPFLib.ResourceDictionary = 0 Then
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
Else
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDarkDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
End If
Dim FontSize As Double = Width * WIDTHFONTRATIO
Me.Resources("EgtKeyboard_FontSize") = New FontSizeConverter().ConvertFrom(CStr(FontSize))
'Me.Top = Owner.Top + (Owner.Height / 2 - Me.Height / 2)
'Me.Left = Owner.Left + (Owner.Width / 2 - Me.Width / 2)
End Sub
Sub New(TextBoxBase As Primitives.TextBoxBase, Owner As Window, Width As Double, FontSize As Double)
InitializeComponent()
'Me.Owner = Owner
bIsActive = True
m_SourceTxBx = TextBoxBase
m_sOrigTxt = DirectCast(m_SourceTxBx, TextBox).Text
Me.Width = Width
Me.Height = Width * (1 / ASPECTRATIO)
If InitializeEgtWPFLib.ResourceDictionary = 0 Then
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
Else
Dim rd As ResourceDictionary = New ResourceDictionary()
rd.Source = New Uri("/EgtWPFLib;component/EgtWPFLibDarkDictionary.xaml", UriKind.Relative)
Me.Resources.Clear()
Me.Resources = rd
End If
Me.Resources("EgtKeyboard_FontSize") = New FontSizeConverter().ConvertFrom(CStr(FontSize))
'Me.Top = Owner.Top + (Owner.Height / 2 - Me.Height / 2)
'Me.Left = Owner.Left + (Owner.Width / 2 - Me.Width / 2)
End Sub
#Region "Costruttori e funzioni con posizionamento utili nel caso la tastiera sia una finestra"
'Sub New(TextBoxBase As Primitives.TextBoxBase, Owner As Window, Position As Positions, RelativeToSourcePosition As RelativeToSourcePositions, Top As Double, Left As Double)
' InitializeComponent()
' 'Me.Owner = Owner
' bIsActive = True
' m_SourceTxBx = TextBoxBase
' Me.Width = Owner.ActualWidth / 2
' Me.Height = Me.Width * (1 / ASPECTRATIO)
' Dim FontSize As Double = Width * WIDTHFONTRATIO
' Me.Resources("EgtKeyboard_FontSize") = New FontSizeConverter().ConvertFrom(CStr(FontSize))
' Me.m_RelativeToSourcePosition = RelativeToSourcePosition
' Me.m_SourceTop = Top
' Me.m_SourceLeft = Left
' Select Case Position
' Case Positions.CenteredInOwner
' 'Me.Top = Owner.Top + (Owner.Height / 2 - Height / 2)
' 'Me.Left = Owner.Left + (Owner.Width / 2 - Width / 2)
' Case Positions.RelativeToSource
' ' Se nessuna delle quattro posizioni relative alla textbox è valida, la posiziono centrata nell'owner
' If Not CalculateRelativeToSourcePosition() Then
' 'Me.Top = Owner.Top + (Owner.Height / 2 - Height / 2)
' 'Me.Left = Owner.Left + (Owner.Width / 2 - Width / 2)
' End If
' Case Positions.Custom
' 'Me.Top = Top
' 'Me.Left = Left
' End Select
'End Sub
'Sub New(TextBoxBase As Primitives.TextBoxBase, Owner As Window, Width As Double, FontSize As Double, Position As Positions, RelativeToSourcePosition As RelativeToSourcePositions, Top As Double, Left As Double)
' InitializeComponent()
' 'Me.Owner = Owner
' bIsActive = True
' m_SourceTxBx = TextBoxBase
' Me.Width = Width
' Me.Height = Width * (1 / ASPECTRATIO)
' Me.Resources("EgtKeyboard_FontSize") = New FontSizeConverter().ConvertFrom(CStr(FontSize))
' Me.m_RelativeToSourcePosition = RelativeToSourcePosition
' Me.m_SourceTop = Top
' Me.m_SourceLeft = Left
' Select Case Position
' Case Positions.CenteredInOwner
' 'Me.Top = Owner.Top + (Owner.Height / 2 - Height / 2)
' 'Me.Left = Owner.Left + (Owner.Width / 2 - Width / 2)
' Case Positions.RelativeToSource
' ' Se nessuna delle quattro posizioni relative alla textbox è valida, la posiziono centrata nell'owner
' If Not CalculateRelativeToSourcePosition() Then
' 'Me.Top = Owner.Top + (Owner.Height / 2 - Height / 2)
' 'Me.Left = Owner.Left + (Owner.Width / 2 - Width / 2)
' End If
' Case Positions.Custom
' 'Me.Top = Top
' 'Me.Left = Left
' End Select
'End Sub
'Private Function CalculateRelativeToSourcePosition()
' Select Case m_RelativeToSourcePosition
' Case RelativeToSourcePositions.Top
' If Not VerifyRelativeToSourcePosition(RelativeToSourcePositions.Top, RelativeToSourcePositions.Bottom, RelativeToSourcePositions.Right, RelativeToSourcePositions.Left) Then
' Return False
' End If
' Case RelativeToSourcePositions.Bottom
' If Not VerifyRelativeToSourcePosition(RelativeToSourcePositions.Bottom, RelativeToSourcePositions.Top, RelativeToSourcePositions.Right, RelativeToSourcePositions.Left) Then
' Return False
' End If
' Case RelativeToSourcePositions.Left
' If Not VerifyRelativeToSourcePosition(RelativeToSourcePositions.Left, RelativeToSourcePositions.Bottom, RelativeToSourcePositions.Top, RelativeToSourcePositions.Right) Then
' Return False
' End If
' Case RelativeToSourcePositions.Right
' If Not VerifyRelativeToSourcePosition(RelativeToSourcePositions.Right, RelativeToSourcePositions.Bottom, RelativeToSourcePositions.Top, RelativeToSourcePositions.Left) Then
' Return False
' End If
' End Select
' Return True
'End Function
'Private Function VerifyRelativeToSourcePosition(FirstPosition As RelativeToSourcePositions, SecondPosition As RelativeToSourcePositions, ThirdPosition As RelativeToSourcePositions, FourthPosition As RelativeToSourcePositions)
' If Not CalculatePosition(FirstPosition) Then
' If Not CalculatePosition(SecondPosition) Then
' If Not CalculatePosition(ThirdPosition) Then
' If Not CalculatePosition(FourthPosition) Then
' Return False
' End If
' End If
' End If
' End If
' Return True
'End Function
'Private Function CalculatePosition(RelativeToSourcePosition As RelativeToSourcePositions)
' Dim dKeyboardTop As Double
' Dim dKeyboardLeft As Double
' Select Case RelativeToSourcePosition
' Case RelativeToSourcePositions.Top
' dKeyboardTop = Me.m_SourceTop - Me.Height - OFFSET
' dKeyboardLeft = Me.m_SourceLeft - (Me.Width / 2 - m_SourceTxBx.ActualWidth / 2)
' Case RelativeToSourcePositions.Bottom
' dKeyboardTop = Me.m_SourceTop + m_SourceTxBx.ActualHeight + OFFSET
' dKeyboardLeft = Me.m_SourceLeft - (Me.Width / 2 - m_SourceTxBx.ActualWidth / 2)
' Case RelativeToSourcePositions.Left
' dKeyboardTop = Me.m_SourceTop + m_SourceTxBx.ActualHeight / 2 - Me.Height / 2
' dKeyboardLeft = Me.m_SourceLeft - Me.Width - OFFSET
' Case RelativeToSourcePositions.Right
' dKeyboardTop = Me.m_SourceTop + m_SourceTxBx.ActualHeight / 2 - Me.Height / 2
' dKeyboardLeft = Me.m_SourceLeft + m_SourceTxBx.ActualWidth + OFFSET
' End Select
' 'If Not (dKeyboardTop > Me.Owner.Top And (dKeyboardTop + Me.Height) < (Me.Owner.Top + Me.Owner.ActualHeight) And dKeyboardLeft > Me.Owner.Left And (dKeyboardLeft + Me.Width) < (Me.Owner.Left + Me.Owner.ActualWidth)) Then
' ' Return False
' 'End If
' 'Me.Top = Me.Owner.Top + dKeyboardTop
' 'Me.Left = Me.Owner.Left + dKeyboardLeft
' Return True
'End Function
#End Region
#End Region
#Region "Control lifetime events"
'Private Sub EgtKeyboard_Loaded(sender As Object, e As EventArgs) Handles EgtKeyboard.Loaded
' m_SourceTxBx.Focus()
' m_SourceTxBx.SelectAll()
'End Sub
' Private Sub EgtKeyboard_Loaded(sender As Object, e As EventArgs) Handles EgtKeyboard.Loaded
' 'm_sErrorString = EgtMsg(MSG_EGTCALCULATOR + 1)
' If Not IsNothing(m_SourceTxBx) Then
' Dim SourceTxBx As TextBox = m_SourceTxBx
' ValueTxBx.Text = SourceTxBx.Text
' ValueTxBx.Focus()
' ValueTxBx.SelectAll()
' Else
' 'ValueTxBx.Text = DoubleToString(m_dStartValue, 3)
' End If
' End Sub
Private Sub EgtKeyboard_Unloaded(sender As Object, e As EventArgs) Handles EgtKeyboard.Unloaded
End Sub
#End Region
#Region "Button events and support functions"
Private Sub UpperLowerCase(Value As Boolean)
If Value Then
qBtn.Content = "Q"
wBtn.Content = "W"
eBtn.Content = "E"
rBtn.Content = "R"
tBtn.Content = "T"
yBtn.Content = "Y"
uBtn.Content = "U"
iBtn.Content = "I"
oBtn.Content = "O"
pBtn.Content = "P"
aBtn.Content = "A"
sBtn.Content = "S"
dBtn.Content = "D"
fBtn.Content = "F"
gBtn.Content = "G"
hBtn.Content = "H"
jBtn.Content = "J"
kBtn.Content = "K"
lBtn.Content = "L"
zBtn.Content = "Z"
xBtn.Content = "X"
cBtn.Content = "C"
vBtn.Content = "V"
bBtn.Content = "B"
nBtn.Content = "N"
mBtn.Content = "M"
Else
qBtn.Content = "q"
wBtn.Content = "w"
eBtn.Content = "e"
rBtn.Content = "r"
tBtn.Content = "t"
yBtn.Content = "y"
uBtn.Content = "u"
iBtn.Content = "i"
oBtn.Content = "o"
pBtn.Content = "p"
aBtn.Content = "a"
sBtn.Content = "s"
dBtn.Content = "d"
fBtn.Content = "f"
gBtn.Content = "g"
hBtn.Content = "h"
jBtn.Content = "j"
kBtn.Content = "k"
lBtn.Content = "l"
zBtn.Content = "z"
xBtn.Content = "x"
cBtn.Content = "c"
vBtn.Content = "v"
bBtn.Content = "b"
nBtn.Content = "n"
mBtn.Content = "m"
End If
End Sub
Private Sub SymbolNumberCharacter(Value As Boolean)
If Value Then
BackslashBtn.Content = "|"
OneBtn.Content = "!"
TwoBtn.Content = """"
ThreeBtn.Content = "£"
FourBtn.Content = "$"
FiveBtn.Content = "%"
SixBtn.Content = "&"
SevenBtn.Content = "/"
EightBtn.Content = "("
NineBtn.Content = ")"
ZeroBtn.Content = "="
PlusBtn.Content = "*"
MinorBtn.Content = ">"
MinusBtn.Content = "_"
DotBtn.Content = ":"
CommaBtn.Content = ";"
Else
BackslashBtn.Content = "\"
OneBtn.Content = "1"
TwoBtn.Content = "2"
ThreeBtn.Content = "3"
FourBtn.Content = "4"
FiveBtn.Content = "5"
SixBtn.Content = "6"
SevenBtn.Content = "7"
EightBtn.Content = "8"
NineBtn.Content = "9"
ZeroBtn.Content = "0"
PlusBtn.Content = "+"
MinorBtn.Content = "<"
MinusBtn.Content = "-"
DotBtn.Content = "."
CommaBtn.Content = ","
End If
End Sub
' Tasti azione
Private Sub ShiftBtn_Click(sender As Object, e As RoutedEventArgs) Handles Shift1Btn.Click, Shift2Btn.Click
If m_bShift Then
m_bShift = False
UpperLowerCase(False)
SymbolNumberCharacter(False)
Shift1Btn.IsChecked = False
Shift2Btn.IsChecked = False
Else
m_bShift = True
If m_bCapsLock Then
UpperLowerCase(False)
SymbolNumberCharacter(True)
Else
UpperLowerCase(True)
SymbolNumberCharacter(True)
End If
Shift1Btn.IsChecked = True
Shift2Btn.IsChecked = True
End If
m_SourceTxBx.Focus()
End Sub
Private Sub CapsLockBtn_Click(sender As Object, e As RoutedEventArgs) Handles CapsLockBtn.Click
If m_bCapsLock Then
If m_bShift Then
UpperLowerCase(True)
Else
UpperLowerCase(False)
End If
m_bCapsLock = False
CapsLockBtn.IsChecked = False
Else
If m_bShift Then
SymbolNumberCharacter(False)
m_bShift = False
Shift1Btn.IsChecked = False
Shift2Btn.IsChecked = False
End If
m_bCapsLock = True
UpperLowerCase(True)
CapsLockBtn.IsChecked = True
End If
m_SourceTxBx.Focus()
End Sub
Private Sub AltBtn_Click(sender As Object, e As RoutedEventArgs) Handles AltBtn.Click
'Per il momento non fa' nulla
m_SourceTxBx.Focus()
End Sub
' Funzione che gestisce il click di una lettera
Private Sub LetterClick(Uppercase As Char, Lowercase As Char)
If m_bCapsLock Then
If m_bShift Then
AddCharacter(Lowercase)
m_bShift = False
UpperLowerCase(True)
SymbolNumberCharacter(False)
Shift1Btn.IsChecked = False
Shift2Btn.IsChecked = False
Else
SymbolNumberCharacter(False)
AddCharacter(Uppercase)
End If
Else
If m_bShift Then
AddCharacter(Uppercase)
m_bShift = False
UpperLowerCase(False)
SymbolNumberCharacter(False)
Shift1Btn.IsChecked = False
Shift2Btn.IsChecked = False
Else
AddCharacter(Lowercase)
End If
End If
End Sub
' Funzione che gestisce il click di numeri e simboli
Private Sub NumberClick(Uppercase As Char, Lowercase As Char)
If m_bShift Then
If m_bCapsLock Then
UpperLowerCase(True)
Else
UpperLowerCase(False)
End If
SymbolNumberCharacter(False)
AddCharacter(Uppercase)
m_bShift = False
Shift1Btn.IsChecked = False
Shift2Btn.IsChecked = False
Else
AddCharacter(Lowercase)
End If
End Sub
Private Sub AddCharacter(KeyCharacter As String)
m_SourceTxBx.Focus()
Dim EventArgs = New TextCompositionEventArgs(Keyboard.PrimaryDevice, New TextComposition(InputManager.Current, Keyboard.FocusedElement, KeyCharacter)) With {
.RoutedEvent = TextInputEvent
}
InputManager.Current.ProcessInput(EventArgs)
'ValueTxBx.Text = DirectCast(m_SourceTxBx, TextBox).Text
End Sub
Private Sub CharacterBtn_Click(sender As Object, e As RoutedEventArgs) Handles qBtn.Click, wBtn.Click, eBtn.Click, rBtn.Click, tBtn.Click, yBtn.Click, uBtn.Click, iBtn.Click, oBtn.Click, pBtn.Click, aBtn.Click, sBtn.Click, dBtn.Click, fBtn.Click,
gBtn.Click, hBtn.Click, jBtn.Click, kBtn.Click, lBtn.Click, zBtn.Click, xBtn.Click, cBtn.Click, vBtn.Click, bBtn.Click, nBtn.Click, mBtn.Click
Dim KeyButton As Button = e.Source
Dim UpperCaseKey As String = String.Empty
Dim LowerCaseKey As String = String.Empty
If ReturnKeyCharacter(KeyButton, UpperCaseKey, LowerCaseKey) Then
LetterClick(UpperCaseKey(0), LowerCaseKey(0))
End If
End Sub
Private Sub NumberBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackslashBtn.Click, OneBtn.Click, TwoBtn.Click, ThreeBtn.Click, FourBtn.Click, FiveBtn.Click, SixBtn.Click, SevenBtn.Click, EightBtn.Click, NineBtn.Click, ZeroBtn.Click,
TabBtn.Click, PlusBtn.Click, MinorBtn.Click, MinusBtn.Click, DotBtn.Click, CommaBtn.Click
Dim KeyButton As Button = e.Source
Dim UpperCaseKey As String = String.Empty
Dim LowerCaseKey As String = String.Empty
If ReturnKeyNumber(KeyButton, UpperCaseKey, LowerCaseKey) Then
NumberClick(UpperCaseKey(0), LowerCaseKey(0))
End If
End Sub
Private Function ReturnKeyCharacter(KeyButton As Button, ByRef UpperCaseKey As String, ByRef LowerCaseKey As String) As Boolean
Select Case KeyButton.Name
Case qBtn.Name
UpperCaseKey = "Q"
LowerCaseKey = "q"
Return True
Case wBtn.Name
UpperCaseKey = "W"
LowerCaseKey = "w"
Return True
Case eBtn.Name
UpperCaseKey = "E"
LowerCaseKey = "e"
Return True
Case rBtn.Name
UpperCaseKey = "R"
LowerCaseKey = "r"
Return True
Case tBtn.Name
UpperCaseKey = "T"
LowerCaseKey = "t"
Return True
Case yBtn.Name
UpperCaseKey = "Y"
LowerCaseKey = "y"
Return True
Case uBtn.Name
UpperCaseKey = "U"
LowerCaseKey = "u"
Return True
Case iBtn.Name
UpperCaseKey = "I"
LowerCaseKey = "i"
Return True
Case oBtn.Name
UpperCaseKey = "O"
LowerCaseKey = "o"
Return True
Case pBtn.Name
UpperCaseKey = "P"
LowerCaseKey = "p"
Return True
Case aBtn.Name
UpperCaseKey = "A"
LowerCaseKey = "a"
Return True
Case sBtn.Name
UpperCaseKey = "S"
LowerCaseKey = "s"
Return True
Case dBtn.Name
UpperCaseKey = "D"
LowerCaseKey = "d"
Return True
Case fBtn.Name
UpperCaseKey = "F"
LowerCaseKey = "f"
Return True
Case gBtn.Name
UpperCaseKey = "G"
LowerCaseKey = "g"
Return True
Case hBtn.Name
UpperCaseKey = "H"
LowerCaseKey = "h"
Return True
Case jBtn.Name
UpperCaseKey = "J"
LowerCaseKey = "j"
Return True
Case kBtn.Name
UpperCaseKey = "K"
LowerCaseKey = "k"
Return True
Case lBtn.Name
UpperCaseKey = "L"
LowerCaseKey = "l"
Return True
Case zBtn.Name
UpperCaseKey = "Z"
LowerCaseKey = "z"
Return True
Case xBtn.Name
UpperCaseKey = "X"
LowerCaseKey = "x"
Return True
Case cBtn.Name
UpperCaseKey = "C"
LowerCaseKey = "c"
Return True
Case vBtn.Name
UpperCaseKey = "V"
LowerCaseKey = "v"
Return True
Case bBtn.Name
UpperCaseKey = "B"
LowerCaseKey = "b"
Return True
Case nBtn.Name
UpperCaseKey = "N"
LowerCaseKey = "n"
Return True
Case mBtn.Name
UpperCaseKey = "M"
LowerCaseKey = "m"
Return True
End Select
Return False
End Function
Private Function ReturnKeyNumber(KeyButton As Button, ByRef UpperCaseKey As String, ByRef LowerCaseKey As String) As Boolean
Select Case KeyButton.Name
Case BackslashBtn.Name
UpperCaseKey = "|"
LowerCaseKey = "\"
Return True
Case OneBtn.Name
UpperCaseKey = "!"
LowerCaseKey = "1"
Return True
Case TwoBtn.Name
UpperCaseKey = """"
LowerCaseKey = "2"
Return True
Case ThreeBtn.Name
UpperCaseKey = "£"
LowerCaseKey = "3"
Return True
Case FourBtn.Name
UpperCaseKey = "$"
LowerCaseKey = "4"
Return True
Case FiveBtn.Name
UpperCaseKey = "%"
LowerCaseKey = "5"
Return True
Case SixBtn.Name
UpperCaseKey = "&"
LowerCaseKey = "6"
Return True
Case SevenBtn.Name
UpperCaseKey = "/"
LowerCaseKey = "7"
Return True
Case EightBtn.Name
UpperCaseKey = "("
LowerCaseKey = "8"
Return True
Case NineBtn.Name
UpperCaseKey = ")"
LowerCaseKey = "9"
Return True
Case TabBtn.Name
UpperCaseKey = " "
LowerCaseKey = " "
Return True
Case ZeroBtn.Name
UpperCaseKey = "="
LowerCaseKey = "0"
Return True
Case PlusBtn.Name
UpperCaseKey = "*"
LowerCaseKey = "+"
Return True
Case MinorBtn.Name
UpperCaseKey = ">"
LowerCaseKey = "<"
Return True
Case MinusBtn.Name
UpperCaseKey = "_"
LowerCaseKey = "-"
Return True
Case DotBtn.Name
UpperCaseKey = ":"
LowerCaseKey = "."
Return True
Case CommaBtn.Name
UpperCaseKey = ";"
LowerCaseKey = ","
Return True
End Select
Return False
End Function
Private Sub BackspaceBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackspaceBtn.Click
m_SourceTxBx.Focus()
Dim eventArgs As New KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Back) With {
.RoutedEvent = Keyboard.KeyDownEvent
}
InputManager.Current.ProcessInput(eventArgs)
'ValueTxBx.Text = DirectCast(m_SourceTxBx, TextBox).Text
End Sub
Private Sub SpaceBtn_Click(sender As Object, e As RoutedEventArgs) Handles SpaceBtn.Click
m_SourceTxBx.Focus()
Dim eventArgs As New KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Space) With {
.RoutedEvent = Keyboard.KeyDownEvent
}
InputManager.Current.ProcessInput(eventArgs)
'ValueTxBx.Text = DirectCast(m_SourceTxBx, TextBox).Text
End Sub
Private Sub CancBtn_Click(sender As Object, e As RoutedEventArgs) Handles CancBtn.Click
m_SourceTxBx.Focus()
Dim eventArgs As New KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Delete) With {
.RoutedEvent = Keyboard.KeyDownEvent
}
InputManager.Current.ProcessInput(eventArgs)
'ValueTxBx.Text = DirectCast(m_SourceTxBx, TextBox).Text
End Sub
Private Sub ClearBtn_Click(sender As Object, e As RoutedEventArgs) Handles ClearBtn.Click
DirectCast(m_SourceTxBx, TextBox).Text = String.Empty
m_SourceTxBx.Focus()
'ValueTxBx.Text = DirectCast(m_SourceTxBx, TextBox).Text
End Sub
Private Sub EnterBtn_Click(sender As Object, e As RoutedEventArgs) Handles Enter1Btn.Click, Enter2Btn.Click
EnterCmd(sender, e)
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
ExitCmd(sender, e)
End Sub
Friend Sub EnterCmd(sender As Object, e As EventArgs)
If Not bIsActive Then Return
bIsActive = False
Keyboard.ClearFocus()
RaiseEvent EgtClosed(sender, e)
End Sub
Friend Sub ExitCmd(sender As Object, e As EventArgs)
If Not bIsActive Then Return
DirectCast(m_SourceTxBx, TextBox).Text = m_sOrigTxt
bIsActive = False
Keyboard.ClearFocus()
RaiseEvent EgtClosed(sender, e)
End Sub
#End Region
#Region "Funzioni aggiuntive non attive"
' '' Codice che permette di mantenere le proporzioni(Aspect Ratio) della finestra dopo l'ingrandimento o il rimpicciolimento della stessa
''Public Const ASPECTRATIO As Double = 12 / 5
''Protected Overrides Sub OnSourceInitialized(e As EventArgs)
'' MyBase.OnSourceInitialized(e)
'' Dim source As HwndSource = TryCast(HwndSource.FromVisual(Me), HwndSource)
'' If source IsNot Nothing Then
'' source.AddHook(New HwndSourceHook(AddressOf WinProc))
'' End If
''End Sub
''Public Const WM_EXITSIZEMOVE As Integer = &H232
''Private Function WinProc(hwnd As IntPtr, msg As Int32, wParam As IntPtr, lParam As IntPtr, ByRef handled As [Boolean]) As IntPtr
'' Dim result As IntPtr = IntPtr.Zero
'' Select Case msg
'' Case WM_EXITSIZEMOVE
'' If True Then
'' Me.Width = Me.Height * ASPECTRATIO
'' Exit Select
'' End If
'' End Select
'' Return result
''End Function
#End Region
End Class