public InterceptKeyEventArgs(Keys key, KeyDirection keyDirection, bool altPressed, bool controlPressed) { AltPressed = altPressed; ControlPressed = controlPressed; Key = key; KeyDirection = keyDirection; }
void Awake() { attack.Init(this, param); ReactiveProperty <Dir8> eyeDir = new ReactiveProperty <Dir8>(Dir8.D); KeyDirection .Where(key => key != Dir8.None) .Subscribe(key => eyeDir.Value = key); EyeDirection = eyeDir; attack.OnAttack.Subscribe(_ => _State.Value = EState.Attacking); attack.OnAttackFinished.Subscribe(_ => _State.Value = EState.Normal); }
//-------------------------------------------- // Reading the Keys for direction // Same used in One and Two Player mode //-------------------------------------------- public KeyDirection SetKeyDirection(KeyDirection PreviousDirection) { var direction = Console.ReadKey(true).Key; Thread.Sleep(10); switch (direction) { case ConsoleKey.DownArrow: if (PreviousDirection != KeyDirection.Up) { return(KeyDirection.Down); } break; case ConsoleKey.UpArrow: if (PreviousDirection != KeyDirection.Down) { return(KeyDirection.Up); } break; case ConsoleKey.LeftArrow: if (PreviousDirection != KeyDirection.Right) { return(KeyDirection.Left); } break; case ConsoleKey.RightArrow: if (PreviousDirection != KeyDirection.Left) { return(KeyDirection.Right); } break; case ConsoleKey.W: return(KeyDirection.W); case ConsoleKey.S: return(KeyDirection.S); case ConsoleKey.A: return(KeyDirection.A); case ConsoleKey.D: return(KeyDirection.D); } return(PreviousDirection); }
public void move(KeyDirection direction) { int newPosX = posX + ((int)direction * step); bool leftSideOut = newPosX < 0; bool rightSideOut = newPosX > canvas.Width - (width + 20); if (leftSideOut || rightSideOut) { newPosX = posX; } Canvas.SetLeft(rectangle, newPosX); posX = newPosX; rightEdge = posX + width; }
protected override void OnKeyUp(KeyEventArgs e) { if (this.m_KeyTimer.Enabled) { this.m_KeyTimer.Enabled = false; this.bPressed = false; this.m_KeyType = KeyDirection.None; } if (this.m_ParentFocused) { this.SendKeyUpToParent(e.KeyCode); } base.OnKeyUp(e); }
public Game(GameMode gameMode) { //-------------------------------------------- //Setting the size of the board //-------------------------------------------- this.BoardHeight = 20; this.BoardWidth = 60; //-------------------------------------------- // Creating Sprites for the game //-------------------------------------------- this.Food = new Food(this.BoardWidth, this.BoardHeight); this.Joystick = new Joystick(); this.Snake = new Snake(5, 10, 3); this.SnakePlayerTwo = new Snake(5, 15, 3); this.Board = new Board(this.BoardWidth, this.BoardHeight); this.Apple = new Apple(this.BoardWidth, this.BoardHeight); this.Energybar = new Energy(); //-------------------------------------------- // Changing colors and hiding cursor //-------------------------------------------- Console.CursorVisible = false; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Black; //-------------------------------------------- // Setting startvariables //-------------------------------------------- this.Score = 0; this.TwoPlayerScore = 0; this.Speed = 5; this.IsFoodEaten = false; this.Direction = KeyDirection.Right; this.GameRunning = true; if (gameMode == GameMode.SnakeVsApple) { this.AppleDirection = KeyDirection.None; } else { this.AppleDirection = KeyDirection.D; } this.SnakeDirection = KeyDirection.Right; this.SnakeDirectionPlayerTwo = KeyDirection.Right; this.GameMode = gameMode; this.OnePlayerFoodIsEaten = false; this.TwoPlayerFoodIsEaten = false; }
public AllDayListbox() { this.m_KeyType = KeyDirection.None; this.m_GridColor = SystemColors.ActiveBorder; this.m_SelectedForeColor = SystemColors.HighlightText; this.m_SelectedBackColor = SystemColors.Highlight; this.m_RowHeight = 15; this.m_SelectedRowIdx = -1; this.m_ParentFocused = true; this.InitializeComponent(); this.InitScrollBar(); this.InitTimer(); this.BackColor = SystemColors.Control; this.Font = new Font(this.Font.Name, this.Font.Size, FontStyle.Bold); }
/// <summary> /// Sends the specified key, optionally indicating modifiers and duration. /// </summary> /// <param name="key"></param> /// <param name="modifiers"></param> /// <param name="duration"></param> /// <returns></returns> public async Task SendKey(string key, KeyDirection direction = KeyDirection.PressAndRelease, IList <string> modifiers = null, Duration duration = null) { if (string.IsNullOrEmpty(key)) { return; } if (duration == null) { duration = AverageKeypressDuration; } // KeyNames of length == 1 are case-sensitive. if (key.Length > 1) { key = key.ToLowerInvariant(); } if (!Keys.ContainsKey(key)) { return; } var keyValue = Keys[key]; var modifiersValue = GetModifiers(keyValue.Item2, modifiers); switch (direction) { case KeyDirection.Press: SendKeyPress(keyValue.Item1, modifiersValue); break; case KeyDirection.Release: SendKeyRelease(keyValue.Item1, modifiersValue); break; case KeyDirection.PressAndRelease: default: SendKeyPress(keyValue.Item1, modifiersValue); await Util.Hesitate(duration); SendKeyRelease(keyValue.Item1, modifiersValue); break; } }
//Creates a Dictionary with Key Directions to simulate clicks. private Dictionary <double, KeyDirection> GetClicks() { var clickInformation = new Dictionary <double, KeyDirection>(); var hitObjects = HumanizeClicks(); if (hitObjects == null) { return(null); } foreach (var hitObject in hitObjects) { KeyDirection value = 0; foreach (var data in hitObject.Data) { if (data == "SpawnObj") { continue; } if (data.Contains("Up")) { value |= KeyDirection.Up; } if (data.Contains("Down")) { value |= KeyDirection.Down; } if (data.Contains("Left")) { value |= KeyDirection.Left; } if (data.Contains("Right")) { value |= KeyDirection.Right; } } clickInformation.Add(hitObject.Time, value); } return(clickInformation); }
/// <summary> /// Visual Studio hooks PreTranslateMessage and will process keyboard input there if it maps to a /// command keyboard binding. Textual input is *not* handled here but keys like Esc, Up, Down, etc ... /// are. They need to be routed directly to IOleCommandTarget /// </summary> protected override bool PreProcess(KeyDirection keyDirection, KeyInput keyInput, Key key, ModifierKeys modifierKeys) { // Visual Studio only intercepts the down events. if (keyDirection != KeyDirection.Down) { return false; } switch (keyInput.Key) { case VimKey.Escape: case VimKey.Back: case VimKey.Up: case VimKey.Down: case VimKey.Left: case VimKey.Right: case VimKey.Tab: return _vsSimulation.RunInOleCommandTarget(keyInput); default: return false; } }
//-------------------------------------------- // Setting new values for the coordinates of // the apple //-------------------------------------------- public KeyDirection Move(KeyDirection direction) { switch (direction) { case KeyDirection.W: if (this.Y > 1) { this.Rotten--; this.Y--; } break; case KeyDirection.S: if (Y < MaxHeight - 1) { this.Rotten--; this.Y++; } break; case KeyDirection.A: if (X > 1) { this.Rotten--; this.X--; } break; case KeyDirection.D: if (X < MaxWidth - 1) { this.Rotten--; this.X++; } break; } return(KeyDirection.None); }
/// <summary> /// Visual Studio hooks PreTranslateMessage and will process keyboard input there if it maps to a /// command keyboard binding. Textual input is *not* handled here but keys like Esc, Up, Down, etc ... /// are. They need to be routed directly to IOleCommandTarget /// </summary> protected override bool PreProcess(KeyDirection keyDirection, KeyInput keyInput, Key key, ModifierKeys modifierKeys) { // Visual Studio only intercepts the down events. if (keyDirection != KeyDirection.Down) { return(false); } switch (keyInput.Key) { case VimKey.Escape: case VimKey.Back: case VimKey.Up: case VimKey.Down: case VimKey.Left: case VimKey.Right: case VimKey.Tab: return(_vsSimulation.RunInOleCommandTarget(keyInput)); default: return(false); } }
//Calls the real Keypress private void Click(KeyDirection direction, double time) { if ((direction & KeyDirection.Left) == KeyDirection.Left) { Keyboard.PressKey(VirtualKeyShort.KEY_D); } if ((direction & KeyDirection.Up) == KeyDirection.Up) { Keyboard.PressKey(VirtualKeyShort.KEY_F); } if ((direction & KeyDirection.Down) == KeyDirection.Down) { Keyboard.PressKey(VirtualKeyShort.KEY_J); } if ((direction & KeyDirection.Right) == KeyDirection.Right) { Keyboard.PressKey(VirtualKeyShort.KEY_K); } Console.WriteLine($"[EMULATING] {direction} at {time}s"); }
/// <summary> /// This is intended to simulate the pre-processing of input similar to pre-process message. This will /// return true if the event was handled /// </summary> protected virtual bool PreProcess(KeyDirection keyDirection, KeyInput keyInput, Key key, ModifierKeys modifierKeys) { return(false); }
internal KeyEvent ToKeyEvent(KeyDirection keyDirection) { KeyEvent keyEvent = new KeyEvent(); if (Key.HasValue) { keyEvent.Key = Key.Value; } if (ScanCode.HasValue) { keyEvent.ScanCode = ScanCode.Value; } keyEvent.Direction = keyDirection; keyEvent.Extended = Extended; return keyEvent; }
public void RemoveHandler(KeyCode keyCode, Modifiers modifiers, KeyDirection direction, KeyboardEventHandler handler) => RemoveHandler((ushort)keyCode, modifiers, direction, handler);
public KeyInputValue(Key keySource, KeyDirection direction) : base(Core.InputType.Keyboard, null, new KeyValue(direction)) { KeySource = keySource; }
public KeyOperation(Key key, KeyDirection direction) { Key = key; Direction = direction; }
// public static float GetAxis(KEY_ACTION key, bool isGlobal = false) // { // if (!InputManager.bActive || InputManager.s_lockThisFrame) // { // return 0f; // } // if (!InputManager.GameKeyList[key].HasAxis) // { // return 0f; // } // float axis; // if (isGlobal) // { // axis = Input.GetAxis(InputManager.GameKeyList[key].Axis); // } // else // { // axis = Input.GetAxis(InputManager.GameKeyList[key].Axis); // } // if (InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Both) // { // return axis; // } // if ((axis > 0f && InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Positive) || (axis < 0f && InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Negative)) // { // return Mathf.Abs(axis); // } // return 0f; // } // public static float GetAxisRaw(KEY_ACTION key, bool isGlobal = false) // { // if (!InputManager.bActive || InputManager.s_lockThisFrame) // { // return 0f; // } // if (!InputManager.GameKeyList[key].HasAxis) // { // return 0f; // } // float axisRaw; // if (isGlobal) // { // axisRaw = Input.GetAxisRaw(InputManager.GameKeyList[key].Axis); // } // else // { // axisRaw = Input.GetAxisRaw(InputManager.GameKeyList[key].Axis); // } // if (InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Both) // { // return axisRaw; // } // if ((axisRaw > 0f && InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Positive) || (axisRaw < 0f && InputManager.GameKeyList[key].AxisDirection == AxisDirectionType.Negative)) // { // return Mathf.Abs(axisRaw); // } // return 0f; // } // public static bool GetAxisActive(KEY_ACTION key, bool isGlobal = false) // { // if (!InputManager.bActive || InputManager.s_lockThisFrame) // { // return false; // } // if (InputManager.GameKeyList[key].HasAxis) // { // bool result; // if (isGlobal) // { // result = InputManager.GameKeyList[key].AxisActive; // } // else // { // result = InputManager.GameKeyList[key].AxisActive_SinglePad; // } // return result; // } // return false; // } // public static void SetMappingKey(KEY_ACTION keyIndex, KeyCode keyCode) // { // InputManager.GameKeyList[keyIndex].Code = keyCode; // } // public static void SetMappingAxis(KEY_ACTION keyIndex, string axis, AxisDirectionType dir) // { // InputManager.GameKeyList[keyIndex].Axis = axis; // InputManager.GameKeyList[keyIndex].AxisDirection = dir; // } // public static KeyCode GetMappingKey(KEY_ACTION keyIndex) // { // if (!InputManager.GameKeyList.ContainsKey(keyIndex)) // { // return KeyCode.None; // } // return InputManager.GameKeyList[keyIndex].Code; // } // public static string GetMappingAxis(KEY_ACTION keyIndex) // { // if (!InputManager.GameKeyList.ContainsKey(keyIndex)) // { // return string.Empty; // } // return InputManager.GameKeyList[keyIndex].Axis; // } // public static AxisDirectionType GetMappingAxisDirection(KEY_ACTION keyIndex) // { // if (!InputManager.GameKeyList.ContainsKey(keyIndex)) // { // return AxisDirectionType.None; // } // return InputManager.GameKeyList[keyIndex].AxisDirection; // } private static void UpdateDir() { float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; if (InputManager.GetKey(KEY_ACTION.UPARROW, false) || InputManager.GetKey(KEY_ACTION.UP, false)) { num = 1f; } else if (InputManager.GetKey(KEY_ACTION.DOWNARROW, false) || InputManager.GetKey(KEY_ACTION.DOWN, false)) { num2 = 1f; } if (InputManager.GetKey(KEY_ACTION.LEFTARROW, false) || InputManager.GetKey(KEY_ACTION.LEFT, false)) { num3 = 1f; } else if (InputManager.GetKey(KEY_ACTION.RIGHTARROW, false) || InputManager.GetKey(KEY_ACTION.RIGHT, false)) { num4 = 1f; } if (num > 0f) { InputManager.m_MoveDir.z = num; InputManager.curKeyDir |= KeyDirection.W; if ((InputManager.curKeyDir & KeyDirection.S) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.S; } } else if (num2 > 0f) { InputManager.m_MoveDir.z = num2 * -1f; InputManager.curKeyDir |= KeyDirection.S; if ((InputManager.curKeyDir & KeyDirection.W) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.W; } } else { InputManager.m_MoveDir.z = 0f; if ((InputManager.curKeyDir & KeyDirection.S) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.S; } if ((InputManager.curKeyDir & KeyDirection.W) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.W; } } if (num3 > 0f) { InputManager.m_MoveDir.x = num3 * -1f; InputManager.curKeyDir |= KeyDirection.A; if ((InputManager.curKeyDir & KeyDirection.D) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.D; } } else if (num4 > 0f) { InputManager.m_MoveDir.x = num4; InputManager.curKeyDir |= KeyDirection.D; if ((InputManager.curKeyDir & KeyDirection.A) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.A; } } else { InputManager.m_MoveDir.x = 0f; if ((InputManager.curKeyDir & KeyDirection.D) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.D; } if ((InputManager.curKeyDir & KeyDirection.A) > KeyDirection.NONE) { InputManager.curKeyDir ^= KeyDirection.A; } } }
bool HandleKeyboardScrollKey(Gdk.EventKey press, KeyDirection direction) { bool handled = false; // FIXME: hard-coded grid logic here... bool grid = ViewLayout != null; int items_per_row = grid ? (ViewLayout as DataViewLayoutGrid).Columns : 1; switch (press.Key) { case Gdk.Key.k: case Gdk.Key.K: case Gdk.Key.Up: case Gdk.Key.KP_Up: if (!HeaderFocused) { handled = (direction == KeyDirection.Press) ? KeyboardScroll(press.State, -items_per_row, true) : UpdateSelectionForKeyboardScroll(press.State, -items_per_row); } break; case Gdk.Key.j: case Gdk.Key.J: case Gdk.Key.Down: case Gdk.Key.KP_Down: if (direction == KeyDirection.Press) { if (!HeaderFocused) { handled = KeyboardScroll(press.State, items_per_row, true); } else { handled = true; HeaderFocused = false; } } else if (!HeaderFocused) { handled = UpdateSelectionForKeyboardScroll(press.State, items_per_row); } break; case Gdk.Key.l: case Gdk.Key.L: case Gdk.Key.Right: case Gdk.Key.KP_Right: handled = true; if (direction == KeyDirection.Press) { if (grid && !HeaderFocused) { handled = KeyboardScroll(press.State, 1, true); } else if (ActiveColumn + 1 < column_cache.Length) { ActiveColumn++; InvalidateHeader(); } } else if (grid && !HeaderFocused) { handled = UpdateSelectionForKeyboardScroll(press.State, 1); } break; case Gdk.Key.h: case Gdk.Key.H: case Gdk.Key.Left: case Gdk.Key.KP_Left: handled = true; if (direction == KeyDirection.Press) { if (grid && !HeaderFocused) { handled = KeyboardScroll(press.State, -1, true); } else if (ActiveColumn - 1 >= 0) { ActiveColumn--; InvalidateHeader(); } } else if (grid && !HeaderFocused) { handled = UpdateSelectionForKeyboardScroll(press.State, -1); } break; case Gdk.Key.Page_Up: case Gdk.Key.KP_Page_Up: if (!HeaderFocused) { int relativeRow = (int)(-vadjustment.PageIncrement / (double)ChildSize.Height) * items_per_row; handled = vadjustment != null && (direction == KeyDirection.Press ? KeyboardScroll(press.State, relativeRow, false) : UpdateSelectionForKeyboardScroll(press.State, relativeRow)); } break; case Gdk.Key.Page_Down: case Gdk.Key.KP_Page_Down: if (!HeaderFocused) { int relativeRow = (int)(vadjustment.PageIncrement / (double)ChildSize.Height) * items_per_row; handled = vadjustment != null && (direction == KeyDirection.Press ? KeyboardScroll(press.State, relativeRow, false) : UpdateSelectionForKeyboardScroll(press.State, relativeRow)); } break; case Gdk.Key.Home: case Gdk.Key.KP_Home: if (!HeaderFocused) { handled = direction == KeyDirection.Press ? KeyboardScroll(press.State, int.MinValue, true) : UpdateSelectionForKeyboardScroll(press.State, int.MinValue); } break; case Gdk.Key.End: case Gdk.Key.KP_End: if (!HeaderFocused) { handled = direction == KeyDirection.Press ? KeyboardScroll(press.State, int.MaxValue, true) : UpdateSelectionForKeyboardScroll(press.State, int.MaxValue); } break; } return(handled); }
public void AddHandler(KeyCode keyCode, KeyDirection direction, Modifiers modifiers, KeyboardEventHandler handler) => AddHandler((ushort)keyCode, direction, modifiers, handler);
protected override void OnLostFocus(EventArgs e) { if (this.m_KeyTimer.Enabled) { this.m_KeyTimer.Enabled = false; this.bPressed = false; this.m_KeyType = KeyDirection.None; } base.OnLostFocus(e); }
public KeyValue(KeyDirection direction) { KeyType = Core.KeyType.Direction; Direction = direction; Command = ""; }
public bool Run() { while (GameRunning) { if (GameMode == GameMode.SinglePlayer) { if (Snake.CheckBoardCollision(Board)) { GameRunning = false; this.Winner = "Someone Else"; break; } if (Snake.CheckTailCollision()) { GameRunning = false; this.Winner = "Someone Else"; break; } } //-------------------------------------------- // Check for collision with tail and board //-------------------------------------------- if (GameMode == GameMode.SnakeVsApple) { if (Snake.CheckBoardCollision(Board)) { GameRunning = false; this.Winner = "Apple"; break; } if (Snake.CheckTailCollision()) { GameRunning = false; this.Winner = "Apple"; break; } } else if (GameMode == GameMode.SnakeVsSnake) { //-------------------------------------------- // Check for collision on Snake Player Two //-------------------------------------------- if (SnakePlayerTwo.CheckBoardCollision(Board)) { GameRunning = false; this.Winner = "Player 1"; break; } if (SnakePlayerTwo.CheckTailCollision()) { GameRunning = false; this.Winner = "Player 1"; break; } if (SnakePlayerTwo.CheckSnakeCollision(Snake)) { GameRunning = false; this.Winner = "Player 1"; break; } //-------------------------------------------- // Check for collision with other Snake //-------------------------------------------- //if (Snake.CheckSnakeCollision(SnakePlayerTwo)) //{ // GameRunning = false; // this.Winner = "Player 2"; // break; //} } //-------------------------------------------- // Getting movement direction //-------------------------------------------- if (Console.KeyAvailable) { Direction = Joystick.SetKeyDirection(SnakeDirection); if (Direction == KeyDirection.Up || Direction == KeyDirection.Down || Direction == KeyDirection.Left || Direction == KeyDirection.Right) { SnakeDirection = Direction; } else { AppleDirection = Direction; } } //-------------------------------------------- // Eating of the apple //-------------------------------------------- if (GameMode == GameMode.SnakeVsApple) { SnakeEnergy = Snake.GetEnergy(); IsFoodEaten = Snake.Eat(Apple); } else if (GameMode == GameMode.SinglePlayer) { IsFoodEaten = Snake.Eat(Food); } else if (GameMode == GameMode.SnakeVsSnake) { OnePlayerFoodIsEaten = Snake.Eat(Food); TwoPlayerFoodIsEaten = SnakePlayerTwo.Eat(Food); if (OnePlayerFoodIsEaten) { Score++; IsFoodEaten = true; } if (TwoPlayerFoodIsEaten) { TwoPlayerScore++; IsFoodEaten = true; } } Apple.EraseOldApple(); if (GameMode == GameMode.SnakeVsApple) { Snake.Move(SnakeDirection, IsFoodEaten); AppleDirection = Apple.Move(AppleDirection); } else if (GameMode == GameMode.SnakeVsSnake) { SnakeDirectionPlayerTwo = SnakePlayerTwo.TranslateAppleDirectionToSnake(AppleDirection, SnakeDirectionPlayerTwo); Snake.Move(SnakeDirection, OnePlayerFoodIsEaten); SnakePlayerTwo.Move(SnakeDirectionPlayerTwo, TwoPlayerFoodIsEaten); } else if (GameMode == GameMode.SinglePlayer) { Snake.Move(SnakeDirection, IsFoodEaten); } if (IsFoodEaten) { if (GameMode == GameMode.SnakeVsApple) { Apple.LoseLife(); Apple.MakeFood(BoardWidth, BoardHeight); Energy = Apple.GetEnergy(); Snake.GetEnergyFromApple(Energy); } else if (GameMode == GameMode.SnakeVsSnake) { Food.MakeFood(BoardWidth, BoardHeight); IsFoodEaten = false; } else { Score++; Food.MakeFood(BoardWidth, BoardHeight); } } //-------------------------------------------- // Drawing the graphics in both modes //-------------------------------------------- Snake.Draw("Green"); //-------------------------------------------- // Drawing different for Two vs One Player mode //-------------------------------------------- if (GameMode == GameMode.SnakeVsApple) { Apple.RottTheApple(); Energybar.Draw(BoardHeight, SnakeEnergy); Snake.LoseEnergy(); Apple.Draw(); Apple.DrawLifes(BoardHeight); } else if (GameMode == GameMode.SnakeVsSnake) { SnakePlayerTwo.Draw("Magenta"); Food.Draw(); } else { Food.Draw(); ShowScore(Score, BoardHeight); } if (SnakeEnergy < 1 && GameMode == GameMode.SnakeVsApple) { this.GameRunning = false; this.Winner = "Apple"; } if (Apple.GetLifes() < 1 && GameMode == GameMode.SnakeVsApple) { this.GameRunning = false; this.Winner = "Snake"; } //-------------------------------------------- // Timer for loop //-------------------------------------------- Thread.Sleep(100 - Speed); } Console.Clear(); Console.ForegroundColor = ConsoleColor.White; GameOver(this.Winner); bool playAgain = AskIfPlayAgain(); return(playAgain); }
protected override void OnKeyDown(KeyEventArgs e) { if (this.bPressed) { e.Handled = true; return; } if (this.m_ParentFocused) { this.SendKeyDownToParent(e.KeyCode); } else { switch (e.KeyCode) { case Keys.Up: if ((this.SelectedIndex > this.m_vs.Minimum) && ((this.SelectedIndex - 1) >= 0)) { int num2; this.SelectedIndex = num2 = this.SelectedIndex - 1; this.EnsureVisible(num2, true); this.bPressed = true; this.m_KeyType = KeyDirection.Up; this.m_KeyTimer.Enabled = true; } goto Label_0118; case Keys.Right: goto Label_0118; case Keys.Down: if ((this.SelectedIndex >= this.m_vs.Maximum) || ((this.SelectedIndex + 1) >= this.m_Items.Count)) { this.ParentFocused = true; } else { int num; this.SelectedIndex = num = this.SelectedIndex + 1; this.EnsureVisible(num, true); this.bPressed = true; this.m_KeyType = KeyDirection.Down; this.m_KeyTimer.Enabled = true; } goto Label_0118; case Keys.Return: if (this.SelectedIndex >= 0) { this.OnRowEntered(); } goto Label_0118; } } Label_0118: base.OnKeyDown(e); }
//Fakes keypresses //This should be humanized more: Key releases should differ private void PressKeys(double timeToPress) { KeyDirection keysToPress = playObj.ElementAt(currentNote).Value; Click(keysToPress, timeToPress); }
/// <summary> /// This is intended to simulate the pre-processing of input similar to pre-process message. This will /// return true if the event was handled /// </summary> protected virtual bool PreProcess(KeyDirection keyDirection, KeyInput keyInput, Key key, ModifierKeys modifierKeys) { return false; }
public static string BuildXtensiveType(KeyDirection enumValue) { return(BuildXtensiveType(OrmNamespace.Core, ENUM_TYPE_DIRECTION, enumValue)); }