public static int[] GetRowTerminators(KeyboardLayoutType layout) { // First five rows are the hashes of the terminator keys // (Backspace, Enter, R Shift, R Ctrl for Euro layout) switch (layout) { default: // includes case KeyboardLayoutType.US: return(new [] { KeyHasher.GetHashFromKeyData(14, 0), KeyHasher.GetHashFromKeyData(43, 0), KeyHasher.GetHashFromKeyData(28, 0), KeyHasher.GetHashFromKeyData(54, 224), KeyHasher.GetHashFromKeyData(29, 224) }); case KeyboardLayoutType.Punjabi: case KeyboardLayoutType.European: return(new [] { KeyHasher.GetHashFromKeyData(14, 0), KeyHasher.GetHashFromKeyData(28, 0), 99999, KeyHasher.GetHashFromKeyData(54, 224), KeyHasher.GetHashFromKeyData(29, 224) }); } }
public static int[] GetRowTerminators(KeyboardLayoutType layout) { // First five rows are the hashes of the terminator keys // (Backspace, Enter, R Shift, R Ctrl for Euro layout) switch (layout) { default: // includes case KeyboardLayoutType.US: return new [] { KeyHasher.GetHashFromKeyData(14, 0), KeyHasher.GetHashFromKeyData(43, 0), KeyHasher.GetHashFromKeyData(28, 0), KeyHasher.GetHashFromKeyData(54, 224), KeyHasher.GetHashFromKeyData(29, 224) }; case KeyboardLayoutType.Punjabi: case KeyboardLayoutType.European: return new [] { KeyHasher.GetHashFromKeyData(14, 0), KeyHasher.GetHashFromKeyData(28, 0), 99999, KeyHasher.GetHashFromKeyData(54, 224), KeyHasher.GetHashFromKeyData(29, 224) }; } }
public static PhysicalKeyboardLayout GetPhysicalLayout(KeyboardLayoutType layout, bool isMacKeyboard) { var existingInstance = cachedInstances.SingleOrDefault(l => l.layout == layout && l.isMacKeyboard == isMacKeyboard); if (existingInstance != null) { return existingInstance; } PhysicalKeyboardLayout nl = new PhysicalKeyboardLayout { layout = layout, isMacKeyboard = isMacKeyboard }; nl.Populate(); cachedInstances.Add(nl); return nl; }
public static PhysicalKeyboardLayout GetPhysicalLayout(KeyboardLayoutType layout, bool isMacKeyboard) { var existingInstance = cachedInstances.SingleOrDefault(l => l.layout == layout && l.isMacKeyboard == isMacKeyboard); if (existingInstance != null) { return(existingInstance); } PhysicalKeyboardLayout nl = new PhysicalKeyboardLayout { layout = layout, isMacKeyboard = isMacKeyboard }; nl.Populate(); cachedInstances.Add(nl); return(nl); }
public static void SwitchKeyboardLayout(KeyboardLayoutType layout) { KeyboardLayout = layout; }
void Redraw() { // Can be errors during slideshow, so if we get one then cancel it. try { NativeMethods.LockWindowUpdate(this.Handle); } catch (ObjectDisposedException) { _cancelSlideshow = true; return; } FormToolTip.RemoveAll(); FormToolTip.SetToolTip(KeyboardListCombo, "Change the displayed keyboard"); // Need to make sure these dispose as they have bitmap resources, so not using Controls.Clear() // as it didn't release them properly.. for (int i = this.KeyboardPanel.Controls.Count - 1; i >= 0; i--) { this.KeyboardPanel.Controls[i].Dispose(); } // Start in the top left corner.. int left = _paddingWidth; int top = _paddingWidth + this.menu.Height; int numpadleft = 0; int navleft = 0; float mainkeywidth = (14.5F * (_keySize + _paddingWidth)) + (_paddingWidth * 2); float navwidth = ((_keySize + _paddingWidth) * 3); // Work out how far back the number pad extends if (_hasNumberPad) { numpadleft = (int)Math.Round(this.ClientSize.Width - (((_keySize + _paddingWidth) * 4.2)), 0); // Nav controls are three wide and they have to fit midway in the // gap between the end of the main body and the numberpad. navleft = (int)Math.Round((mainkeywidth + ((numpadleft - mainkeywidth - navwidth) / 2)), 0); } else { // Work out how far back the navkeys extend instead: navleft = (int)Math.Round(this.ClientSize.Width - (((_keySize + _paddingWidth) * 3.2)), 0); } KeyboardLayoutType desiredlayout = AppController.KeyboardLayout; PhysicalKeyboardLayout kl = PhysicalKeyboardLayout.GetPhysicalLayout(desiredlayout, _isMacKeyboard); _rowTerminators = PhysicalKeyboardLayout.GetRowTerminators(desiredlayout); if (_keysOnly == false) { // Function keys. DrawRow(kl.FunctionKeys, left, top); // Utility Keys if (_hasNumberPad == false || desiredlayout == KeyboardLayoutType.US) { DrawRow(kl.UtilityKeys, navleft, top); } else { // Shunt keys along one key-width (plus padding) for UK layout so they right-justify DrawRow(kl.UtilityKeys, numpadleft + (int)Math.Round(_keySize, 0) + _paddingWidth, top); } // To get a spacer row between the F keys: add double padding top += (int)Math.Round(_keySize + (_paddingWidth * 2), 0); } // TypewriterKeys keys DrawRow(kl.TypewriterKeys, left, top); if (_keysOnly == false) { // Navigation - Insert, Home, End etc DrawRow(kl.NavigationKeys, navleft, top); // Number pad if (_hasNumberPad) { DrawRow(kl.NumberPadKeys, numpadleft, top); } // Skip down and back for arrow keys top += (int)Math.Round((_keySize + _paddingWidth) * 3, 0); DrawRow(kl.ArrowKeys, navleft, top); } // Need to establish what the keys really are.. should know but it doesn't hurt to check, // especially as it went out of kilter at least once in development. _isCapsLockOn = Form.IsKeyLocked(Keys.CapsLock); // KeyboardHelper.IsKeySet(KeyboardHelper.ToggleKey.CapsLock); _isNumLockOn = Form.IsKeyLocked(Keys.NumLock); // .IsKKeyboardHelper.IsKeySet(KeyboardHelper.ToggleKey.NumLock); _isScrollLockOn = Form.IsKeyLocked(Keys.Scroll); // KeyboardHelper.IsKeySet(KeyboardHelper.ToggleKey.ScrollLock); SetStatusLabelsText(); SetMenuButtonStates(); NativeMethods.LockWindowUpdate(IntPtr.Zero); }