示例#1
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            _engine.Invoke("window", "HandleKey", this, e);

            if( !e.Handled )
                base.OnKeyUp(e);
        }
 protected override void OnKeyPress(KeyEventArgs e)
 {
     var previousText = Text;
     var previousCursorPosition = CursorPosition;
     base.OnKeyPress(e);
     if (Text.Length == 0 && _defaultValue != String.Empty) {
         Text = _defaultValue;
     } else if (_validationRegex.Any(i => !i.IsMatch(Text))) {
         Text = previousText;
         CursorPosition = previousCursorPosition;
     }
 }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnKeyPress(KeyEventArgs e)
        {
            base.OnKeyPress(e);

              if (e.Key == Keys.Right)
              {
            ItemIndex += 1;
            e.Handled = true;
              }
              if (e.Key == Keys.Left)
              {
            ItemIndex -= 1;
            e.Handled = true;
              }

              if (ItemIndex > Items.Count - 1) ItemIndex = 0;
              if (ItemIndex < 0) ItemIndex = Items.Count - 1;

              if (e.Key == Keys.Down && Items.Count > 0 && Items[ItemIndex].Items.Count > 0)
              {
            e.Handled = true;
            OnClick(new MouseEventArgs(new MouseState(), MouseButton.None, Point.Zero));
              }
              if (e.Key == Keys.Escape)
              {
            e.Handled = true;
            ItemIndex = -1;
              }
        }
示例#4
0
    ////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////
    void btnSlider_KeyPress(object sender, KeyEventArgs e)
    {
      if (e.Key == Microsoft.Xna.Framework.Input.Keys.Left || e.Key == Microsoft.Xna.Framework.Input.Keys.Down) Value -= stepSize;
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Right || e.Key == Microsoft.Xna.Framework.Input.Keys.Up) Value += stepSize;
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.PageDown) Value -= pageSize;
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.PageUp) Value += pageSize;
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Home) Value = 0;
      else if (e.Key == Microsoft.Xna.Framework.Input.Keys.End) Value = Range;
    }
 ////////////////////////////////////////////////////////////////////////////      
 ////////////////////////////////////////////////////////////////////////////
 void Input_KeyDown(object sender, KeyEventArgs e)
 {
     if (Visible && (Manager.FocusedControl != null && Manager.FocusedControl.Root == this) &&
       e.Key ==SharpDX.Toolkit.Input.Keys.Escape)
       {
     //Close(ModalResult.Cancel);
       }
 }
 ////////////////////////////////////////////////////////////////////////////     
 ////////////////////////////////////////////////////////////////////////////     
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Keys.Down)
       {
     e.Handled = true;
     btnDown_Click(this, new MouseEventArgs());
       }
       base.OnKeyDown(e);
 }
		////////////////////////////////////////////////////////////////////////////      

		////////////////////////////////////////////////////////////////////////////
		void Input_KeyDown(object sender, KeyEventArgs e)
		{
			if (Visible && (Manager.FocusedControl != null && Manager.FocusedControl.Root == this) &&
				e.Key == Microsoft.Xna.Framework.Input.Keys.Escape)
			{
				//Close(ModalResult.Cancel);
			}
		}
        ////////////////////////////////////////////////////////////////////////////    
        ////////////////////////////////////////////////////////////////////////////
        private void UpdateKeys(KeyboardState state, GameTime gameTime)
        {
            #if (!XBOX && !XBOX_FAKE)

              KeyEventArgs e = new KeyEventArgs();

              e.Caps = (((ushort)NativeMethods.GetKeyState(0x14)) & 0xffff) != 0;

              List<Keys> downKeys = new List<Keys>();
              state.GetDownKeys(downKeys);
              foreach (Keys key in downKeys)
              {
            if (key == Keys.LeftAlt || key == Keys.RightAlt) e.Alt = true;
            else if (key == Keys.LeftShift || key == Keys.RightShift) e.Shift = true;
            else if (key == Keys.LeftControl || key == Keys.RightControl) e.Control = true;
              }

              foreach (InputKey key in keys)
              {
            if (key.Key == Keys.LeftAlt || key.Key == Keys.RightAlt ||
            key.Key == Keys.LeftShift || key.Key == Keys.RightShift ||
            key.Key == Keys.LeftControl || key.Key == Keys.RightControl)
            {
              continue;
            }

            bool pressed = state.IsKeyDown(key.Key);

            double ms = gameTime.ElapsedGameTime.TotalMilliseconds;
            if (pressed) key.Countdown -= ms;

            if ((pressed) && (!key.Pressed))
            {
              key.Pressed = true;
              e.Key = key.Key;

              if (KeyDown != null) KeyDown.Invoke(this, e);
              if (KeyPress != null) KeyPress.Invoke(this, e);
            }
            else if ((!pressed) && (key.Pressed))
            {
              key.Pressed = false;
              key.Countdown = RepeatDelay;
              e.Key = key.Key;

              if (KeyUp != null) KeyUp.Invoke(this, e);
            }
            else if (key.Pressed && key.Countdown < 0)
            {
              key.Countdown = RepeatRate;
              e.Key = key.Key;

              if (KeyPress != null) KeyPress.Invoke(this, e);
            }
              }
              #endif
        }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnKeyPress(KeyEventArgs e)
        {
            if (e.Key == Keys.Up)
              {
            e.Handled = true;
            ShiftIndex(true);
              }
              else if (e.Key == Keys.Down)
              {
            e.Handled = true;
            ShiftIndex(false);
              }

              base.OnKeyPress(e);
        }
示例#10
0
 void Txt_KeyPress(object sender, KeyEventArgs e)
 {
     if (e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
         OnEnterPressed(new TomShane.Neoforce.Controls.EventArgs());
 }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnKeyPress(KeyEventArgs e)
        {
            if (e.Key == Keys.Down)
            {
                e.Handled = true;
                itemIndex += sbVert.StepSize / 10;
            }
            else if (e.Key == Keys.Up)
            {
                e.Handled = true;
                itemIndex -= sbVert.StepSize / 10;
            }
            else if (e.Key == Keys.PageDown)
            {
                e.Handled = true;
                itemIndex += sbVert.PageSize / 10;
            }
            else if (e.Key == Keys.PageUp)
            {
                e.Handled = true;
                itemIndex -= sbVert.PageSize / 10;
            }
            else if (e.Key == Keys.Home)
            {
                e.Handled = true;
                itemIndex = 0;
            }
            else if (e.Key == Keys.End)
            {
                e.Handled = true;
                itemIndex = items.Count - 1;
            }

            if (itemIndex < 0) itemIndex = 0;
            else if (itemIndex >= Items.Count) itemIndex = Items.Count - 1;

            ItemIndex = itemIndex;

            base.OnKeyPress(e);
        }
示例#12
0
        //////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Methods ///////////

        ////////////////////////////////////////////////////////////////////////////
        protected override string KeyToString(KeyEventArgs args)
        {
            switch (args.Key)
            {
            case Keys.D0:
                return((args.Shift) ? "=" : "0");

            case Keys.D1:
                return((args.Shift) ? "!" : "1");

            case Keys.D2:
                return((args.Shift) ? "\"" : "2");

            case Keys.D3:
                return((args.Shift) ? "�" : "3");

            case Keys.D4:
                return((args.Shift) ? "$" : "4");

            case Keys.D5:
                return((args.Shift) ? "%" : "5");

            case Keys.D6:
                return((args.Shift) ? "&" : "6");

            case Keys.D7:
                return((args.Shift) ? "/" : "7");

            case Keys.D8:
                return((args.Shift) ? "(" : "8");

            case Keys.D9:
                return((args.Shift) ? ")" : "9");

            case Keys.OemBackslash:
                return((args.Shift) ? ">" : "<");

            case Keys.OemPlus:
                return((args.Shift) ? "*" : "+");

            case Keys.OemMinus:
                return((args.Shift) ? "_" : "-");

            case Keys.OemOpenBrackets:
                return((args.Shift) ? "?" : "�");

            case Keys.OemCloseBrackets:
                return((args.Shift) ? "`" : "�");

            case Keys.OemQuestion:
                return((args.Shift) ? "'" : "#");

            case Keys.OemPeriod:
                return((args.Shift) ? ":" : ".");

            case Keys.OemComma:
                return((args.Shift) ? ";" : ",");

            case Keys.OemPipe:
                return((args.Shift) ? "�" : "^");

            case Keys.Space:
                return(" ");

            case Keys.OemSemicolon:
                return((args.Shift) ? "�" : "�");

            case Keys.OemQuotes:
                return((args.Shift) ? "�" : "�");

            case Keys.Decimal:
                return((args.Shift) ? "" : ".");

            default:
                return(base.KeyToString(args));
            }
        }
示例#13
0
        //////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Methods ///////////

        ////////////////////////////////////////////////////////////////////////////
        protected override string KeyToString(KeyEventArgs args)
        {
            switch (args.Key)
            {
            case Keys.D0:
                return((args.Shift) ? "0" : "�");

            case Keys.D1:
                return((args.Shift) ? "1" : "+");

            case Keys.D2:
                return((args.Shift) ? "2" : "�");

            case Keys.D3:
                return((args.Shift) ? "3" : "�");

            case Keys.D4:
                return((args.Shift) ? "4" : "�");

            case Keys.D5:
                return((args.Shift) ? "5" : "�");

            case Keys.D6:
                return((args.Shift) ? "6" : "�");

            case Keys.D7:
                return((args.Shift) ? "7" : "�");

            case Keys.D8:
                return((args.Shift) ? "8" : "�");

            case Keys.D9:
                return((args.Shift) ? "9" : "�");

            case Keys.OemPlus:
                return((args.Shift) ? "�" : "�");

            case Keys.OemMinus:
                return((args.Shift) ? "%" : "=");

            case Keys.OemOpenBrackets:
                return((args.Shift) ? "/" : "�");

            case Keys.OemCloseBrackets:
                return((args.Shift) ? "(" : ")");

            case Keys.OemQuestion:
                return((args.Shift) ? "_" : "-");

            case Keys.OemPeriod:
                return((args.Shift) ? ":" : ".");

            case Keys.OemComma:
                return((args.Shift) ? "?" : ",");

            case Keys.OemPipe:
                return((args.Shift) ? "'" : "�");

            case Keys.Space:
                return(" ");

            case Keys.OemSemicolon:
                return((args.Shift) ? "\"" : "�");

            case Keys.OemQuotes:
                return((args.Shift) ? "!" : "�");

            case Keys.OemTilde:
                return((args.Shift) ? "�" : ";");

            case Keys.Decimal:
                return((args.Shift) ? "" : ",");

            default:
                return(base.KeyToString(args));
            }
        }
示例#14
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected virtual string KeyToString(KeyEventArgs args)
        {
            switch (args.Key)
            {
            case Keys.A:
                return("a");

            case Keys.B:
                return("b");

            case Keys.C:
                return("c");

            case Keys.D:
                return("d");

            case Keys.E:
                return("e");

            case Keys.F:
                return("f");

            case Keys.G:
                return("g");

            case Keys.H:
                return("h");

            case Keys.I:
                return("i");

            case Keys.J:
                return("j");

            case Keys.K:
                return("k");

            case Keys.L:
                return("l");

            case Keys.M:
                return("m");

            case Keys.N:
                return("n");

            case Keys.O:
                return("o");

            case Keys.P:
                return("p");

            case Keys.Q:
                return("q");

            case Keys.R:
                return("r");

            case Keys.S:
                return("s");

            case Keys.T:
                return("t");

            case Keys.U:
                return("u");

            case Keys.V:
                return("v");

            case Keys.W:
                return("w");

            case Keys.X:
                return("x");

            case Keys.Y:
                return("y");

            case Keys.Z:
                return("z");

            case Keys.D0:
                return((args.Shift) ? ")" : "0");

            case Keys.D1:
                return((args.Shift) ? "!" : "1");

            case Keys.D2:
                return((args.Shift) ? "@" : "2");

            case Keys.D3:
                return((args.Shift) ? "#" : "3");

            case Keys.D4:
                return((args.Shift) ? "$" : "4");

            case Keys.D5:
                return((args.Shift) ? "%" : "5");

            case Keys.D6:
                return((args.Shift) ? "^" : "6");

            case Keys.D7:
                return((args.Shift) ? "&" : "7");

            case Keys.D8:
                return((args.Shift) ? "*" : "8");

            case Keys.D9:
                return((args.Shift) ? "(" : "9");

            case Keys.OemPlus:
                return((args.Shift) ? "+" : "=");

            case Keys.OemMinus:
                return((args.Shift) ? "_" : "-");

            case Keys.OemOpenBrackets:
                return((args.Shift) ? "{" : "[");

            case Keys.OemCloseBrackets:
                return((args.Shift) ? "}" : "]");

            case Keys.OemQuestion:
                return((args.Shift) ? "?" : "/");

            case Keys.OemPeriod:
                return((args.Shift) ? ">" : ".");

            case Keys.OemComma:
                return((args.Shift) ? "<" : ",");

            case Keys.OemPipe:
                return((args.Shift) ? "|" : "\\");

            case Keys.Space:
                return(" ");

            case Keys.OemSemicolon:
                return((args.Shift) ? ":" : ";");

            case Keys.OemQuotes:
                return((args.Shift) ? "\"" : "'");

            case Keys.OemTilde:
                return((args.Shift) ? "~" : "`");

            case Keys.NumPad0:
                return((args.Shift) ? "" : "0");

            case Keys.NumPad1:
                return((args.Shift) ? "" : "1");

            case Keys.NumPad2:
                return((args.Shift) ? "" : "2");

            case Keys.NumPad3:
                return((args.Shift) ? "" : "3");

            case Keys.NumPad4:
                return((args.Shift) ? "" : "4");

            case Keys.NumPad5:
                return((args.Shift) ? "" : "5");

            case Keys.NumPad6:
                return((args.Shift) ? "" : "6");

            case Keys.NumPad7:
                return((args.Shift) ? "" : "7");

            case Keys.NumPad8:
                return((args.Shift) ? "" : "8");

            case Keys.NumPad9:
                return((args.Shift) ? "" : "9");

            case Keys.Decimal:
                return((args.Shift) ? "" : ".");

            case Keys.Divide:
                return((args.Shift) ? "/" : "/");

            case Keys.Multiply:
                return((args.Shift) ? "*" : "*");

            case Keys.Subtract:
                return((args.Shift) ? "-" : "-");

            case Keys.Add:
                return((args.Shift) ? "+" : "+");

            default:
                return("");
            }
        }