public void SetLayout(KeyboardLayout layout)
        {
            currentLayout = layout.Clone();

            for (var keyboardPosition = 0; keyboardPosition < keyboardButtons.Length; keyboardPosition++)
            {
                keyboardButtons[keyboardPosition].Tag = (Int16)keyboardPosition;
                keyboardButtons[keyboardPosition].Click += KeyboardButtonClick;
                UpdateText(keyboardPosition);
            }
        }
 void BetterSampleFound(KeyboardLayout layout, double score)
 {
     ConsoleTextBox.AppendText(Environment.NewLine +
         "Better sample found! Layout is:"
         + Environment.NewLine + MainControl.PrintLayoutWithScore(layout, score));
 }
示例#3
0
		private void CreateConversionArray (KeyboardLayouts layouts, KeyboardLayout layout)
		{
			XEvent e2 = new XEvent ();
			uint keysym = 0;
			int [] ckey = new int [] { 0, 0, 0, 0 };

			e2.KeyEvent.display = display;
			e2.KeyEvent.state = 0;

			for (int keyc = min_keycode; keyc <= max_keycode; keyc++) {
				int vkey = 0;
				int scan = 0;

				e2.KeyEvent.keycode = keyc;
				XKeySym t;

				XLookupStatus status;
				LookupString (ref e2, 0, out t, out status);

				keysym = (uint) t;
				if (keysym != 0) {
					if ((keysym >> 8) == 0xFF) {
						vkey = nonchar_key_vkey [keysym & 0xFF];
						scan = nonchar_key_scan [keysym & 0xFF];
						// Set extended bit
						if ((scan & 0x100) != 0)
							vkey |= 0x100;
					} else if (keysym == 0x20) { // spacebar
						vkey = (int) VirtualKeys.VK_SPACE;
						scan = 0x39;
					} else {
						// Search layout dependent scancodes
						int maxlen = 0;
						int maxval = -1;;
						
						for (int i = 0; i < syms; i++) {
							keysym = XKeycodeToKeysym (display, keyc, i);
							if ((keysym < 0x800) && (keysym != ' '))
								ckey [i] = (sbyte) (keysym & 0xFF);
							else
								ckey [i] = (sbyte) MapDeadKeySym ((int) keysym);
						}
						
						for (int keyn = 0; keyn < layout.Keys.Length; keyn++) {
							int ml = Math.Min (layout.Keys [keyn].Length, 4);
							int ok = -1;
							for (int i = 0; (ok != 0) && (i < ml); i++) {
								sbyte ck = (sbyte) layout.Keys [keyn][i];
								if (ck != ckey [i])
									ok = 0;
								if ((ok != 0) || (i > maxlen)) {
									maxlen = i;
									maxval = keyn;
								}
								if (ok != 0)
									break;
							}
						}
						if (maxval >= 0) {
							if (maxval < layouts.scan_table [(int) layout.ScanIndex].Length)
								scan = layouts.scan_table [(int) layout.ScanIndex][maxval];
							if (maxval < layouts.vkey_table [(int) layout.VKeyIndex].Length)
								vkey = layouts.vkey_table [(int) layout.VKeyIndex][maxval];
						}
					}
				}
				keyc2vkey [e2.KeyEvent.keycode] = vkey;
				keyc2scan [e2.KeyEvent.keycode] = scan;
			}
			
			
		}
示例#4
0
 /// <summary>
 /// Creates a new instance and initializes it with provided values.
 /// </summary>
 /// <param name="size">The size of the background area.</param>
 /// <param name="font">The font of the control.</param>
 /// <param name="layout">The current KeyboardLayout that will be rendered in this frame.</param>
 public BeginFrameRendererEventArgs(Graphics graphics, Rectangle clipRectangle, Rectangle bounds, Font font, KeyboardLayout layout)
 {
     Graphics = graphics;
     ClipRectangle = clipRectangle;
     Bounds = bounds;
     Font = font;
     Layout = layout;
 }
 public static string PrintLayoutWithScore(KeyboardLayout layout, double score)
 {
     return (layout.Print().ToString() + Environment.NewLine
         + "Score is: " + -score + Environment.NewLine);
 }