Exemplo n.º 1
1
    protected override void OnKeyPress(KeyPressEventArgs e)
    {
        base.OnKeyPress(e);

        if (e.KeyChar == 27)
        {
            Exit();
        }

        switch (e.KeyChar)
        {
            case 'w':
                camera.Move(0f, 0.1f, 0f);
                break;
            case 'a':
                camera.Move(-0.1f, 0f, 0f);
                break;
            case 's':
                camera.Move(0f, -0.1f, 0f);
                break;
            case 'd':
                camera.Move(0.1f, 0f, 0f);
                break;
            case 'q':
                camera.Move(0f, 0f, 0.1f);
                break;
            case 'e':
                camera.Move(0f, 0f, -0.1f);
                break;
        }
    }
Exemplo n.º 2
0
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     base.OnKeyPress(e);
     if (e.KeyChar == 'w' || e.KeyChar == 'W')
     {
         camera.Position += camera.Attitude.Direction;
     }
     else if (e.KeyChar == 's' || e.KeyChar == 'S')
     {
         camera.Position -= camera.Attitude.Direction;
     }
     else if (e.KeyChar == 'd' || e.KeyChar == 'D')
     {
         camera.Position += camera.Attitude.Side;
     }
     else if (e.KeyChar == 'a' || e.KeyChar == 'A')
     {
         camera.Position -= camera.Attitude.Side;
     }
     else if (e.KeyChar == 'u' || e.KeyChar == 'U')
     {
         camera.Position += camera.Attitude.Up;
     }
     else if (e.KeyChar == 'j' || e.KeyChar == 'J')
     {
         camera.Position -= camera.Attitude.Up;
     }
 }
Exemplo n.º 3
0
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     if (char.IsLetterOrDigit(e.KeyChar))
       theKey = e.KeyChar;
     Invalidate();
     base.OnKeyPress(e);
 }
Exemplo n.º 4
0
 public override void PressKey(KeyPressEventArgs e)
 {
     base.PressKey(e);
     if (e.KeyInfo.Key == ConsoleKey.Spacebar || e.KeyInfo.Key == ConsoleKey.Enter)
     {
         Press(e);
     }
 }
 //nie wiem, gdzie jest enter
 private void HandleKeyPressEvent(object o, KeyPressEventArgs args)
 {
     switch(args.Event.Key){
         case Gdk.Key.Escape:	CancelButton.Click();
                                 break;
         default:	break;
     }
 }
Exemplo n.º 6
0
		public void SendKey(Keys keyDown, char keyPressed, GuiWidget reciever)
		{
			KeyEventArgs keyDownEvent = new KeyEventArgs(keyDown);
			reciever.OnKeyDown(keyDownEvent);
			if (!keyDownEvent.SuppressKeyPress)
			{
				KeyPressEventArgs keyPressEvent = new KeyPressEventArgs(keyPressed);
				reciever.OnKeyPress(keyPressEvent);
			}
		}
Exemplo n.º 7
0
        private void KeyPressed(KeyPressEventArgs obj)
        {
            if (obj.Key == Game.InputKeys.PlayerBlock)
            {
                if (IsCastable)
                {

                }
            }
        }
Exemplo n.º 8
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            //  Enter = 13, Escape = 27,
            if (e.KeyChar == 13 || e.KeyChar == 27)
            {
                OnLostFocus(e);
            }

            e.Handled = (this.Text.IndexOfAny(invalidChar) != -1);
            base.OnKeyPress(e);
        }
Exemplo n.º 9
0
    protected void OnKeyPress(object sender, KeyPressEventArgs a)
    {
        if (a.Event.Key == Gdk.Key.Return) {
            // Send Entry Value to Server
            string val = this.entry2.Text;
            this.entry2.Text = string.Empty;
            this.textview2.Buffer.Text += val + "\n";
            this.ConvertToTelegram (val);
            //Console.WriteLine (val);

        }
    }
Exemplo n.º 10
0
 public virtual void Press(KeyPressEventArgs e)
 {
     EventHandler handler = Pressed;
     if (handler != null)
     {
         handler(this, new KeyPressEventArgs
         {
             KeyInfo = e.KeyInfo
         });
     }
     OnPressed(e);
 }
Exemplo n.º 11
0
        public override void PressKey(KeyPressEventArgs e)
        {
            base.PressKey(e);

            char character = e.KeyInfo.KeyChar;

            int length = Text.Length;
            if (!Char.IsControl(character) && length <= MaxTextSize)
            {
                Text += character;
            }
            else
            {
                if (character == '\b' && length > 0)
                {
                    Text = Text.Remove(length - 1, 1);
                }
            }
            ReRender();
        }
Exemplo n.º 12
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (StringTools.StringLength(game.platform, w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(game.platform, w.text, 0, StringTools.StringLength(game.platform, w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                     {
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (game.platform.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(game.platform, w.text, game.platform.ClipboardGetText());
                         }
                         return;
                     }
                     if (game.platform.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(game.platform, w.text, s);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
    // Restricts the entry of characters to digits (including hex), the negative sign,
    // the decimal point, and editing keystrokes (backspace).
    protected override void OnKeyPress(KeyPressEventArgs e)
    {
        base.OnKeyPress(e);

        NumberFormatInfo numberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
        string decimalSeparator = numberFormatInfo.NumberDecimalSeparator;
        string groupSeparator = numberFormatInfo.NumberGroupSeparator;
        string negativeSign = numberFormatInfo.NegativeSign;

        string keyInput = e.KeyChar.ToString();

        if (Char.IsDigit(e.KeyChar))
        {
            // Digits are OK
        }
        else if (keyInput.Equals(decimalSeparator) || keyInput.Equals(groupSeparator) ||
         keyInput.Equals(negativeSign))
        {
            // Decimal separator is OK
        }
        else if (e.KeyChar == '\b')
        {
            // Backspace key is OK
        }
        //    else if ((ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
        //    {
        //     // Let the edit control handle control and alt key combinations
        //    }
        else if (this.allowSpace && e.KeyChar == ' ')
        {

        }
        else
        {
            // Consume this invalid key and beep
            e.Handled = true;
            //    MessageBeep();
        }
    }
Exemplo n.º 14
0
            protected override void OnKeyPress(KeyPressEventArgs e)
            {
                base.OnKeyPress(e);

                if (!Char.IsDigit(e.KeyChar))
                {
                    if
                    (
                       !(
                          ('A' <= e.KeyChar && 'F' >= e.KeyChar) ||
                          ('a' <= e.KeyChar && 'f' >= e.KeyChar)
                        )
                    )
                    {
                        if (!Char.IsControl(e.KeyChar))
                        {
                            Console.Beep();

                            e.Handled = true;
                        }
                    }
                }
            }
Exemplo n.º 15
0
  /// <summary>
  /// Message Pump
  /// </summary>
  /// <param name="msg"></param>
  protected override void WndProc(ref Message msg)
  {
    try
    {
      switch (msg.Msg)
      {
        // power management
        case WM_POWERBROADCAST:
          OnPowerBroadcast(ref msg);
          break;

        // set maximum and minimum form size in windowed mode
        case WM_GETMINMAXINFO:
          OnGetMinMaxInfo(ref msg);
          break;

        case WM_ENTERSIZEMOVE:
          Log.Debug("Main: WM_ENTERSIZEMOVE");
          break;

        case WM_EXITSIZEMOVE:
          Log.Debug("Main: WM_EXITSIZEMOVE");
          break;

        // only allow window to be moved inside a valid working area
        case WM_MOVING:
          OnMoving(ref msg);
          break;
        
        // verify window size in case it was not resized by the user
        case WM_SIZE:
          OnSize(ref msg);
          break;

        // aspect ratio save window resizing
        case WM_SIZING:
          OnSizing(ref msg);
          break;
        
        // handle display changes
        case WM_DISPLAYCHANGE:
          OnDisplayChange(ref msg);
          break;
        
        // handle device changes
        case WM_DEVICECHANGE:
          OnDeviceChange(ref msg);
          break;

        case WM_QUERYENDSESSION:
          Log.Debug("Main: WM_QUERYENDSESSION");
          PluginManager.WndProc(ref msg);
          base.WndProc(ref msg);
          ShuttingDown = true;
          msg.Result = (IntPtr)1;
          break;

        case WM_ENDSESSION:
          Log.Info("Main: WM_ENDESSION");
          PluginManager.WndProc(ref msg);
          base.WndProc(ref msg);
          Application.ExitThread();
          Application.Exit();
          msg.Result = (IntPtr)0;
          break;
        
        // handle activation and deactivation requests
        case WM_ACTIVATE:
          OnActivate(ref msg);
          break;

        // handle system commands
        case WM_SYSCOMMAND:
          // do not continue with rest of method in case we aborted screen saver or display powering off
          if (!OnSysCommand(ref msg))
          {
            return;
          }
          break;
      }

      // TODO: should not call return here, no process plugins should be allowed to abort windows message processing
      // forward message to process plugins
      if (PluginManager.WndProc(ref msg))
      {
        // msg.Result = new IntPtr(0); <-- do plugins really set it on their own?
        return;
      }

      // TODO: extract to method and change to correct code
      // forward message to input devices
      Action action;
      char key;
      Keys keyCode;
      if (InputDevices.WndProc(ref msg, out action, out key, out keyCode))
      {
        if (msg.Result.ToInt32() != 1)
        {
          msg.Result = new IntPtr(0);
        }

        if (action != null && action.wID != Action.ActionType.ACTION_INVALID)
        {
          Log.Info("Main: Incoming action: {0}", action.wID);
          if (ActionTranslator.GetActionDetail(GUIWindowManager.ActiveWindowEx, action) && (action.SoundFileName.Length > 0 && !g_Player.Playing))
          {
            Utils.PlaySound(action.SoundFileName, false, true);
          }
          GUIGraphicsContext.ResetLastActivity();
          GUIGraphicsContext.OnAction(action);
        }

        if (keyCode != Keys.A)
        {
          Log.Info("Main: Incoming Keycode: {0}", keyCode.ToString());
          var ke = new KeyEventArgs(keyCode);
          OnKeyDown(ke);
          return; // abort WndProc()
        }

        if (key != 0)
        {
          Log.Info("Main: Incoming Key: {0}", key);
          var e = new KeyPressEventArgs(key);
          OnKeyPress(e);
          return; // abort WndProc()
        }

        return; // abort WndProc()
      }

      // forward message to player
      g_Player.WndProc(ref msg);

      // forward message to form class
      base.WndProc(ref msg);
    }

    catch (Exception ex)
    {
      Log.Error(ex);
    }
  }
Exemplo n.º 16
0
 /// <summary>
 /// Event handler for the KeyPress event. Check if the user has depressed the escape key and if so close the form.
 /// </summary>
 /// <param name="sender">Reference to the object that raised the event.</param>
 /// <param name="e">Parameter passed from the object that raised the event.</param>
 private void FormAccount_KeyPress(object sender, KeyPressEventArgs e)
 {
     byte keyChar = (byte)e.KeyChar;
     if (keyChar == CommonConstants.AsciiEscape)
     {
         Close();
     }
 }
Exemplo n.º 17
0
	void KeyPressHandler (object obj, KeyPressEventArgs args)
	{
		Console.WriteLine ("Pressed");
		// nothing
	}
Exemplo n.º 18
0
 private void txtFiltro_KeyPress(object sender, KeyPressEventArgs e)
 {
   
 }
Exemplo n.º 19
0
 /// <summary>
 /// Key has been pressed.
 /// </summary>
 /// <param name="c">Reference to the source control instance.</param>
 /// <param name="e">A KeyPressEventArgs that contains the event data.</param>
 public virtual void KeyPress(Control c, KeyPressEventArgs e)
 {
 }
Exemplo n.º 20
0
 private void CRUD_KeyPress(object sender, KeyPressEventArgs e)
 {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Perform key press handling.
 /// </summary>
 /// <param name="e">A KeyPressEventArgs that contains the event data.</param>
 public override void KeyPress(KeyPressEventArgs e)
 {
     // Tell current view of key event
     FocusView?.KeyPress(e);
 }
Exemplo n.º 22
0
    private void textBox_KeyPress(object sender, KeyPressEventArgs e)
    {
        var textBox = (TextBox)sender;

        if (textBox.Text.Length >= maxCharCount && textBox.SelectionLength == 0 && e.KeyChar != '\b') //backspace
        {
            e.Handled = true;

            if (sender == textBox1 && textBox2.Text.Length < maxCharCount)
            {
                if (textBox2.Text.Length == 0)
                    textBox2.Text += e.KeyChar;

                JumpToTextBox(textBox2);
            }
            else if (sender == textBox2 && textBox3.Text.Length < maxCharCount)
            {
                if (textBox3.Text.Length == 0)
                    textBox3.Text += e.KeyChar;

                JumpToTextBox(textBox3);
            }
        }
        else
        {
            if (e.KeyChar == '\b') //backspace
            {
                if (textBox.Text == "")
                {
                    if (sender == textBox3)
                    {
                        JumpToTextBox(textBox2);
                    }
                    else if (sender == textBox2)
                    {
                        JumpToTextBox(textBox1);
                    }
                }
            }
        }
    }
Exemplo n.º 23
0
 private void txtTutar_KeyPress(object sender, KeyPressEventArgs e)
 {
     Genel gnl = new Genel();
     gnl.SadeceRakamVirgulVeSilme(e);
 }
Exemplo n.º 24
0
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar.ToString())
            {
            case "0":
                button0_Click(button0, new EventArgs());
                break;

            case "1":
                button1_Click(button1, new EventArgs());
                break;

            case "2":
                button2_Click(button2, new EventArgs());
                break;

            case "3":
                button3_Click(button3, new EventArgs());
                break;

            case "4":
                button4_Click(button4, new EventArgs());
                break;

            case "5":
                button5_Click(button5, new EventArgs());
                break;

            case "6":
                button6_Click(button6, new EventArgs());
                break;

            case "7":
                button7_Click(button7, new EventArgs());
                break;

            case "8":
                button8_Click(button8, new EventArgs());
                break;

            case "9":
                button9_Click(button9, new EventArgs());
                break;

            case "":
                buttonErase_MouseDown(buttonErase, new MouseEventArgs(MouseButtons.Left, 1, buttonErase.Location.X, buttonErase.Location.Y, 0));
                break;

            case "*":
                buttonMultiply_Click(buttonMultiply, new EventArgs());
                break;

            case "/":
                buttonDivide_Click(buttonDivide, new EventArgs());
                break;

            case "%":
                buttonProcent_Click(buttonProcent, new EventArgs());
                break;

            case ",":
                buttonDot_Click(buttonDot, new EventArgs());
                break;

            case ".":
                buttonDot_Click(buttonDot, new EventArgs());
                break;

            case "+":
                buttonAdd_Click(buttonAdd, new EventArgs());
                break;

            case "-":
                buttonSubstract_Click(buttonSubstract, new EventArgs());
                break;

            case "e":
                buttonE_Click(buttonE, new EventArgs());
                break;

            case "^":
                buttonXexpY_Click(buttonXexpY, new EventArgs());
                break;

            default:
                Console.WriteLine(e.KeyChar.ToString());
                break;
            }
        }
Exemplo n.º 25
0
 private void txtbFloor_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((e.KeyChar <= 47 || e.KeyChar >= 59) && e.KeyChar != 8)
         e.Handled = true;
 }
Exemplo n.º 26
0
 private void textBoxLog_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 27
0
 // ########################################################################
 // Eventos Validating y KeyPress
 // ########################################################################
 private void TextBoxNumericos_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = !(char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar));
 }
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     base.OnKeyPress(e);
     myUpToDate = false;
     this.Invalidate();
 }
Exemplo n.º 29
0
 private void textBox_preparationY_KeyPress(object sender, KeyPressEventArgs e)
 {
     InputPlusInt(e);
 }
Exemplo n.º 30
0
 private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
 {
 }
Exemplo n.º 31
0
 private void txtTotal_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 32
0
 private void txtBoxId_KeyPress(object sender, KeyPressEventArgs e)
 {
     _handler.CheckInput(e);
 }
Exemplo n.º 33
0
 public static void KeyPressFalse(object sender, KeyPressEventArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 34
0
 private void LabelUsuario1_KeyPress(object sender, KeyPressEventArgs e)
 {
     this.Text = "Letra: " + e.KeyChar;
 }
Exemplo n.º 35
0
 private void listView1_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 9) { //Tab
         this.textBox1.Focus();
     }
     else if (e.KeyChar == 13) {//Enter
         this.gotoFile();
     }
     else if (e.KeyChar == 27) {//Esc
         Close();
     }
 }
Exemplo n.º 36
0
 private void txtLength_KeyPress(object sender, KeyPressEventArgs e)
 {
     WinFormHelper.SetControlOnlyZS(sender, e);
 }
Exemplo n.º 37
0
 private void Obs_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Char.ToUpper(e.KeyChar);
 }
Exemplo n.º 38
0
 private void txtSendData_KeyPress(object sender, KeyPressEventArgs e)
 { 
     e.Handled = KeyHandled; 
 }
Exemplo n.º 39
0
 private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
 {
     MessageBox.Show("You press " + e.KeyChar + " key", "test", MessageBoxButtons.OK);
 }
Exemplo n.º 40
0
        /// <summary>
        /// Recieves the actual unsafe keyboard hook procedure
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        private int KeyboardProc(int code, IntPtr wParam, IntPtr lParam)
        {
            WinApi.KeyboardLLHookStruct hookStruct = (WinApi.KeyboardLLHookStruct)Marshal.PtrToStructure(lParam, typeof(WinApi.KeyboardLLHookStruct));

            int msg = wParam.ToInt32();
            bool handled = false;

            if (msg == WinApi.WM_KEYDOWN || msg == WinApi.WM_SYSKEYDOWN)
            {
                KeyEventArgs e = new KeyEventArgs((Keys)hookStruct.vkCode);
                OnKeyDown(e);
                handled = e.Handled;
            }
            else if (msg == WinApi.WM_KEYUP || msg == WinApi.WM_SYSKEYUP)
            {
                KeyEventArgs e = new KeyEventArgs((Keys)hookStruct.vkCode);
                OnKeyUp(e);
                handled = e.Handled;
            }

            if (msg == WinApi.WM_KEYDOWN && KeyPress != null)
            {
                byte[] keyState = new byte[256];
                byte[] buffer = new byte[2];
                WinApi.GetKeyboardState(keyState);
                int conversion = WinApi.ToAscii(hookStruct.vkCode, hookStruct.scanCode, keyState, buffer, hookStruct.flags);

                if (conversion == 1 || conversion == 2)
                {
                    bool shift = (WinApi.GetKeyState(WinApi.VK_SHIFT) & 0x80) == 0x80;
                    bool capital = WinApi.GetKeyState(WinApi.VK_CAPITAL) != 0;
                    char c = (char)buffer[0];
                    if ((shift ^ capital) && Char.IsLetter(c))
                    {
                        c = Char.ToUpper(c);
                    }
                    KeyPressEventArgs e = new KeyPressEventArgs(c);
                    OnKeyPress(e);
                    handled |= e.Handled;
                }
            }

            return handled ? 1 : WinApi.CallNextHookEx(Handle, code, wParam, lParam);
        }
Exemplo n.º 41
0
 void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
 {
     //if (e.KeyChar ==(char) Keys.Select)
      //{
      //    e.Handled = true;
      //    DataGridViewCell cell = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[dataGridView1.CurrentCell.ColumnIndex];
      //    dataGridView1.CurrentCell = cell;
      //    dataGridView1.CurrentCell.ReadOnly = false;
      //    dataGridView1.BeginEdit(true);
      //}
 }
 private void txtNumeroChasis_KeyPress(object sender, KeyPressEventArgs e)
 {
 }
Exemplo n.º 43
0
	void TextBox_KeyPress (object sender, KeyPressEventArgs e)
	{
		if (e.KeyChar == '3' || e.KeyChar == '\r')
			e.Handled = true;
	}
Exemplo n.º 44
0
 private void Relatorios_comboBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 45
0
 void tbGradosF_KeyPress(object sender, KeyPressEventArgs e)
 {
     objTextBox = (TextBox)sender;
 }
Exemplo n.º 46
0
 private void code_end_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar);
 }
Exemplo n.º 47
0
 private void discount_amount_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar);
 }
 private void AsignarGafeteOperador(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (int)Keys.Enter)
     {
         try
         {
             if (EsEdicion)
             {
                 if (txtGafeteAsignado.Text != "")
                 {
                     if (CodigoGafeteCorrecto(txtGafeteAsignado.Text.Trim().ToUpper()))
                     {
                         if (YaExisteGafeteOperador())
                         {
                             MessageBox.Show("Este Gafete Ya Está Asignado A Otra Persona, Por Favor Verifique", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                             txtGafeteAsignado.Text = "";
                             txtGafeteAsignado.Focus();
                         }
                         else
                         {
                             string query = "UPDATE AsignacionGafete SET Gafete2 = '" + txtGafeteAsignado.Text.Trim().ToUpper() + "' WHERE AsignacionGafeteID = " + txtAsignacionGafeteID.Text + " AND TieneSalida = 0 AND Activo = 1";
                             if (conexion.State == ConnectionState.Closed)
                             {
                                 conexion.Open();
                             }
                             SqlCommand cmd    = new SqlCommand(query, conexion);
                             int        result = cmd.ExecuteNonQuery();
                             if (result > 0)
                             {
                                 MessageBox.Show("Gafete Actualizado Correctamente", "Correcto", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                 this.Close();
                             }
                             else
                             {
                                 MessageBox.Show("Error Actualizando Gafete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             }
                             conexion.Close();
                         }
                     }
                     else
                     {
                         MessageBox.Show("Codigo De Gafete Incorrecto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         txtGafeteAsignado.Text = "";
                         txtGafeteAsignado.Focus();
                     }
                 }
                 else
                 {
                     MessageBox.Show("El Campo de Nuevo Gafete De Operador No Debe Estar Vacío", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     txtGafeteAsignado.Text = "";
                     txtGafeteAsignado.Focus();
                 }
             }
             else
             {
                 if (txtGafete1.Text != "")
                 {
                     if (txtGafeteAsignado.Text != "")
                     {
                         if (CodigoGafeteCorrecto(txtGafeteAsignado.Text.Trim().ToUpper()))
                         {
                             if (!ExisteGafeteAsignado(txtGafeteAsignado.Text.Trim().ToUpper()))                                   //Verifico que el gafete a asignar no este ligado a otro gafete de vigilancia
                             {
                                 if (!ExisteAsignacion(txtGafete1.Text.Trim().ToUpper(), txtGafeteAsignado.Text.Trim().ToUpper())) //Verifico que no exista la asginacion del gafete 1 con el asignado
                                 {
                                     string query = "INSERT INTO AsignacionGafete VALUES ( " +
                                                    " '" + txtGafete1.Text.Trim().ToUpper() + "', " +
                                                    " '" + txtGafeteAsignado.Text.Trim().ToUpper() + "', " +
                                                    " '" + txtRegistroPersonaID.Text.Trim() + "', " +
                                                    " '" + txtRegistroAccesoID.Text.Trim() + "', " +
                                                    " GETDATE(), " +
                                                    " GETDATE(), " +
                                                    " null, 0, 1 ); ";
                                     SqlCommand cmd = new SqlCommand(query, conexion);
                                     if (conexion.State == ConnectionState.Closed)
                                     {
                                         conexion.Open();
                                     }
                                     int rowAffected = cmd.ExecuteNonQuery();
                                     if (rowAffected > 0)
                                     {
                                         MessageBox.Show("Asignacíon Correcta", "Correcto", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                         this.Close();
                                     }
                                     else
                                     {
                                         MessageBox.Show("Error al guardar datos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                     }
                                 }
                                 else
                                 {
                                     MessageBox.Show("Ya Existe una Asignacion Con estos Gafetes, se limpiara la pantalla", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                     LimpiarCampos();
                                 }
                             }
                             else
                             {
                                 MessageBox.Show("Este Gafete ya esta asignado a otra persona", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                 txtGafeteAsignado.Enabled = true;
                                 this.txtGafeteAsignado.Focus();
                                 this.txtGafeteAsignado.Text = "";
                             }
                         }
                         else
                         {
                             MessageBox.Show("Codigo De Gafete Incorrecto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                             txtGafeteAsignado.Text = "";
                             txtGafeteAsignado.Focus();
                         }
                     }
                     else
                     {
                         MessageBox.Show("Ingrese Gafete Operador", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         txtGafeteAsignado.Focus();
                     }
                 }
                 else
                 {
                     MessageBox.Show("Ingrese Gafete Administrador", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     LimpiarCampos();
                     txtGafeteAsignado.Enabled = false;
                     txtGafete1.Focus();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 49
0
 protected virtual void OnPressed(KeyPressEventArgs e)
 {
 }
 private void MuestraInformacion(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (int)Keys.Enter)
     {
         try
         {
             if (txtGafete1.Text != "")
             {
                 if (!GafeteOriginalTieneAsignacion(txtGafete1.Text.Trim().ToUpper()))
                 {
                     string query = " SELECT " +
                                    " P.RegistroPersonasID, " +
                                    " ISNULL(RS.RegistroAccesoID, 0) RegistroAccesoID, " +
                                    " P.Nombre, " +
                                    " ISNULL(RS.Asunto, 'NA') Asunto, " +
                                    " ISNULL(D.Nombre, 'NA') Departamento, " +
                                    " ISNULL(RS.Comentarios, 'NA') Descripcion, " +
                                    " P.FechaEntrada " +
                                    " FROM " +
                                    " RegistroAccesoPersonas P " +
                                    " INNER JOIN RegistroAccesoSteelgo RS ON RS.RegistroAccesoID = P.RegistroAccesoID AND RS.TieneSalida = 0 AND RS.Activo = 1 " +
                                    " INNER JOIN [IBIX].[IBIXLocal].dbo.tblDepto D ON D.Depto = RS.DepartamentoID AND D.Emp = 1 AND D.Nombre <> '' " +
                                    " WHERE " +
                                    " P.Gafete = '" + txtGafete1.Text.Trim().ToUpper() + "' AND P.Salida = 0 AND P.Activo = 1 ";
                     SqlCommand cmd = new SqlCommand(query, conexion);
                     if (conexion.State == ConnectionState.Closed)
                     {
                         conexion.Open();
                     }
                     SqlDataReader reader = cmd.ExecuteReader();
                     if (reader.Read())
                     {
                         txtNombre.Text            = reader["Nombre"].ToString();
                         txtAsunto.Text            = reader["Asunto"].ToString();
                         txtDepartamento.Text      = reader["Departamento"].ToString();
                         txtDescripcion.Text       = reader["Descripcion"].ToString();
                         txtRegistroPersonaID.Text = reader["RegistroPersonasID"].ToString();
                         txtRegistroAccesoID.Text  = reader["RegistroAccesoID"].ToString();
                         txtFechaEntrada.Value     = Convert.ToDateTime(reader["FechaEntrada"].ToString());
                         txtHoraEntrada.Value      = Convert.ToDateTime(reader["FechaEntrada"].ToString());
                         txtGafeteAsignado.Enabled = true;
                         txtGafeteAsignado.Focus();
                     }
                     else
                     {
                         MessageBox.Show("No se Encontro Información con este número de gafete", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         txtGafete1.Text = "";
                         txtGafete1.Focus();
                     }
                     reader.Close();
                     conexion.Close();
                 }
                 else
                 {
                     MessageBox.Show("Este Gafete ya tiene Asignación activa", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     txtGafete1.Text = "";
                     txtGafete1.Focus();
                 }
             }
             else
             {
                 MessageBox.Show("Por favor ingrese numero de gafete", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 LimpiarCampos();
                 txtGafeteAsignado.Enabled = false;
                 txtGafete1.Focus();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error Mostrando Datos: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             LimpiarCampos();
             txtGafeteAsignado.Enabled = false;
         }
     }
 }
Exemplo n.º 51
0
 /// <summary>
 /// Raises the <see cref="KeyPress"/> event
 /// </summary>
 /// <param name="e">Event Data</param>
 protected virtual void OnKeyPress(KeyPressEventArgs e)
 {
     if (KeyPress != null)
     {
         KeyPress(this, e);
     }
 }
Exemplo n.º 52
0
 private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = (!Char.IsDigit(e.KeyChar) & !Char.IsControl(e.KeyChar));
 }
Exemplo n.º 53
0
 protected virtual void OnKeyPress(KeyPressEventArgs args)
 {
     if (this.KeyPress != null)
     {
         this.KeyPress(this, args);
     }
 }
Exemplo n.º 54
0
Arquivo: Form1.cs Projeto: zajuruk/VP
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
 {
 }
Exemplo n.º 55
0
        /// <summary>
        /// Event handler for the TextBox KeyPress event. Checks if the user entered a [CR] and, if so, starts processing the input.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_TxtPassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals('\r'))
            {
                // Check if the number of attempts at logging on has expired.
                m_Attempts++;
                if (m_Attempts >= MaxAttempts)
                {
                    MessageBox.Show(Resources.MBTSecurityLoginFailed, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Close();
                    return;
                }

                // Get the hash code corresponding to the entered password.
				m_Hashcode = Security.GetHashCode(m_TextBoxPassword.Text);

                // Check whether the password is valid.
                if (m_Hashcode == Security.HashCodeLevel1)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level1;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else if (m_Hashcode == Security.HashCodeLevel2)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level2;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else if (m_Hashcode == Security.HashCodeLevel3)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level3;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else
                {
                    m_TextBoxPassword.Text = "";
                    MessageBox.Show(Resources.MBTSecurityPasswordIncorrect, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 56
0
 private void Txt_detalle_KeyPress(object sender, KeyPressEventArgs e)
 {
     validar.validarLetras(e);
 }
Exemplo n.º 57
0
  /// <summary>
  /// Message Pump
  /// </summary>
  /// <param name="msg"></param>
  protected override void WndProc(ref Message msg)
  {
    try
    {
      switch (msg.Msg)
      {
        case (int)ShellNotifications.WmShnotify:
          NotifyInfos info = new NotifyInfos((ShellNotifications.SHCNE)(int)msg.LParam);
          
          if (Notifications.NotificationReceipt(msg.WParam, msg.LParam, ref info))
          {
            if (info.Notification == ShellNotifications.SHCNE.SHCNE_MEDIAINSERTED)
            {
              string path = info.Item1;

              if (Utils.IsRemovable(path))
              {
                string driveName = Utils.GetDriveName(info.Item1);
                GUIMessage gmsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ADD_REMOVABLE_DRIVE, 0, 0, 0, 0, 0, 0);
                gmsg.Label = info.Item1;
                gmsg.Label2 = String.Format("({0}) {1}", path, driveName);
                GUIGraphicsContext.SendMessage(gmsg);
              }
            }

            if (info.Notification == ShellNotifications.SHCNE.SHCNE_MEDIAREMOVED)
            {
              string path = info.Item1;

              if (Utils.IsRemovable(path))
              {
                string driveName = Utils.GetDriveName(info.Item1);
                GUIMessage gmsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REMOVE_REMOVABLE_DRIVE, 0, 0, 0, 0, 0, 0);
                gmsg.Label = info.Item1;
                gmsg.Label2 = String.Format("({0}) {1}", path, driveName);
                GUIGraphicsContext.SendMessage(gmsg);
              }
            }
          }
          return;

        // power management
        case WM_POWERBROADCAST:
          OnPowerBroadcast(ref msg);
          break;

        // set maximum and minimum form size in windowed mode
        case WM_GETMINMAXINFO:
          OnGetMinMaxInfo(ref msg);
          PluginManager.WndProc(ref msg);
          break;

        case WM_ENTERSIZEMOVE:
          Log.Debug("Main: WM_ENTERSIZEMOVE");
          PluginManager.WndProc(ref msg);
          break;

        case WM_EXITSIZEMOVE:
          Log.Debug("Main: WM_EXITSIZEMOVE");
          PluginManager.WndProc(ref msg);
          break;

        // only allow window to be moved inside a valid working area
        case WM_MOVING:
          OnMoving(ref msg);
          PluginManager.WndProc(ref msg);
          break;
        
        // verify window size in case it was not resized by the user
        case WM_SIZE:
          OnSize(ref msg);
          PluginManager.WndProc(ref msg);
          break;

        // aspect ratio save window resizing
        case WM_SIZING:
          OnSizing(ref msg);
          PluginManager.WndProc(ref msg);
          break;
        
        // handle display changes
        case WM_DISPLAYCHANGE:
          OnDisplayChange(ref msg);
          PluginManager.WndProc(ref msg);
          break;
        
        // handle device changes
        case WM_DEVICECHANGE:
          OnDeviceChange(ref msg);
          PluginManager.WndProc(ref msg);
          break;

        case WM_QUERYENDSESSION:
          Log.Debug("Main: WM_QUERYENDSESSION");
          PluginManager.WndProc(ref msg);
          base.WndProc(ref msg);
          ShuttingDown = true;
          msg.Result = (IntPtr)1;
          break;

        case WM_ENDSESSION:
          Log.Info("Main: WM_ENDESSION");
          PluginManager.WndProc(ref msg);
          base.WndProc(ref msg);
          Application.ExitThread();
          Application.Exit();
          msg.Result = (IntPtr)0;
          break;
        
        // handle activation and deactivation requests
        case WM_ACTIVATE:
          OnActivate(ref msg);
          PluginManager.WndProc(ref msg);
          break;

        // handle system commands
        case WM_SYSCOMMAND:
          // do not continue with rest of method in case we aborted screen saver or display powering off
          if (!OnSysCommand(ref msg))
          {
            return;
          }
          PluginManager.WndProc(ref msg);
          break;

        // handle default commands needed for plugins
        default:
          PluginManager.WndProc(ref msg);
          break;
      }

      // TODO: extract to method and change to correct code
      // forward message to input devices
      Action action;
      char key;
      Keys keyCode;
      if (InputDevices.WndProc(ref msg, out action, out key, out keyCode))
      {
        if (msg.Result.ToInt32() != 1)
        {
          msg.Result = new IntPtr(0);
        }

        if (action != null && action.wID != Action.ActionType.ACTION_INVALID)
        {
          Log.Info("Main: Incoming action: {0}", action.wID);
          if (ActionTranslator.GetActionDetail(GUIWindowManager.ActiveWindowEx, action) && (action.SoundFileName.Length > 0 && !g_Player.Playing))
          {
            Utils.PlaySound(action.SoundFileName, false, true);
          }
          GUIGraphicsContext.ResetLastActivity();
          GUIGraphicsContext.OnAction(action);
        }

        if (keyCode != Keys.A)
        {
          Log.Info("Main: Incoming Keycode: {0}", keyCode.ToString());
          var ke = new KeyEventArgs(keyCode);
          OnKeyDown(ke);
          return; // abort WndProc()
        }

        if (key != 0)
        {
          Log.Info("Main: Incoming Key: {0}", key);
          var e = new KeyPressEventArgs(key);
          OnKeyPress(e);
          return; // abort WndProc()
        }

        return; // abort WndProc()
      }

      // forward message to player
      g_Player.WndProc(ref msg);

      // forward message to form class
      base.WndProc(ref msg);
    }

    catch (Exception ex)
    {
      Log.Error(ex);
    }
  }
Exemplo n.º 58
0
 /// <summary>
 /// enter键功能
 /// </summary>
 private void txtPageNum_KeyPress(object sender, KeyPressEventArgs e)
 {
     btnGo_Click(null, null);
 }
Exemplo n.º 59
0
  /// <summary>
  /// 
  /// </summary>
  /// <param name="e"></param>
  protected override void KeyPressEvent(KeyPressEventArgs e)
  {
    GUIGraphicsContext.BlankScreen = false;
    var key = new Key(e.KeyChar, 0);
    var action = new Action();
    if (GUIWindowManager.IsRouted || GUIWindowManager.ActiveWindowEx == (int)GUIWindow.Window.WINDOW_TV_SEARCH)
    // is a dialog open or maybe the tv schedule search (GUISMSInputControl)?
    {
      GUIGraphicsContext.ResetLastActivity();
      if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindowEx, key, ref action) &&
          (GUIWindowManager.ActiveWindowEx != (int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD) &&
          (GUIWindowManager.ActiveWindowEx != (int)GUIWindow.Window.WINDOW_TV_SEARCH))
      {
        if (action.SoundFileName.Length > 0 && !g_Player.Playing)
        {
          Utils.PlaySound(action.SoundFileName, false, true);
        }
        GUIGraphicsContext.OnAction(action);
      }
      else
      {
        action = new Action(key, Action.ActionType.ACTION_KEY_PRESSED, 0, 0);
        GUIGraphicsContext.OnAction(action);
      }
      return;
    }

    if (key.KeyChar == '!')
    {
      _showStats = !_showStats;
    }

    if (key.KeyChar == '|' && g_Player.Playing == false)
    {
      g_Player.Play("rtsp://localhost/stream0");
      g_Player.ShowFullScreenWindow();
      return;
    }

    if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindowEx, key, ref action))
    {
      if (action.ShouldDisableScreenSaver)
      {
        GUIGraphicsContext.ResetLastActivity();
      }
      if (action.SoundFileName.Length > 0 && !g_Player.Playing)
      {
        Utils.PlaySound(action.SoundFileName, false, true);
      }
      GUIGraphicsContext.OnAction(action);
    }
    else
    {
      GUIGraphicsContext.ResetLastActivity();
    }

    action = new Action(key, Action.ActionType.ACTION_KEY_PRESSED, 0, 0);
    GUIGraphicsContext.OnAction(action);
  }
Exemplo n.º 60
0
 private void textBox_pitchYNum_KeyPress(object sender, KeyPressEventArgs e)
 {
     InputPlusInt(e);
 }