| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- namespace Muchinfo.WPF.Controls.Keyboard
- {
- /// <summary>
- /// Class TouchScreenKeyboard
- /// </summary>
- public class TouchScreenKeyboard : Window
- {
- #region Fields
- public static readonly DependencyProperty TouchScreenKeyboardProperty =
- DependencyProperty.RegisterAttached("TouchScreenKeyboard", typeof(bool), typeof(TouchScreenKeyboard), new UIPropertyMetadata(default(bool), TouchScreenKeyboardPropertyChanged));
- /// <summary>
- /// The CMD0
- /// </summary>
- public static RoutedUICommand Cmd0 = new RoutedUICommand();
- public static RoutedUICommand Cmd1 = new RoutedUICommand();
- public static RoutedUICommand Cmd2 = new RoutedUICommand();
- public static RoutedUICommand Cmd3 = new RoutedUICommand();
- public static RoutedUICommand Cmd4 = new RoutedUICommand();
- public static RoutedUICommand Cmd5 = new RoutedUICommand();
- public static RoutedUICommand Cmd6 = new RoutedUICommand();
- public static RoutedUICommand Cmd7 = new RoutedUICommand();
- public static RoutedUICommand Cmd8 = new RoutedUICommand();
- public static RoutedUICommand Cmd9 = new RoutedUICommand();
- public static RoutedUICommand CmdA = new RoutedUICommand();
- public static RoutedUICommand CmdB = new RoutedUICommand();
- public static RoutedUICommand CmdBackspace = new RoutedUICommand();
- public static RoutedUICommand CmdC = new RoutedUICommand();
- public static RoutedUICommand CmdCapsLock = new RoutedUICommand();
- public static RoutedUICommand CmdClear = new RoutedUICommand();
- public static RoutedUICommand CmdColon = new RoutedUICommand();
- public static RoutedUICommand CmdD = new RoutedUICommand();
- public static RoutedUICommand CmdDoubleInvertedComma = new RoutedUICommand();
- public static RoutedUICommand CmdE = new RoutedUICommand();
- public static RoutedUICommand CmdEndCrultBrace = new RoutedUICommand();
- public static RoutedUICommand CmdEnter = new RoutedUICommand();
- public static RoutedUICommand CmdF = new RoutedUICommand();
- public static RoutedUICommand CmdG = new RoutedUICommand();
- public static RoutedUICommand CmdGreaterThan = new RoutedUICommand();
- public static RoutedUICommand CmdH = new RoutedUICommand();
- public static RoutedUICommand CmdI = new RoutedUICommand();
- public static RoutedUICommand CmdJ = new RoutedUICommand();
- public static RoutedUICommand CmdK = new RoutedUICommand();
- public static RoutedUICommand CmdL = new RoutedUICommand();
- public static RoutedUICommand CmdLessThan = new RoutedUICommand();
- public static RoutedUICommand CmdM = new RoutedUICommand();
- public static RoutedUICommand CmdMinus = new RoutedUICommand();
- public static RoutedUICommand CmdN = new RoutedUICommand();
- public static RoutedUICommand CmdO = new RoutedUICommand();
- public static RoutedUICommand CmdOpenCrulyBrace = new RoutedUICommand();
- public static RoutedUICommand CmdOR = new RoutedUICommand();
- public static RoutedUICommand CmdP = new RoutedUICommand();
- public static RoutedUICommand CmdPlus = new RoutedUICommand();
- public static RoutedUICommand CmdQ = new RoutedUICommand();
- public static RoutedUICommand CmdQuestion = new RoutedUICommand();
- public static RoutedUICommand CmdR = new RoutedUICommand();
- public static RoutedUICommand CmdS = new RoutedUICommand();
- public static RoutedUICommand CmdShift = new RoutedUICommand();
- public static RoutedUICommand CmdSpaceBar = new RoutedUICommand();
- public static RoutedUICommand CmdT = new RoutedUICommand();
- public static RoutedUICommand CmdTab = new RoutedUICommand();
- public static RoutedUICommand CmdTlide = new RoutedUICommand();
- public static RoutedUICommand CmdU = new RoutedUICommand();
- public static RoutedUICommand CmdV = new RoutedUICommand();
- public static RoutedUICommand Cmdw = new RoutedUICommand();
- public static RoutedUICommand CmdX = new RoutedUICommand();
- public static RoutedUICommand CmdY = new RoutedUICommand();
- public static RoutedUICommand CmdZ = new RoutedUICommand();
- private static bool _capsLockFlag;
- private static Control _currentControl;
- private const double HeightTouchKeyboard = 211d;
- private static Window _instanceObject;
- private static Brush _previousTextBoxBackgroundBrush = null;
- private static Brush _previousTextBoxBorderBrush = null;
- private static Thickness _previousTextBoxBorderThickness;
- private static bool _shiftFlag;
-
- private static double _widthTouchKeyboard = 540;
- #endregion Fields
- #region Constructors
- /// <summary>
- /// Initializes static members of the <see cref="TouchScreenKeyboard"/> class.
- /// </summary>
- static TouchScreenKeyboard()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchScreenKeyboard), new FrameworkPropertyMetadata(typeof(TouchScreenKeyboard)));
- SetCommandBinding();
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="TouchScreenKeyboard"/> class.
- /// </summary>
- public TouchScreenKeyboard()
- {
- this.Width = WidthTouchKeyboard;
- this.Height = HeightTouchKeyboard;
- }
- #endregion Constructors
- #region Properties
- public static string TouchScreenText
- {
- get
- {
- if (_currentControl is TextBox)
- {
- return ((TextBox)_currentControl).Text;
- }
- else if (_currentControl is PasswordBox)
- {
- return ((PasswordBox)_currentControl).Password;
- }
- else return "";
- }
- set
- {
- if (_currentControl is TextBox)
- {
- ((TextBox)_currentControl).Text = value;
- }
- else if (_currentControl is PasswordBox)
- {
- ((PasswordBox)_currentControl).Password = value;
- }
- }
- }
- public static double WidthTouchKeyboard
- {
- get { return _widthTouchKeyboard; }
- set { _widthTouchKeyboard = value; }
- }
- protected static bool CapsLockFlag
- {
- get { return TouchScreenKeyboard._capsLockFlag; }
- set { TouchScreenKeyboard._capsLockFlag = value; }
- }
- protected static bool ShiftFlag
- {
- get { return _shiftFlag; }
- set { _shiftFlag = value; }
- }
- #endregion Properties
- #region Methods
- public static void Dispose()
- {
- _currentControl = null;
- _previousTextBoxBackgroundBrush = null;
- _previousTextBoxBorderBrush = null;
- if (_instanceObject != null)
- {
- _instanceObject.Close();
- _instanceObject = null;
- }
- }
- public static bool GetTouchScreenKeyboard(DependencyObject obj)
- {
- return (bool)obj.GetValue(TouchScreenKeyboardProperty);
- }
- public static void SetTouchScreenKeyboard(DependencyObject obj, bool value)
- {
- obj.SetValue(TouchScreenKeyboardProperty, value);
- }
- private static void AddKeyBoardINput(char input)
- {
- if (CapsLockFlag)
- {
- if (ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += char.ToLower(input).ToString();
- ShiftFlag = false;
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += char.ToUpper(input).ToString();
- }
- }
- else
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += char.ToLower(input).ToString();
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += char.ToUpper(input).ToString();
- ShiftFlag = false;
- }
- }
- }
- static void OnGotFocus(object sender, RoutedEventArgs e)
- {
- Control host = sender as Control;
- _previousTextBoxBackgroundBrush = host.Background;
- _previousTextBoxBorderBrush = host.BorderBrush;
- _previousTextBoxBorderThickness = host.BorderThickness;
- host.Background = Brushes.Yellow;
- host.BorderBrush = Brushes.Red;
- host.BorderThickness = new Thickness(4);
- _currentControl = host;
- if (_instanceObject == null)
- {
- FrameworkElement ct = host;
- while (true)
- {
- if (ct is Window)
- {
- ((Window)ct).Activated += new EventHandler(TouchScreenKeyboard_Activated);
- ((Window)ct).Deactivated += new EventHandler(TouchScreenKeyboard_Deactivated);
- break;
- }
- ct = (FrameworkElement)ct.Parent;
- }
- _instanceObject = new TouchScreenKeyboard();
- _instanceObject.AllowsTransparency = true;
- _instanceObject.WindowStyle = WindowStyle.None;
- _instanceObject.ShowInTaskbar = false;
- _instanceObject.ShowInTaskbar = false;
- _instanceObject.Topmost = true;
- SyncChild();
- // host.LayoutUpdated += new EventHandler(tb_LayoutUpdated);
- }
- }
- static void OnLostFocus(object sender, RoutedEventArgs e)
- {
- Control host = sender as Control;
- host.Background = _previousTextBoxBackgroundBrush;
- host.BorderBrush = _previousTextBoxBorderBrush;
- host.BorderThickness = _previousTextBoxBorderThickness;
- if (_instanceObject != null)
- {
- _instanceObject.Close();
- _instanceObject = null;
- }
- SetTouchScreenKeyboard(host, false);
- //设置只有使用按键时才打开键盘。
- host.GotFocus -= OnGotFocus;
- host.LostFocus -= OnLostFocus;
- }
- private static void OnUnloaded(object sender, RoutedEventArgs e)
- {
- if (_instanceObject != null)
- {
- _instanceObject.Close();
- }
- }
- static void RunCommand(object sender, ExecutedRoutedEventArgs e)
- {
- if (e.Command == CmdTlide) //First Row
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "`";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "~";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd1)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "1";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "!";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd2)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "2";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "@";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd3)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "3";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "#";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd4)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "4";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "$";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd5)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "5";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "%";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd6)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "6";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "^";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd7)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "7";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "&";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd8)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "8";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "*";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd9)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "9";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "(";
- ShiftFlag = false;
- }
- }
- else if (e.Command == Cmd0)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "0";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += ")";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdMinus)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "-";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "_";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdPlus)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "=";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "+";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdBackspace)
- {
- if (!string.IsNullOrEmpty(TouchScreenKeyboard.TouchScreenText))
- {
- TouchScreenKeyboard.TouchScreenText = TouchScreenKeyboard.TouchScreenText.Substring(0, TouchScreenKeyboard.TouchScreenText.Length - 1);
- }
- }
- else if (e.Command == CmdTab) //Second Row
- {
- TouchScreenKeyboard.TouchScreenText += " ";
- }
- else if (e.Command == CmdQ)
- {
- AddKeyBoardINput('Q');
- }
- else if (e.Command == Cmdw)
- {
- AddKeyBoardINput('w');
- }
- else if (e.Command == CmdE)
- {
- AddKeyBoardINput('E');
- }
- else if (e.Command == CmdR)
- {
- AddKeyBoardINput('R');
- }
- else if (e.Command == CmdT)
- {
- AddKeyBoardINput('T');
- }
- else if (e.Command == CmdY)
- {
- AddKeyBoardINput('Y');
- }
- else if (e.Command == CmdU)
- {
- AddKeyBoardINput('U');
- }
- else if (e.Command == CmdI)
- {
- AddKeyBoardINput('I');
- }
- else if (e.Command == CmdO)
- {
- AddKeyBoardINput('O');
- }
- else if (e.Command == CmdP)
- {
- AddKeyBoardINput('P');
- }
- else if (e.Command == CmdOpenCrulyBrace)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "[";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "{";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdEndCrultBrace)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "]";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "}";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdOR)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += @"\";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "|";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdCapsLock) ///Third ROw
- {
- if (!CapsLockFlag)
- {
- CapsLockFlag = true;
- }
- else
- {
- CapsLockFlag = false;
- }
- }
- else if (e.Command == CmdA)
- {
- AddKeyBoardINput('A');
- }
- else if (e.Command == CmdS)
- {
- AddKeyBoardINput('S');
- }
- else if (e.Command == CmdD)
- {
- AddKeyBoardINput('D');
- }
- else if (e.Command == CmdF)
- {
- AddKeyBoardINput('F');
- }
- else if (e.Command == CmdG)
- {
- AddKeyBoardINput('G');
- }
- else if (e.Command == CmdH)
- {
- AddKeyBoardINput('H');
- }
- else if (e.Command == CmdJ)
- {
- AddKeyBoardINput('J');
- }
- else if (e.Command == CmdK)
- {
- AddKeyBoardINput('K');
- }
- else if (e.Command == CmdL)
- {
- AddKeyBoardINput('L');
- }
- else if (e.Command == CmdColon)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += ";";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += ":";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdDoubleInvertedComma)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "'";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += Char.ConvertFromUtf32(34);
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdEnter)
- {
- if (_instanceObject != null)
- {
- _instanceObject.Close();
- _instanceObject = null;
- }
- _currentControl.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
- }
- else if (e.Command == CmdShift) //Fourth Row
- {
- ShiftFlag = true; ;
- }
- else if (e.Command == CmdZ)
- {
- AddKeyBoardINput('Z');
- }
- else if (e.Command == CmdX)
- {
- AddKeyBoardINput('X');
- }
- else if (e.Command == CmdC)
- {
- AddKeyBoardINput('C');
- }
- else if (e.Command == CmdV)
- {
- AddKeyBoardINput('V');
- }
- else if (e.Command == CmdB)
- {
- AddKeyBoardINput('B');
- }
- else if (e.Command == CmdN)
- {
- AddKeyBoardINput('N');
- }
- else if (e.Command == CmdM)
- {
- AddKeyBoardINput('M');
- }
- else if (e.Command == CmdLessThan)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += ",";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "<";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdGreaterThan)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += ".";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += ">";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdQuestion)
- {
- if (!ShiftFlag)
- {
- TouchScreenKeyboard.TouchScreenText += "/";
- }
- else
- {
- TouchScreenKeyboard.TouchScreenText += "?";
- ShiftFlag = false;
- }
- }
- else if (e.Command == CmdSpaceBar)//Last row
- {
- TouchScreenKeyboard.TouchScreenText += " ";
- }
- else if (e.Command == CmdClear)//Last row
- {
- TouchScreenKeyboard.TouchScreenText = "";
- }
- }
- private static void SetCommandBinding()
- {
- CommandBinding CbTlide = new CommandBinding(CmdTlide, RunCommand);
- CommandBinding Cb1 = new CommandBinding(Cmd1, RunCommand);
- CommandBinding Cb2 = new CommandBinding(Cmd2, RunCommand);
- CommandBinding Cb3 = new CommandBinding(Cmd3, RunCommand);
- CommandBinding Cb4 = new CommandBinding(Cmd4, RunCommand);
- CommandBinding Cb5 = new CommandBinding(Cmd5, RunCommand);
- CommandBinding Cb6 = new CommandBinding(Cmd6, RunCommand);
- CommandBinding Cb7 = new CommandBinding(Cmd7, RunCommand);
- CommandBinding Cb8 = new CommandBinding(Cmd8, RunCommand);
- CommandBinding Cb9 = new CommandBinding(Cmd9, RunCommand);
- CommandBinding Cb0 = new CommandBinding(Cmd0, RunCommand);
- CommandBinding CbMinus = new CommandBinding(CmdMinus, RunCommand);
- CommandBinding CbPlus = new CommandBinding(CmdPlus, RunCommand);
- CommandBinding CbBackspace = new CommandBinding(CmdBackspace, RunCommand);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbTlide);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb1);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb2);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb3);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb4);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb5);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb6);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb7);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb8);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb9);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cb0);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbMinus);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbPlus);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbBackspace);
- CommandBinding CbTab = new CommandBinding(CmdTab, RunCommand);
- CommandBinding CbQ = new CommandBinding(CmdQ, RunCommand);
- CommandBinding Cbw = new CommandBinding(Cmdw, RunCommand);
- CommandBinding CbE = new CommandBinding(CmdE, RunCommand);
- CommandBinding CbR = new CommandBinding(CmdR, RunCommand);
- CommandBinding CbT = new CommandBinding(CmdT, RunCommand);
- CommandBinding CbY = new CommandBinding(CmdY, RunCommand);
- CommandBinding CbU = new CommandBinding(CmdU, RunCommand);
- CommandBinding CbI = new CommandBinding(CmdI, RunCommand);
- CommandBinding Cbo = new CommandBinding(CmdO, RunCommand);
- CommandBinding CbP = new CommandBinding(CmdP, RunCommand);
- CommandBinding CbOpenCrulyBrace = new CommandBinding(CmdOpenCrulyBrace, RunCommand);
- CommandBinding CbEndCrultBrace = new CommandBinding(CmdEndCrultBrace, RunCommand);
- CommandBinding CbOR = new CommandBinding(CmdOR, RunCommand);
- CommandBinding CbCapsLock = new CommandBinding(CmdCapsLock, RunCommand);
- CommandBinding CbA = new CommandBinding(CmdA, RunCommand);
- CommandBinding CbS = new CommandBinding(CmdS, RunCommand);
- CommandBinding CbD = new CommandBinding(CmdD, RunCommand);
- CommandBinding CbF = new CommandBinding(CmdF, RunCommand);
- CommandBinding CbG = new CommandBinding(CmdG, RunCommand);
- CommandBinding CbH = new CommandBinding(CmdH, RunCommand);
- CommandBinding CbJ = new CommandBinding(CmdJ, RunCommand);
- CommandBinding CbK = new CommandBinding(CmdK, RunCommand);
- CommandBinding CbL = new CommandBinding(CmdL, RunCommand);
- CommandBinding CbColon = new CommandBinding(CmdColon, RunCommand);
- CommandBinding CbDoubleInvertedComma = new CommandBinding(CmdDoubleInvertedComma, RunCommand);
- CommandBinding CbEnter = new CommandBinding(CmdEnter, RunCommand);
- CommandBinding CbShift = new CommandBinding(CmdShift, RunCommand);
- CommandBinding CbZ = new CommandBinding(CmdZ, RunCommand);
- CommandBinding CbX = new CommandBinding(CmdX, RunCommand);
- CommandBinding CbC = new CommandBinding(CmdC, RunCommand);
- CommandBinding CbV = new CommandBinding(CmdV, RunCommand);
- CommandBinding CbB = new CommandBinding(CmdB, RunCommand);
- CommandBinding CbN = new CommandBinding(CmdN, RunCommand);
- CommandBinding CbM = new CommandBinding(CmdM, RunCommand);
- CommandBinding CbGreaterThan = new CommandBinding(CmdGreaterThan, RunCommand);
- CommandBinding CbLessThan = new CommandBinding(CmdLessThan, RunCommand);
- CommandBinding CbQuestion = new CommandBinding(CmdQuestion, RunCommand);
- CommandBinding CbSpaceBar = new CommandBinding(CmdSpaceBar, RunCommand);
- CommandBinding CbClear = new CommandBinding(CmdClear, RunCommand);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbTab);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbQ);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cbw);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbE);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbR);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbT);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbY);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbU);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbI);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), Cbo);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbP);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbOpenCrulyBrace);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbEndCrultBrace);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbOR);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbCapsLock);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbA);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbS);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbD);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbF);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbG);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbH);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbJ);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbK);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbL);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbColon);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbDoubleInvertedComma);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbEnter);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbShift);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbZ);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbX);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbC);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbV);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbB);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbN);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbM);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbGreaterThan);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbLessThan);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbQuestion);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbSpaceBar);
- CommandManager.RegisterClassCommandBinding(typeof(TouchScreenKeyboard), CbClear);
- }
- /// <summary>
- /// Syncs the child.
- /// </summary>
- private static void SyncChild()
- {
- if (_currentControl != null && _instanceObject != null)
- {
- Point virtualpoint = new Point(0, _currentControl.ActualHeight + 3);
- Point Actualpoint = _currentControl.PointToScreen(virtualpoint);
- if (WidthTouchKeyboard + Actualpoint.X > SystemParameters.VirtualScreenWidth)
- {
- double difference = WidthTouchKeyboard + Actualpoint.X - SystemParameters.VirtualScreenWidth;
- _instanceObject.Left = Actualpoint.X - difference;
- }
- else if (!(Actualpoint.X > 1))
- {
- _instanceObject.Left = 1;
- }
- else
- {
- _instanceObject.Left = Actualpoint.X;
- }
- _instanceObject.Top = Actualpoint.Y;
- _instanceObject.Show();
- }
- }
- static void TouchScreenKeyboardPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
- {
- FrameworkElement host = sender as FrameworkElement;
- if (host != null)
- {
- host.GotFocus += new RoutedEventHandler(OnGotFocus);
- host.Unloaded += OnUnloaded;
- host.LostFocus += new RoutedEventHandler(OnLostFocus);
- }
- }
- static void TouchScreenKeyboard_Activated(object sender, EventArgs e)
- {
- if (_instanceObject != null)
- {
- _instanceObject.Topmost = true;
- }
- }
- static void TouchScreenKeyboard_Deactivated(object sender, EventArgs e)
- {
- if (_instanceObject != null)
- {
- _instanceObject.Topmost = false;
- }
- }
- #endregion Methods
- }
- }
|