protected override bool OnDragEnd(Point dragStartPosition, Point dragEndPosition) { this.CommitEditTransaction(); this.dragCurrentKey = new Key?(); this.dragCurrentKeyIsUp = new bool?(); return(base.OnDragEnd(dragStartPosition, dragEndPosition)); }
public IconButton(IGameWindow window, Camera <OrthographicProjection> camera, Vector2 position, IRenderable renderable, Key?hotkey = null) : base(window, camera, position) { Renderable = renderable; IsSelected = false; Hotkey = hotkey; }
protected override bool OnKey(KeyEventArgs args) { if (this.IsDragging) { Key?nullable1 = this.dragCurrentKey; Key key = args.Key; if ((nullable1.GetValueOrDefault() != key ? 0 : (nullable1.HasValue ? true : false)) != 0) { bool?nullable2 = this.dragCurrentKeyIsUp; bool isUp = args.IsUp; if ((nullable2.GetValueOrDefault() != isUp ? 0 : (nullable2.HasValue ? true : false)) != 0) { return(true); } } this.dragCurrentKey = new Key?(args.Key); this.dragCurrentKeyIsUp = new bool?(args.IsUp); if (args.Key == Key.LeftShift || args.Key == Key.RightShift || args.Key == Key.System && (args.SystemKey == Key.LeftAlt || args.SystemKey == Key.RightAlt)) { switch (this.ActiveAdorner.Kind) { case LinearGradientAdornerKind.StartPoint: case LinearGradientAdornerKind.EndPoint: this.UpdatePosition(); break; case LinearGradientAdornerKind.StartRotation: case LinearGradientAdornerKind.EndRotation: this.UpdateRotation(); break; } } } return(true); }
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) { int keyInt = (int)e.Key; ModifierKeys modifier = ((ComboBoxModifierKey)comboBox_ModifierKey.SelectedItem).ValueKey; if ((keyInt >= 34 && keyInt <= 69) || (keyInt >= 74 && keyInt <= 83) || (keyInt >= 90 && keyInt <= 113)) { if ((modifier == ModifierKeys.Control && e.Key != Key.O && e.Key != Key.S && e.Key != Key.F2 && e.Key != Key.N && e.Key != Key.E && e.Key != Key.D && e.Key != Key.H && e.Key != Key.A) || (modifier == ModifierKeys.Alt && e.Key != Key.F4) || modifier == ModifierKeys.None) { textBox_Hotkey.Text = e.Key.ToString(); currentKey = e.Key; } } e.Handled = true; }
protected virtual void HandleKeyboardKeyStateChange(ButtonStateChangeEvent <Key> keyboardKeyStateChange) { var state = keyboardKeyStateChange.State; var key = keyboardKeyStateChange.Button; var kind = keyboardKeyStateChange.Kind; if (kind == ButtonStateChangeKind.Pressed) { handleKeyDown(state, key, false); if (!isModifierKey(key)) { keyboardRepeatKey = key; keyboardRepeatTime = repeat_initial_delay; } } else { handleKeyUp(state, key); if (key == keyboardRepeatKey) { keyboardRepeatKey = null; keyboardRepeatTime = 0; } } }
public bool SetCurrentKeypressType(Key?key) { IsKeyPressed = true; bool keyHandledState = true; Key? oldkey = _key; _key = key; switch (_key) { case Key.Up: case Key.Down: case Key.Left: case Key.Right: _keypressed = _key; break; case Key.Space: AddActionKey(Key.Space); _key = oldkey; break; default: _keypressed = null; keyHandledState = false; IsKeyPressed = false; break; } return(keyHandledState); }
public KeyboardSettingsViewModel(KeyboardSettings keyboardSettings) { BuyKey = null; SellKey = null; CloseAllKey = null; if (keyboardSettings == null) { return; } if (keyboardSettings.BuyKey != null) { BuyKey = keyboardSettings.BuyKey.Key; } if (keyboardSettings.SellKey != null) { SellKey = keyboardSettings.SellKey.Key; } if (keyboardSettings.CloseAllKey != null) { CloseAllKey = keyboardSettings.CloseAllKey.Key; } }
protected virtual void HandleKeyboardKeyStateChange(ButtonStateChangeEvent <Key> keyboardKeyStateChange) { var state = keyboardKeyStateChange.State; var key = keyboardKeyStateChange.Button; var kind = keyboardKeyStateChange.Kind; GetButtonEventManagerFor(key).HandleButtonStateChange(state, kind); if (kind == ButtonStateChangeKind.Pressed) { if (!isModifierKey(key)) { keyboardRepeatKey = key; keyboardRepeatTime = repeat_initial_delay; } } else { if (key == keyboardRepeatKey) { keyboardRepeatKey = null; keyboardRepeatTime = 0; } } }
private static Sound CreateSoundFromSQL(string name, string pathToSound, string pathToImage, string key) { Key?definedKey = null; if (key != null) { definedKey = (Key)Enum.Parse(typeof(Key), key); } Sound sound = new Sound(0.5) { Name = name, PathToSound = pathToSound, PathToImage = pathToImage, Key = definedKey }; BitmapImage bit = new BitmapImage(); bit.BeginInit(); bit.CreateOptions = BitmapCreateOptions.IgnoreImageCache; bit.CacheOption = BitmapCacheOption.OnLoad; try { bit.UriSource = new Uri(pathToImage); } catch { bit.UriSource = new Uri("pack://application:,,,/Resources/1200px-Button_Icon_Red.svg.png"); } bit.EndInit(); sound.Image.ImageSource = bit; return(sound); }
void Control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { charPressed = false; handled = true; key = e.KeyData.ToEto(); if (key != Key.None && LastKeyDown != key) { var kpea = new KeyEventArgs(key, KeyEventType.KeyDown); Widget.OnKeyDown(kpea); e.SuppressKeyPress = kpea.Handled; 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 = kpea.Handled; } LastKeyDown = null; }
internal static void AfterFrame() { if (BackButtonQuitsApp && IsKeyDownOnce(Key.Back)) { Window.Close(); } m_lastKey = null; m_lastChar = null; for (int i = 0; i < m_keysDownOnceArray.Length; i++) { m_keysDownOnceArray[i] = false; } for (int j = 0; j < m_keysDownRepeatArray.Length; j++) { if (m_keysDownArray[j]) { if (m_keysDownRepeatArray[j] < 0.0) { m_keysDownRepeatArray[j] = Time.FrameStartTime + 0.2; } else if (Time.FrameStartTime >= m_keysDownRepeatArray[j]) { m_keysDownRepeatArray[j] = MathUtils.Max(Time.FrameStartTime, m_keysDownRepeatArray[j] + 0.033); } } else { m_keysDownRepeatArray[j] = 0.0; } } }
/// <inheritdoc /> public override Key?ReadJson(JsonReader reader, Type objectType, Key?existingValue, bool hasExistingValue, JsonSerializer serializer) { var keyString = reader.Value as string; if (string.IsNullOrWhiteSpace(keyString)) { return(default);
public KeyboardBackInterfaceAxis Bind(Key?up, Key?right, Key?down, Key?left) { bool isSourceModified = false; if (up.HasValue) { _source.AddUp(new KeyboardButtonInputSource(Device, up.Value)); isSourceModified = true; } if (right.HasValue) { _source.AddRight(new KeyboardButtonInputSource(Device, right.Value)); isSourceModified = true; } if (down.HasValue) { _source.AddDown(new KeyboardButtonInputSource(Device, down.Value)); isSourceModified = true; } if (left.HasValue) { _source.AddLeft(new KeyboardButtonInputSource(Device, left.Value)); isSourceModified = true; } if (isSourceModified) { SourceModified(_source); } return(this); }
public static KeyStrokeMessage FromKeyCode(int keyCode) { Key?key = null; switch (keyCode) { case 32: key = Messages.Key.Space; break; case 37: key = Messages.Key.ArrowLeft; break; case 39: key = Messages.Key.ArrowRight; break; case 38: key = Messages.Key.ArrowUp; break; case 40: key = Messages.Key.ArrowDown; break; } return(new KeyStrokeMessage(key)); }
public void CheckInput() { if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - millis > DELAY) { Key?key = null; dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { if (Keyboard.IsKeyDown(Key.Up)) { key = Key.Up; } else if (Keyboard.IsKeyDown(Key.Down)) { key = Key.Down; } else if (Keyboard.IsKeyDown(Key.Left)) { key = Key.Left; } else if (Keyboard.IsKeyDown(Key.Right)) { key = Key.Right; } else if (Keyboard.IsKeyDown(Key.Escape)) { key = Key.Escape; } }); if (key != null) { millis = DateTimeOffset.Now.ToUnixTimeMilliseconds(); KeyPressed?.Invoke(this, new Tetris.Data.KeyEventArgs(keyMap[(Key)key])); } } }
private async void TextBox_KeyDown(object sender, KeyEventArgs e) { Key = e.Key; await Task.Delay(1); (sender as TextBox).Text = $"{Key}"; }
protected override void OnKeyDown(KeyEventArgs e) { Key?downAccessKey = GetAccessKeyFromButton(moveDown); Key?upAccessKey = GetAccessKeyFromButton(moveUp); Key?allAccessKey = GetAccessKeyFromButton(selectAll); if ((e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt && allAccessKey == e.SystemKey) { if (AllSelected) { SelectAllUnchecked(); } else { SelectAllChecked(); } e.Handled = true; } if ((e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt && upAccessKey == e.SystemKey) { UpClick(this, null); e.Handled = true; } if ((e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt && downAccessKey == e.SystemKey) { DownClick(this, null); e.Handled = true; } base.OnKeyDown(e); }
private void CreateKeys() { this.privateKey = Key.Create(KeyAgreementAlgorithm.X25519, new KeyCreationParameters { ExportPolicy = KeyExportPolicies.AllowPlaintextExport }); this.publicKey = this.privateKey.PublicKey; }
public KeyboardHotkey([NotNull] KeyboardHotkey hotkey) : base(hotkey) { this._key = hotkey._key; this.isValid = hotkey.isValid; this.HotkeyVisitor = hotkey.HotkeyVisitor; }
private void CreateKeys() { this.privateKey = Key.Create(NSec.Cryptography.SignatureAlgorithm.Ed25519, new KeyCreationParameters { ExportPolicy = KeyExportPolicies.AllowPlaintextExport }); this.publicKey = this.privateKey.PublicKey; }
/// <summary> /// Adds a shortcut key to an item. /// </summary> /// <param name="item">The item to add the key too.</param> /// <param name="key">The short cut key.</param> public void AddItemShortcutKey(object item, Key?key) { if (key.HasValue && item != null) { if (this.itemsByShortcutKey.ContainsKey(key.Value)) { this.itemsByShortcutKey[key.Value] = item; } else { this.itemsByShortcutKey.Add(key.Value, item); } if (this.shortcutKeysByItem.ContainsKey(item)) { this.shortcutKeysByItem[item] = key.Value; } else { this.shortcutKeysByItem.Add(item, key.Value); } if (this.containersByItem.ContainsKey(item)) { this.containersByItem[item].ShortcutKeyText = ShortcutKeyHelper.ShortcutKeyPrefix + ShortcutKeyHelper.GetKeyAsString(key.Value); this.containersByItem[item].ShortcutKeyTextOpacity = this.showingShortcutKeys ? 1.0 : 0.0; } } }
public static void IsKeyTest(Key?key, MouseAction?mouseAction) { // ReSharper disable once PossibleInvalidOperationException KeyOrButton kob = key.HasValue ? new KeyOrButton(key.Value) : new KeyOrButton(mouseAction.Value); Assert.That(key.HasValue ? kob.IsKey : !kob.IsKey); }
private async Task <byte> WaitForKey() { /* * Keypad Keyboard +-+-+-+-+ +-+-+-+-+ |1|2|3|C| |1|2|3|4| +-+-+-+-+ +-+-+-+-+ |4|5|6|D| |Q|W|E|R| +-+-+-+-+ => +-+-+-+-+ |7|8|9|E| |A|S|D|F| +-+-+-+-+ +-+-+-+-+ |A|0|B|F| |Z|X|C|V| +-+-+-+-+ +-+-+-+-+ */ while (true) { if (LastKeyPressed.HasValue && KeyMap.ContainsKey(LastKeyPressed.Value)) { var ret = KeyMap[LastKeyPressed.Value]; LastKeyPressed = null; return(ret); } await Task.Delay(1); } }
public Button(Texture texture, float width, float height) { m_texture = texture; m_width = width; m_height = height; m_geometry = new Geometry(Primitive.Triangles, 4, 18); m_colour = Vector4.One; m_highlightColour = Vector4.One; m_disabledColour = Vector4.One; m_region = Quad.UnitSquare; m_highlightRegion = Quad.UnitSquare; m_disabledRegion = Quad.UnitSquare; m_shortcutKey = null; m_shortcutButton = null; m_altShortcutButton = null; m_shortcutSteamControllerButton = null; m_shortcutPrompt = new Text((height >= 60.0f) ? UIFonts.Default : UIFonts.Smaller, "", UIColours.White, TextAlignment.Left); m_shortcutPrompt.Visible = false; m_alwaysShowShortcutPrompt = false; m_allowDuringDialogue = false; m_hover = false; m_frame = 0; }
private async void OnShowKeybindDialog(ControllerButton Button) { var bindName = ControllerManager.GetActiveController().Type == ControllerType.DualShock4 ? ControllerData.DS4.ButtonNames[Button] : ControllerData.Xbox.ButtonNames[Button]; _bindDialog = await this.ShowProgressAsync(Properties.Resources.DialogBindKeyTitle, string.Format(Properties.Resources.DialogBindKeyText, bindName), true); await Task.Run((Action) delegate { while (!_bindDialog.IsCanceled) { Thread.Sleep(1); Key?pressedKey = null; foreach (Key key in Enum.GetValues(typeof(Key))) { bool keyDown = false; Application.Current.Dispatcher.Invoke((Action) delegate { try { keyDown = Keyboard.IsKeyDown(key); } catch { } }); if (!keyDown) { continue; } pressedKey = key; break; } var cancel = false; if (!pressedKey.HasValue) { continue; } switch (pressedKey) { case Key.Escape: cancel = true; break; default: break; } if (cancel) { break; } BindingManager.SetKeybind(Button, pressedKey.Value); BindingManager.SaveKeybinds(); break; } }) ; await _bindDialog.CloseAsync(); }
/// <summary> /// Initializes a new instance of the <see cref="Input"/> struct. /// </summary> /// <param name="actionName">The name of the action.</param> /// <param name="key">The key.</param> public Input(string actionName, Key key) { ActionName = actionName; this.key = key; joystickAxis = null; joystickButton = null; joystickHat = null; }
/// <summary> /// Initializes a new instance of the <see cref="Input"/> struct. /// </summary> /// <param name="actionName">The name of the action.</param> /// <param name="joystickHat">The joystick hat.</param> public Input(string actionName, JoystickHat joystickHat) { ActionName = actionName; key = null; joystickAxis = null; joystickButton = null; this.joystickHat = joystickHat; }
public List <Key?> GetActiveKeyList() { Key?somekey = _keypressed; return(new List <Key?> { _key }); }
public void KeyUp(Key?key) { if (key == _key) { IsKeyPressed = false; _keypressed = null; //Clear once released. } }
public SoundStore(Sound sound) { filePath = sound.FilePath; loop = sound.Loop; volume = sound.Volume; key = sound.Key; loopLatency = sound.LoopLatency; playLatency = sound.PlayLatency; }
/// <summary> /// Pokud se stiskla klávesa (detekuje pouze první stisk). /// </summary> /// <param name="key">Klávesa.</param> /// <returns>Vrací true, pokud se klávesa stiskla.</returns> public bool IsKeyPress(Key key) { if (pressedKey == key && keys.Count == 1) { bool pressed = pressedKey.HasValue; pressedKey = null; return pressed; } return false; }
/// <summary> /// Klávesa se uvolnila. /// </summary> /// <param name="e"></param> private void KeyUp(KeyboardKeyEventArgs e) { keys.RemoveAll(key => { return (key == e.Key); }); pressedKey = null; }
private void ConsoleTextBox_KeyDown(object sender,RoutedEventArgs e) { KeyEventArgs ke = (KeyEventArgs)e; if (ke.Key == System.Windows.Input.Key.Enter) { if (Session.IsConnected.HasValue && Session.IsConnected.Value == false) { Session.StreamWorkerBW.CancelAsync(); if(!Session.StreamWorkerBW.IsBusy) Session.StreamWorkerBW.RunWorkerAsync(); return; } } else if (ke.Key == System.Windows.Input.Key.Space) Session.WriteToStream(' '); else if (ke.Key == System.Windows.Input.Key.Back) { // { 0x08, 0x20, 0x08 }); Session.Stream.Write(new byte[] { 0x08 }, 0, 1); } else{ if (ke.Key == Key.LeftCtrl || ke.Key ==Key.LeftShift || ke.Key==Key.RightShift) pressedkey1 = ke.Key; else { if(pressedkey1 == Key.LeftCtrl) { if (ke.Key == Key.C) { Session.Stream.Write(new byte[] { 3 }, 0, 1); }else if(ke.Key == Key.Insert) { if(ConsoleTextBox.SelectedText!="") System.Windows.Forms.Clipboard.SetText(ConsoleTextBox.SelectedText); } } else { if(( pressedkey1 == Key.LeftShift || pressedkey1 == Key.RightShift ) && (ke.Key==Key.Insert)) { // code for paste string tmp = System.Windows.Forms.Clipboard.GetText(); foreach(char c in tmp) Session.WriteToStream(c); } } } } }
private void ConsoleTextBox_KeyUp(object sender, RoutedEventArgs e) { KeyEventArgs ke = (KeyEventArgs)e; if (ke.Key == pressedkey1) pressedkey1 = null; if (ke.Key == pressedkey2) pressedkey2 = null; }
/// <summary> /// Klávesa se stiskla. /// </summary> /// <param name="e"></param> private void KeyDown(KeyboardKeyEventArgs e) { if (!keys.Contains(e.Key)) keys.Add(e.Key); if (!pressedKey.HasValue) pressedKey = e.Key; }