using DevComponents.DotNetBar.Keyboard; using POSV.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace POSV.Component { [ToolboxItem(true)] public class LoginKeyboardControl: KeyboardControl { public LoginKeyboardControl() { this.Keyboard = CreateSimpleKeyboard(); VirtualKeyboardColorTable _colorTableCustom = new VirtualKeyboardColorTable(); _colorTableCustom.BackgroundColor = Color.White; _colorTableCustom.KeysColor = ColorTranslator.FromHtml("#ececea"); _colorTableCustom.PressedKeysColor = Color.LightGray; _colorTableCustom.TextColor = Color.White; //ColorTranslator.FromHtml("#666666"); _colorTableCustom.DownKeysColor = Color.LightGray; _colorTableCustom.DownTextColor = Color.White; _colorTableCustom.TopBarTextColor = Color.Black; _colorTableCustom.ToggleTextColor = Color.DarkRed; this.ColorTable = _colorTableCustom; this.Font = Constant.NORMAL_FONT; this.IsTopBarVisible = false; this.Size = new Size(350, 330); this.SendingKey += OnSendingKey; } private void OnSendingKey(object sender, KeyboardKeyCancelEventArgs e) { var key = e.Key; switch (key) { case "清除": { InputSimulatorUtils.SendClear(); e.Cancel = true; } break; case "{BACKSPACE}": { InputSimulatorUtils.SendKey(KeyCodes.Map["back"]); e.Cancel = true; } break; default: { if (KeyCodes.Map.ContainsKey(key)) { InputSimulatorUtils.SendKey(KeyCodes.Map[key]); e.Cancel = true; } } break; } } private Keyboard CreateSimpleKeyboard() { Keyboard keyboard = new Keyboard(); var line = new LinearKeyboardLayout(); line.AddKey("7"); line.AddKey("8"); line.AddKey("9"); line.AddLine(); line.AddKey("4"); line.AddKey("5"); line.AddKey("6"); line.AddLine(); line.AddKey("1"); line.AddKey("2"); line.AddKey("3"); line.AddLine(); line.AddKey("0"); line.AddKey("清除", info: null); line.AddKey("Backspace", info: "{BACKSPACE}"); keyboard.Layouts.Add(line); return keyboard; } } }