/// <summary> /// Define o mapa dos direcionais digitais. /// </summary> /// <param name="dpadup">Direcional digital para cima.</param> /// <param name="dpaddown">Direcional digital para baixo.</param> /// <param name="dpadright">Direcional digital para direita.</param> /// <param name="dpadleft">Direcional digital para esquerda.</param> public void SetDPad(Keys?dpadup, Keys?dpaddown, Keys?dpadright, Keys?dpadleft) { DPadUp = dpadup; DPadDown = dpaddown; DPadRight = dpadright; DPadLeft = dpadleft; }
/// <summary> /// Event method auto-called when the "Add Key" button is pressed. /// </summary> public void AddKeyButton_Click(object sender, EventArgs e) { Keys? result = null; NeedInputForm form = new NeedInputForm() { SetResultKey = (k) => { result = k; } }; form.ShowDialog(this); if (!result.HasValue) { // The enter key doesn't track right, so just make sure it's always present. if (Program.Blocker.KeysToChatterTime[Keys.Enter].HasValue) { return; } result = Keys.Enter; } Program.Blocker.KeysToChatterTime[result.Value] = Program.Blocker.GlobalChatterTimeLimit; Program.Blocker.SaveConfig(); ConfigureKeysGrid.Rows.Add(result.Value.Stringify(), Program.Blocker.GlobalChatterTimeLimit.ToString(), "[X]"); }
void Control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { charPressed = false; handled = true; key = e.KeyData.ToEto(); if (key != Keys.None && LastKeyDown != key) { var kpea = new KeyEventArgs(key, KeyEventType.KeyDown); Widget.OnKeyDown(kpea); handled = e.SuppressKeyPress = e.Handled = kpea.Handled; } else { handled = false; } if (!handled && charPressed) { // this is when something in the event causes messages to be processed for some reason (e.g. show dialog box) // we want the char event to come after the dialog is closed, and handled is set to true! var kpea = new KeyEventArgs(key, KeyEventType.KeyDown, keyChar); Widget.OnKeyDown(kpea); e.SuppressKeyPress = e.Handled = kpea.Handled; } LastKeyDown = null; }
public void SetFromEvent(KeyEventArgs keyEvent) { Control = keyEvent.Control; Alt = keyEvent.Alt; Shift = keyEvent.Shift; switch (keyEvent.KeyCode) { case Keys.ControlKey: case Keys.LControlKey: case Keys.RControlKey: case Keys.Alt: case Keys.Menu: case Keys.LMenu: case Keys.RMenu: case Keys.ShiftKey: case Keys.LShiftKey: case Keys.RShiftKey: KeyCode = null; break; default: KeyCode = keyEvent.KeyCode; break; } }
private static void loadPredefinedSearchQueries(string fname) { // load the pre-defined search queries JsonConfig jsonConfig = new JsonConfig("pre-defined search queries", fname); ILog logger = LogManager.GetLogger("shortcuts"); foreach (dynamic entry in jsonConfig.data) { string queryString = entry["query"] ?? ""; if (queryString == "") { Program.logStartupMsg("bad-shortcut", $"{entry["shortcut"]}: Missing query string"); continue; } string shortcutString = entry["shortcut"] ?? ""; Keys? keys = Shortcut.parseShortcutString((string)shortcutString); if (keys == null) { Program.logStartupMsg("bad-shortcut", $"{queryString}: {shortcutString}"); continue; } Shortcut shortcut = new SearchQueryShortcut(keys.Value, queryString); logger.Info($"Registering search query shortcut: {shortcut} => {queryString}"); Shortcut.registerShortcut(shortcut); } }
public void AddInList(Keys keys, Keys?modeKeys, KeyAction action) { KeyItem item = new KeyItem(keys, modeKeys, action); map.AddItem(item); list.Add(NamedAction.OfKeyItem(item)); }
/// <summary> /// Define o mapa dos botões X, Y, A e B. /// </summary> /// <param name="x">Botão X do GamePad.</param> /// <param name="y">Botão Y do GamePad.</param> /// <param name="a">Botão A do GamePad.</param> /// <param name="b">Botão B do GamePad.</param> public void SetAXBY(Keys?x, Keys?y, Keys?a, Keys?b) { X = x; Y = y; A = a; B = b; }
public static Color ColorInput(this InputManager input, Keys?keyR, Keys?keyG, Keys?keyB, Keys?keyA, Color c, ref bool isModified) { Color color = c; int v = input.Key.Is.CtrlDown || input.Key.Is.ShiftDown ? 1 : -1; if (keyR != null && input.Key.Is.Down(keyR.Value)) { color = new Color((color.R + v).Clamp(0, 255), color.G, color.B, color.A); isModified = true; } if (keyG != null && input.Key.Is.Down(keyG.Value)) { color = new Color(color.R, (color.G + v).Clamp(0, 255), color.B, color.A); isModified = true; } if (keyB != null && input.Key.Is.Down(keyB.Value)) { color = new Color(color.R, color.G, (color.B + v).Clamp(0, 255), color.A); isModified = true; } if (keyA != null && input.Key.Is.Down(keyA.Value)) { color = new Color(color.R, color.G, color.B, (color.A + v).Clamp(0, 255)); isModified = true; } return(color); }
private void InitModifiers() { FModifiers = Keys.None; foreach (var key in FKeys) { switch (key) { case Keys.ShiftKey: case Keys.LShiftKey: case Keys.RShiftKey: FModifiers |= Keys.Shift; break; case Keys.ControlKey: FModifiers |= Keys.Control; break; case Keys.Menu: case Keys.LMenu: case Keys.RMenu: FModifiers |= Keys.Alt; break; } } }
public SystemButtonEntryCombined([LocalizationRequired(false)] string id, string displayName, bool shiftToInvert = false, bool customCommand = false, Func <Keys?, IEnumerable <Keys> > fixedValueCallback = null, SystemButtonEntry buttonReference = null, bool delayed = false, string toolTip = null, string displayModifiers = "Ctrl+", Keys?defaultKey = null) { _fixedValueCallback = fixedValueCallback; WheelButton = new WheelButtonEntry(id, displayName, true); WheelButtonModifier = new WheelButtonEntry(id, displayName, false, true); WheelButton.ModifierButton = WheelButtonModifier; WheelButtonModifier.ModifierButton = WheelButton; SystemButton = fixedValueCallback == null ? new SystemButtonEntry(id, displayName, defaultKey) : null; ShiftToInvert = shiftToInvert; CustomCommand = customCommand; Delayed = delayed; ToolTip = toolTip; DisplayModifiers = displayModifiers; _systemButtonReference = buttonReference ?? SystemButton; if (_systemButtonReference != null) { _systemButtonReference.PropertyChanged += OnSystemButtonPropertyChanged; } UpdateDisplayFixedValue(); }
static public void SendKey(Keys?key, bool pressed) { if (key == (Keys)(int.Parse(Config.Default.Droite))) { _processor.Right = pressed; } if (key == (Keys)(int.Parse(Config.Default.Gauche))) { _processor.Left = pressed; } if (key == (Keys)(int.Parse(Config.Default.Haut))) { _processor.Up = pressed; } if (key == (Keys)(int.Parse(Config.Default.Bas))) { _processor.Down = pressed; } if (key == (Keys)(int.Parse(Config.Default.A))) { _processor.Akey = pressed; } if (key == (Keys)(int.Parse(Config.Default.B))) { _processor.Bkey = pressed; } if (key == (Keys)(int.Parse(Config.Default.Start))) { _processor.Start = pressed; } if (key == (Keys)(int.Parse(Config.Default.Select))) { _processor.Select = pressed; } }
public KeyMapping(Keys?key, Buttons?button, bool singlePressOnly = false, int pressCooldown = 0) { Key = key; this.Button = button; SinglePressOnly = singlePressOnly; PressCooldown = pressCooldown; }
/// <summary> /// Конструктор копирования /// </summary> public ApplicationMessageBinding(ApplicationMessageBinding k) : this(k.Message, k.mainKey, k.messageType) { stopFurtherProcessing = k.stopFurtherProcessing; mod1 = k.mod1; mod2 = k.mod2; ActionDescription = k.ActionDescription; }
//Escreve um elemento no xml. private void WriteElement(XmlWriter writer, string element, Keys?key) { writer.WriteStartElement(element); writer.WriteAttributeString("key", key.ToString()); writer.WriteValue(key.HasValue ? ((int)key).ToString() : ""); writer.WriteEndElement(); }
/// <summary> /// Define o mapa dos botões de ombro [RB] e [LB] /// </summary> /// <param name="leftshouder">Botão de ombro esquerdo. [LB].</param> /// <param name="rightshoulder">Botão de ombro direito [RB].</param> public KeyButtonMap SetShoulder(Keys?leftshouder, Keys?rightshoulder) { LeftShoulder = leftshouder; RightShoulder = rightshoulder; return(this); }
private void txtCmb_KeyDown(object sender, KeyEventArgs e) { hk.ClearHotkeys(); registered = false; mod = 0; txtCmb.Text = ""; if (e.Control) { mod |= AbsoluteUI.ModifierKeys.Control; txtCmb.Text += "CTRL "; } if (e.Alt) { mod |= AbsoluteUI.ModifierKeys.Alt; txtCmb.Text += "ALT "; } if (e.Shift) { mod |= AbsoluteUI.ModifierKeys.Shift; txtCmb.Text += "SHIFT "; } t = e.KeyCode; txtCmb.Text += t.ToString(); }
/// <summary> /// Define o mapa dos gatilhos [RT] e [LT]. /// </summary> /// <param name="lefttrigger">Gatilho esquerdo [LT].</param> /// <param name="righttrigger">Gatilho direito [RT].</param> public KeyButtonMap SetTrigger(Keys?lefttrigger, Keys?righttrigger) { LeftTrigger = lefttrigger; RightTrigger = righttrigger; return(this); }
/// <summary> /// перехват нажимания кнопок /// </summary> /// <param name="key">Нажатая кнопка</param> void MainFormKeyPressedEvent(Keys key) { var mod = Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(x => ModifierKeys.ToString().Split(',').Select(y => y.Trim()).Contains(x.ToString())).ToArray(); curentMod1Key = mod.Length > 0 ? mod[0] : Keys.None; curentMod2Key = mod.Length > 1 ? mod[1] : Keys.None; if (key != Keys.ControlKey && key != Keys.ShiftKey) { ObjHotKey.mainKey = key; ObjHotKey.mod1 = curentMod1Key; ObjHotKey.mod2 = curentMod2Key; var sb = new StringBuilder(key.ToString()); if (curentMod1Key != Keys.None && curentMod1Key != null) { sb.Append(string.Format(" + {0}", curentMod1Key)); ObjHotKey.mod1 = curentMod1Key; } if (curentMod2Key != Keys.None && curentMod2Key != null) { sb.Append(string.Format(" + {0}", curentMod2Key)); ObjHotKey.mod2 = curentMod2Key; } txtbxHotKeyNewValue.Text = sb.ToString(); } }
internal void UpdateOpen() { UpdateDimensions(); oldState = currentState; currentState = Keyboard.GetState(); if (repeatKey.HasValue) { if (currentState[repeatKey.Value] == KeyState.Down) { repeatCounter += Engine.DeltaTime; while (repeatCounter >= REPEAT_DELAY) { HandleKey(repeatKey.Value); repeatCounter -= REPEAT_EVERY; } } else { repeatKey = null; } } foreach (Keys key in currentState.GetPressedKeys()) { if (oldState[key] == KeyState.Up) { HandleKey(key); break; } } }
/// <summary> 将按下的按键转换为键盘上的按键名称 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void KeyName_textBox_KeyDown(object sender, KeyEventArgs e) { TextBox CurrentControl = (TextBox)sender; Key = e.KeyCode; ShowSysKey(); }
/// <summary> /// перехват нажимания кнопок /// </summary> /// <param name="key">Нажатая кнопка</param> void MainFormKeyPressedEvent(Keys key) { var mod = Enum.GetValues(typeof(Keys)).Cast <Keys>().Where(x => ModifierKeys.ToString().Split(',').Select(y => y.Trim()).Contains(x.ToString())).ToArray(); curentMod1Key = mod.Length > 0 ? mod[0] : Keys.None; curentMod2Key = mod.Length > 1 ? mod[1] : Keys.None; if (key != Keys.ControlKey && key != Keys.ShiftKey) { ObjHotKey.mainKey = key; ObjHotKey.mod1 = curentMod1Key; ObjHotKey.mod2 = curentMod2Key; var sb = new StringBuilder(key.ToString()); if (curentMod1Key != Keys.None && curentMod1Key != null) { sb.Append(string.Format(" + {0}", curentMod1Key)); ObjHotKey.mod1 = curentMod1Key; } if (curentMod2Key != Keys.None && curentMod2Key != null) { sb.Append(string.Format(" + {0}", curentMod2Key)); ObjHotKey.mod2 = curentMod2Key; } txtbxHotKeyNewValue.Text = sb.ToString(); } }
protected override bool ProcessKeyMessage(ref Message m) { if ((m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) && ((ulong)m.WParam == VK_CONTROL || (ulong)m.WParam == VK_SHIFT)) { Keys?key = null; switch (((ulong)m.LParam >> 16) & 0x1FF) { case LControl: key = Keys.LControlKey; break; case RControl: key = Keys.RControlKey; break; case LShift: key = Keys.LShiftKey; break; case RShift: key = Keys.RShiftKey; break; } if (key.HasValue) { if (m.Msg == WM_KEYDOWN) { OnKeyDown(new KeyEventArgs(key.Value)); } else { OnKeyUp(new KeyEventArgs(key.Value)); } return(true); } } return(base.ProcessKeyMessage(ref m)); }
private ToolStripMenuItem AddActionToMenu(MenuAction menuAction, ToolStripItemCollection curMenuItems, IActionContext context, HashSet usedShortcuts) { ActionPresentation presentation = new ActionPresentation(); presentation.Reset(); ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = menuAction.Name; Keys?keyShortcut = Core.ActionManager.GetKeyboardShortcutEx(menuAction.Action, context); if (keyShortcut != null && !usedShortcuts.Contains(keyShortcut)) { item.ShortcutKeys = (Keys)keyShortcut; usedShortcuts.Add(keyShortcut); } if (menuAction.MenuIcon != null) { item.Image = menuAction.MenuIcon; } item.Click += ExecuteMenuAction; curMenuItems.Add(item); _itemToActionMap[item] = menuAction; return(item); }
protected override void OnKeyDown(KeyEventArgs e) { m_Key = e.KeyCode; switch (e.KeyCode) { case Keys.ControlKey: case Keys.Menu: case Keys.ShiftKey: m_Key = null; break; case Keys.Back: if (!e.Control && !e.Alt && !e.Shift) { Text = string.Empty; return; } break; } var hk = new Hotkey { Control = e.Control, Alt = e.Alt, Shift = e.Shift, Key = m_Key }; Text = hk.ToString(); }
public InputBinding(string name, Keys?keyboardKey = null, MouseButton?mouseButton = null, Buttons?gamepadButton = null, Axis?gamepadAxis = null) { Name = name; KeyboardKeys = new(); if (keyboardKey != null) { KeyboardKeys.Add(new() { keyboardKey.Value }); } MouseButtons = new(); if (mouseButton != null) { MouseButtons.Add(mouseButton.Value); } GamepadButtons = new(); if (gamepadButton != null) { GamepadButtons.Add(gamepadButton.Value); } GamepadAxis = new(); if (gamepadAxis != null) { GamepadAxis.Add(gamepadAxis.Value); } }
private void HandleKey(Keys key) { if (key == Keys.Q || key == Keys.W) { repeatKey = key; repeatCounter = 0; } switch (key) { default: break; case Keys.OemTilde: Open = canOpen = false; break; case Keys.Q: ScrollUp(); break; case Keys.W: ScrollDown(); break; } }
/// <summary> /// Define o mapa dos botões START, BACK e BIGBUTTON. /// </summary> /// <param name="start">Botão Start.</param> /// <param name="back">Botão Back.</param> /// <param name="bigbutton">Botão BigButton.</param> public KeyButtonMap SetStartBackBig(Keys?start, Keys?back, Keys?bigbutton) { Start = start; Back = back; BigButton = bigbutton; return(this); }
public Paddle(Rectangle screen_bounds, Vector2 position, bool cpu, Keys?up, Keys?down) { _screen_bounds = screen_bounds; _position = position; _up_key = up; _down_key = down; _cpu = cpu; }
/// <summary> /// Define o mapa do direcional analógico esquerdo. /// </summary> /// <param name="leftstick">Analógico esquerdo.</param> /// <param name="leftthumbstickup">Analógico esquerdo para cima.</param> /// <param name="leftthumbstickdown">Analógico esquerdo para baixo.</param> /// <param name="leftthumbstickright">Analógico esquerdo para direita.</param> /// <param name="leftthumbstickleft">Analógico esquerdo para esquerda.</param> public void SetLeftStick(Keys?leftstick, Keys?leftthumbstickup, Keys?leftthumbstickdown, Keys?leftthumbstickright, Keys?leftthumbstickleft) { LeftStick = leftstick; LeftThumbStickUp = leftthumbstickup; LeftThumbStickDown = leftthumbstickdown; LeftThumbStickRight = leftthumbstickright; LeftThumbStickLeft = leftthumbstickleft; }
public KeyItem(Keys keys, Keys?modeKeys, KeyAction action) { this.keys = keys; this.modeKeys = modeKeys; this.action = action; next = null; }
private static void OnWindowKeyPress(object sender, KeyEventArgs e) { Program.lastKeyPressed = e.Key; if (e.Key == Keys.Enter || e.Key == Keys.NumpadEnter) { Program.window.Close(); } }
private void AssertAKeyPress(Keys key) { int neededInputs = 2; var modifiers = new Keys?[3]; if (key.HasFlag(Keys.Shift)) { modifiers[0] = Keys.ShiftKey; neededInputs += 2; } if (key.HasFlag(Keys.Control)) { modifiers[1] = Keys.ControlKey; neededInputs += 2; } if (key.HasFlag(Keys.Alt)) { modifiers[2] = Keys.Menu; neededInputs += 2; } Assert.AreEqual(neededInputs, _inputs.Count); int currentInput = 0; foreach (var modifier in modifiers) { if (modifier.HasValue) { AssertIsKeyDownInputFor(modifier.Value, _inputs[currentInput++]); } } AssertIsKeyDownInputFor(key, _inputs[currentInput++]); AssertIsKeyUpInputFor(key, _inputs[currentInput++]); foreach (var modifier in modifiers) { if (modifier.HasValue) { AssertIsKeyUpInputFor(modifier.Value, _inputs[currentInput++]); } } }
private bool HandleStudioKey(Keys keyData) { Keys? nullable = _firstLetter; _firstLetter = null; Keys valueOrDefault = nullable.GetValueOrDefault(); if (!nullable.HasValue) { switch (keyData) { case (Keys.Control | Keys.E): case (Keys.Control | Keys.K): case (Keys.Control | Keys.M): case (Keys.Control | Keys.W): _firstLetter = new Keys?(keyData); return true; case (Keys.Control | Keys.G): this.ExecuteQuery(); return true; case (Keys.Control | Keys.J): this.ListMembers(); return true; } return false; } switch (valueOrDefault) { case (Keys.Control | Keys.K): valueOrDefault = keyData; if (valueOrDefault > Keys.X) { if (valueOrDefault > (Keys.Control | Keys.L)) { switch (valueOrDefault) { case (Keys.Control | Keys.S): goto Label_013B; case (Keys.Control | Keys.T): goto Label_0149; case (Keys.Control | Keys.U): goto Label_0150; } if (valueOrDefault != (Keys.Control | Keys.X)) { goto Label_0149; } goto Label_012D; } if (valueOrDefault == (Keys.Control | Keys.C)) { goto Label_00FE; } if (valueOrDefault == (Keys.Control | Keys.L)) { break; } } else if (valueOrDefault > Keys.L) { switch (valueOrDefault) { case Keys.S: goto Label_013B; case Keys.U: goto Label_0150; case Keys.X: goto Label_012D; } } else { switch (valueOrDefault) { case Keys.C: goto Label_00FE; } } goto Label_0149; case (Keys.Control | Keys.M): switch (keyData) { case Keys.L: case Keys.O: case (Keys.Control | Keys.L): case (Keys.Control | Keys.O): this.ToggleAllOutlining(); return true; case Keys.M: case (Keys.Control | Keys.M): this.ToggleOutlining(false); return true; } return false; case (Keys.Control | Keys.W): switch (keyData) { case Keys.L: case (Keys.Control | Keys.L): MainForm.Instance.FocusSchemaExplorer(); return true; case Keys.S: case (Keys.Control | Keys.S): MainForm.Instance.FocusQueries(); return true; } return false; case (Keys.Control | Keys.E): switch (keyData) { case Keys.C: case (Keys.Control | Keys.C): this.CommentSelection(); return true; case Keys.U: case (Keys.Control | Keys.U): this.UncommentSelection(); return true; } return false; default: return false; } this.ListMembers(); return true; Label_00FE: this.CommentSelection(); return true; Label_012D: this.InsertSnippet(false); return true; Label_013B: this.InsertSnippet(true); return true; Label_0149: return false; Label_0150: this.UncommentSelection(); return true; }
private void HandleKey(Keys key) { if (key != Keys.Tab && key != Keys.LeftShift && key != Keys.RightShift && key != Keys.RightAlt && key != Keys.LeftAlt && key != Keys.RightControl && key != Keys.LeftControl) tabIndex = -1; if (key != Keys.OemTilde && key != Keys.Enter && repeatKey != key) { repeatKey = key; repeatCounter = 0; } switch (key) { default: if (key.ToString().Length == 1) { if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += key.ToString(); else currentText += key.ToString().ToLower(); } break; case (Keys.D1): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '!'; else currentText += '1'; break; case (Keys.D2): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '@'; else currentText += '2'; break; case (Keys.D3): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '#'; else currentText += '3'; break; case (Keys.D4): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '$'; else currentText += '4'; break; case (Keys.D5): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '%'; else currentText += '5'; break; case (Keys.D6): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '^'; else currentText += '6'; break; case (Keys.D7): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '&'; else currentText += '7'; break; case (Keys.D8): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '*'; else currentText += '8'; break; case (Keys.D9): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '('; else currentText += '9'; break; case (Keys.D0): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += ')'; else currentText += '0'; break; case (Keys.OemComma): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '<'; else currentText += ','; break; case (Keys.OemPeriod): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '>'; else currentText += '.'; break; case (Keys.OemQuestion): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '?'; else currentText += '/'; break; case (Keys.OemSemicolon): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += ':'; else currentText += ';'; break; case (Keys.OemQuotes): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '"'; else currentText += '\''; break; case (Keys.OemBackslash): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '|'; else currentText += '\\'; break; case (Keys.OemOpenBrackets): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '{'; else currentText += '['; break; case (Keys.OemCloseBrackets): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '}'; else currentText += ']'; break; case (Keys.OemMinus): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '_'; else currentText += '-'; break; case (Keys.OemPlus): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) currentText += '+'; else currentText += '='; break; case (Keys.Space): currentText += " "; break; case (Keys.Back): if (currentText.Length > 0) currentText = currentText.Substring(0, currentText.Length - 1); break; case (Keys.Delete): currentText = ""; break; case (Keys.Up): if (seekIndex < commandHistory.Count - 1) { seekIndex++; currentText = string.Join(" ", commandHistory[seekIndex]); } break; case (Keys.Down): if (seekIndex > -1) { seekIndex--; if (seekIndex == -1) currentText = ""; else currentText = string.Join(" ", commandHistory[seekIndex]); } break; case (Keys.Tab): if (currentState[Keys.LeftShift] == KeyState.Down || currentState[Keys.RightShift] == KeyState.Down) { if (tabIndex == -1) { tabSearch = currentText; FindLastTab(); } else { tabIndex--; if (tabIndex < 0 || (tabSearch != "" && sorted[tabIndex].IndexOf(tabSearch) != 0)) FindLastTab(); } } else { if (tabIndex == -1) { tabSearch = currentText; FindFirstTab(); } else { tabIndex++; if (tabIndex >= sorted.Count || (tabSearch != "" && sorted[tabIndex].IndexOf(tabSearch) != 0)) FindFirstTab(); } } if (tabIndex != -1) currentText = sorted[tabIndex]; break; case (Keys.Enter): if (currentText.Length > 0) EnterCommand(); break; case (Keys.OemTilde): Open = false; break; } }
internal void UpdateOpen() { oldState = currentState; currentState = Keyboard.GetState(); underscoreCounter++; if (underscoreCounter == UNDERSCORE_TIME) { underscoreCounter = 0; underscore = !underscore; } if (repeatKey.HasValue) { if (currentState[repeatKey.Value] == KeyState.Down) { if (repeatCounter < REPEAT_DELAY) repeatCounter++; else { if (repeatCounter == REPEAT_DELAY) { repeatCounter++; HandleKey(repeatKey.Value); } else { repeatCounter++; if (repeatCounter == REPEAT_DELAY + REPEAT_EVERY) repeatCounter = REPEAT_DELAY; } } } else repeatKey = null; } foreach (Keys key in currentState.GetPressedKeys()) { if (oldState[key] == KeyState.Up) { HandleKey(key); break; } } }
public KeySet(Keys? key, int initTime, int repeatPeriod) { this.assigned = key; this.initTime = initTime; this.repeatPeriod = repeatPeriod; }
/// <summary> /// Opens the game console. /// </summary> /// <param name="closeKey"><para>The key that should close the game console.</para> /// <para>If the close key is set to null, the console can only be closed by call the <c>Close</c>-Method /// or if the user enters the <c>close</c> command and hits enter.</para></param> public void Open(Keys? closeKey) { if (!IsOpen && !IsOpening && !IsClosing) { if (Opening != null) { CancelEventArgs cancelArgs = new CancelEventArgs(); Opening(this, cancelArgs); if (cancelArgs.Cancel) { return; } } this._closeKey = closeKey; InitializeAnimation(OpeningAnimation, _openingAnimationTime); Enabled = Visible = true; IsOpening = true; IsClosing = false; } }
/// <summary> /// Метод восстановления объекта горячей клавиши из строки. Этот метод обратный методу "ToString()" /// </summary> public static ApplicationMessageBinding Parse(string str) { var messageSrt = string.Empty; var keySrt = string.Empty; var mod1Srt = string.Empty; var mod2Srt = string.Empty; var messageTypeSrt = string.Empty; var stopFurtherProcessingSrt = string.Empty; foreach (var s in str.Split(',')) { var param = s.Split(':'); if (param.Length < 2 || string.IsNullOrEmpty(param[0].Trim()) || string.IsNullOrEmpty(param[1].Trim())) { Logger.Error(String.Format("Неправилиный формат записи пользовательских настроек горячих клавиш в файле UserSettings. Ошибка в \"{0}\"", s)); continue; //Это значить что в паре "ключ / значение" один или оба отсутствуют } switch (param[0]) { case "message": messageSrt = param[1]; break; case "key": keySrt = param[1]; break; case "mod1": mod1Srt = param[1]; break; case "mod2": mod2Srt = param[1]; break; case "messageType": messageTypeSrt = param[1]; break; case "stopFurtherProcessing": stopFurtherProcessingSrt = param[1]; break; } } ApplicationMessage message; Keys key; Keys? mod1; Keys? mod2; WindowMessage messageType; bool stopFurtherProcessing; try { message = Enum.GetValues(typeof (ApplicationMessage)).Cast<ApplicationMessage>().First(x => x.ToString() == messageSrt); key = Enum.GetValues(typeof (Keys)).Cast<Keys>().First(x => x.ToString() == keySrt); mod1 = Enum.GetValues(typeof (Keys)).Cast<Keys>().FirstOrDefault(x => x.ToString() == mod1Srt); mod2 = Enum.GetValues(typeof (Keys)).Cast<Keys>().FirstOrDefault(x => x.ToString() == mod2Srt); messageType = Enum.GetValues(typeof (WindowMessage)).Cast<WindowMessage>().First(x => x.ToString() == messageTypeSrt); stopFurtherProcessing = stopFurtherProcessingSrt == "True"; } catch (Exception ex) { Logger.Error("Ошибка при попытке распарсить кастомные настройки горячих клавиш из файла UserSettings", ex); return null; } return new ApplicationMessageBinding(message, key, messageType) { mod1 = mod1, mod2 = mod2, stopFurtherProcessing = stopFurtherProcessing }; }
public void Set(Keys value) { _value = value; }
public void Reset() { _value = Default; }
public Key(Keys defaultKey, Keys? value = null) { Default = defaultKey; _value = value; }
void handleKey( Keys key ) { if( key != Keys.Tab && key != Keys.LeftShift && key != Keys.RightShift && key != Keys.RightAlt && key != Keys.LeftAlt && key != Keys.RightControl && key != Keys.LeftControl ) _tabIndex = -1; if( key != Keys.OemTilde && key != Keys.Oem8 && key != Keys.Enter && _repeatKey != key ) { _repeatKey = key; _repeatCounter = 0; } switch( key ) { default: if( key.ToString().Length == 1 ) { if( InputUtils.isShiftDown() ) _currentText += key.ToString(); else _currentText += key.ToString().ToLower(); } break; case( Keys.D1 ): if( InputUtils.isShiftDown() ) _currentText += '!'; else _currentText += '1'; break; case( Keys.D2 ): if( InputUtils.isShiftDown() ) _currentText += '@'; else _currentText += '2'; break; case( Keys.D3 ): if( InputUtils.isShiftDown() ) _currentText += '#'; else _currentText += '3'; break; case( Keys.D4 ): if( InputUtils.isShiftDown() ) _currentText += '$'; else _currentText += '4'; break; case( Keys.D5 ): if( InputUtils.isShiftDown() ) _currentText += '%'; else _currentText += '5'; break; case( Keys.D6 ): if( InputUtils.isShiftDown() ) _currentText += '^'; else _currentText += '6'; break; case( Keys.D7 ): if( InputUtils.isShiftDown() ) _currentText += '&'; else _currentText += '7'; break; case( Keys.D8 ): if( InputUtils.isShiftDown() ) _currentText += '*'; else _currentText += '8'; break; case( Keys.D9 ): if( InputUtils.isShiftDown() ) _currentText += '('; else _currentText += '9'; break; case( Keys.D0 ): if( InputUtils.isShiftDown() ) _currentText += ')'; else _currentText += '0'; break; case( Keys.OemComma): if( InputUtils.isShiftDown() ) _currentText += '<'; else _currentText += ','; break; case Keys.OemPeriod: if( InputUtils.isShiftDown() ) _currentText += '>'; else _currentText += '.'; break; case Keys.OemQuestion: if( InputUtils.isShiftDown() ) _currentText += '?'; else _currentText += '/'; break; case Keys.OemSemicolon: if( InputUtils.isShiftDown() ) _currentText += ':'; else _currentText += ';'; break; case Keys.OemQuotes: if( InputUtils.isShiftDown() ) _currentText += '"'; else _currentText += '\''; break; case Keys.OemBackslash: if( InputUtils.isShiftDown() ) _currentText += '|'; else _currentText += '\\'; break; case Keys.OemOpenBrackets: if( InputUtils.isShiftDown() ) _currentText += '{'; else _currentText += '['; break; case Keys.OemCloseBrackets: if( InputUtils.isShiftDown() ) _currentText += '}'; else _currentText += ']'; break; case Keys.OemMinus: if( InputUtils.isShiftDown() ) _currentText += '_'; else _currentText += '-'; break; case Keys.OemPlus: if( InputUtils.isShiftDown() ) _currentText += '+'; else _currentText += '='; break; case Keys.Space: _currentText += " "; break; case Keys.Back: if( _currentText.Length > 0 ) _currentText = _currentText.Substring( 0, _currentText.Length - 1 ); break; case Keys.Delete: _currentText = ""; break; case Keys.Up: if( _seekIndex < _commandHistory.Count - 1 ) { _seekIndex++; _currentText = string.Join( " ", _commandHistory[_seekIndex] ); } break; case Keys.Down: if( _seekIndex > -1 ) { _seekIndex--; if( _seekIndex == -1 ) _currentText = ""; else _currentText = string.Join( " ", _commandHistory[_seekIndex] ); } break; case Keys.Tab: if( InputUtils.isShiftDown() ) { if( _tabIndex == -1 ) { _tabSearch = _currentText; findLastTab(); } else { _tabIndex--; if( _tabIndex < 0 || ( _tabSearch != "" && _sorted[_tabIndex].IndexOf( _tabSearch ) != 0 ) ) findLastTab(); } } else { if( _tabIndex == -1 ) { _tabSearch = _currentText; findFirstTab(); } else { _tabIndex++; if( _tabIndex >= _sorted.Count || ( _tabSearch != "" && _sorted[_tabIndex].IndexOf( _tabSearch ) != 0 ) ) findFirstTab(); } } if( _tabIndex != -1 ) _currentText = _sorted[_tabIndex]; break; case Keys.F1: case Keys.F2: case Keys.F3: case Keys.F4: case Keys.F5: case Keys.F6: case Keys.F7: case Keys.F8: case Keys.F9: case Keys.F10: case Keys.F11: case Keys.F12: executeFunctionKeyAction( (int)( key - Keys.F1 ) ); break; case Keys.Enter: if( _currentText.Length > 0 ) enterCommand(); break; case Keys.Oem8: case Keys.OemTilde: isOpen = _canOpen = false; break; } }
void updateOpen() { _oldState = _currentState; _currentState = Keyboard.GetState(); _underscoreCounter += Time.deltaTime; while( _underscoreCounter >= UNDERSCORE_TIME ) { _underscoreCounter -= UNDERSCORE_TIME; _underscore = !_underscore; } if( _repeatKey.HasValue ) { if( _currentState[_repeatKey.Value] == KeyState.Down ) { _repeatCounter += Time.deltaTime; while( _repeatCounter >= REPEAT_DELAY ) { handleKey( _repeatKey.Value ); _repeatCounter -= REPEAT_EVERY; } } else _repeatKey = null; } foreach( var key in _currentState.GetPressedKeys() ) { if( _oldState[key] == KeyState.Up ) { handleKey( key ); break; } } }
/// <summary> /// Create a new menu instance, including subscribing to keypresses and all. /// </summary> /// <param name="Title">The title of this menu</param> /// <param name="Hotkey">The hotkey which opens/closes this menu (null for no key)</param> public Menu(string MenuFilename, Keys? Hotkey) { // Set up member properties ActiveMenu = null; // Null if no menu active - otherwise, the currently active menu or submenu this.MenuFilename = MenuFilename; Submenus = new List<Submenu>(); Actions = new List<MenuAction>(); this.Hotkey = Hotkey; // Set up logic properties _isHotkeyPressed = false; // Subscribe to our main application... OutsideSimulatorApp.GetInstance().Subscribe(this); }
public void Unset() { _value = null; }
public override void Update( GameTime gameTime ) { base.Update( gameTime ); double currMillis = gameTime.TotalGameTime.TotalMilliseconds; if ( currMillis - mLastCursorBlink >= CursorBlinkFrequency ) { mCursorVisible = !mCursorVisible; mLastCursorBlink = currMillis; } if ( !Input.CheckFocus( this ) ) return; string oldText = Text; int oldInputPos = InputPos; Func<Keys, bool> notModKey = k => { return k < Keys.LeftShift || k > Keys.RightAlt; }; var currentKeys = Input.Keyboard.GetPressedKeys().Where( notModKey ); var prevKeys = Input.OldKeyboard.GetPressedKeys().Where( notModKey ); var newKeys = currentKeys.Where( ck => !prevKeys.Any( pk => pk == ck ) ).ToList(); var heldKeys = currentKeys.Intersect( prevKeys ); if ( mRepeatKey.HasValue && !heldKeys.Contains( mRepeatKey.Value ) ) mRepeatKey = null; var tmpKey = mRepeatKey; foreach ( var pair in mKeyHistory.ToArray() ) { if ( !heldKeys.Contains( pair.Key ) ) { mKeyHistory.Remove( pair.Key ); continue; } if ( pair.Key != mRepeatKey ) { mRepeatKey = null; if ( currMillis - pair.Value >= this.RepeatDelay ) mRepeatKey = pair.Key; } } if ( mRepeatKey != tmpKey ) mLastRepeat = currMillis; foreach ( Keys key in newKeys ) mKeyHistory[ key ] = currMillis; if ( mRepeatKey.HasValue && currMillis - mLastRepeat >= this.RepeatFrequency ) { newKeys.Add( mRepeatKey.Value ); mLastRepeat = currMillis; } foreach ( Keys key in newKeys ) { switch ( key ) { case Keys.Home: mIsSelecting = Input.IsShiftDown(); InputPos = 0; break; case Keys.End: mIsSelecting = Input.IsShiftDown(); InputPos = Text.Length; break; case Keys.Left: mIsSelecting = Input.IsShiftDown(); if ( Input.IsCtrlDown() ) InputPos = SkipLeft(); else if ( HasSelection && !mIsSelecting ) mSelectionAnchor = mInputPos = SelectionStart; else --InputPos; break; case Keys.Right: mIsSelecting = Input.IsShiftDown(); if ( Input.IsCtrlDown() ) InputPos = SkipRight(); else if ( HasSelection && !mIsSelecting ) mSelectionAnchor = mInputPos = SelectionEnd; else ++InputPos; break; case Keys.Back: if ( Text.Length > 0 ) { int pos = HasSelection ? InputPos : InputPos - 1; if ( Input.IsCtrlDown() ) pos = SkipLeft(); if ( pos < 0 ) pos = 0; if ( InputPos > SelectionAnchor ) pos = SelectionStart; mIsSelecting = true; SelectionAnchor = Math.Max( InputPos, SelectionEnd ); InputPos = Math.Min( pos, SelectionStart ); InsertText( "" ); } break; case Keys.Delete: if ( Text.Length > 0 ) { int pos = HasSelection ? InputPos : InputPos + 1; if ( Input.IsCtrlDown() ) pos = SkipRight(); if ( pos > Text.Length ) pos = Text.Length; if ( InputPos < SelectionAnchor ) pos = SelectionEnd; mIsSelecting = true; SelectionAnchor = Math.Min( InputPos, SelectionStart ); InputPos = Math.Max( pos, SelectionEnd ); InsertText( "" ); } break; case Keys.Space: InsertText( " " ); break; case Keys.Enter: if ( EnableMultiLine ) InsertText( "\n" ); break; default: char glyph = (char) key; if ( char.IsLetter( glyph ) ) { if ( Input.IsCtrlDown() ) { switch ( glyph ) { case 'A': InputPos = Text.Length; SelectionAnchor = 0; break; case 'X': this.Cut(); break; case 'C': this.Copy(); break; case 'V': this.Paste(); break; } } else { InsertText( !Input.IsShiftDown() ? char.ToLower( glyph ) : glyph ); } } else if ( char.IsDigit( glyph ) ) { if ( !Input.IsShiftDown() ) InsertText( glyph ); else InsertText( ")!@#$%^&*(".ElementAt( glyph - '0' ) ); } break; case Keys.OemTilde: InsertText( !Input.IsShiftDown() ? "`" : "~" ); break; case Keys.OemMinus: InsertText( !Input.IsShiftDown() ? "-" : "_" ); break; case Keys.OemPlus: InsertText( !Input.IsShiftDown() ? "=" : "+" ); break; case Keys.OemOpenBrackets: InsertText( !Input.IsShiftDown() ? "[" : "{" ); break; case Keys.OemCloseBrackets: InsertText( !Input.IsShiftDown() ? "]" : "}" ); break; case Keys.OemPipe: InsertText( !Input.IsShiftDown() ? "\\" : "|" ); break; case Keys.OemSemicolon: InsertText( !Input.IsShiftDown() ? ";" : ":" ); break; case Keys.OemQuotes: InsertText( !Input.IsShiftDown() ? "'" : "\"" ); break; case Keys.OemComma: InsertText( !Input.IsShiftDown() ? "," : "<" ); break; case Keys.OemPeriod: InsertText( !Input.IsShiftDown() ? "." : ">" ); break; case Keys.OemQuestion: InsertText( !Input.IsShiftDown() ? "/" : "?" ); break; } mIsSelecting = false; } if ( oldText != Text || oldInputPos != InputPos ) { mCursorVisible = true; mLastCursorBlink = currMillis; } }
internal void UpdateOpen() { oldState = currentState; currentState = Keyboard.GetState(); underscoreCounter += Engine.DeltaTime; while (underscoreCounter >= UNDERSCORE_TIME) { underscoreCounter -= UNDERSCORE_TIME; underscore = !underscore; } if (repeatKey.HasValue) { if (currentState[repeatKey.Value] == KeyState.Down) { repeatCounter += Engine.DeltaTime; while (repeatCounter >= REPEAT_DELAY) { HandleKey(repeatKey.Value); repeatCounter -= REPEAT_EVERY; } } else repeatKey = null; } foreach (Keys key in currentState.GetPressedKeys()) { if (oldState[key] == KeyState.Up) { HandleKey(key); break; } } }