Ejemplo n.º 1
0
        /************************************************************************/

        /*
         * return the key code .
         */
        /************************************************************************/
        private bool IsShiftKeyUpClick(CKbdKey btn, COnScreenKbdKey key)
        {
            CKbdKey btnDown     = null;
            bool    bWithUpCode = false;

            if (key.m_strCode == "[Shift]" ||
                key.m_strCode == "[RightShift]")
            {//shift key
                btnDown     = shift_is_down();
                bWithUpCode = true;
                show_keys(btnDown == null); //toggle
                //return (btnDown != null); //toggle
            }


            if (!bWithUpCode)
            {
                return(false);
            }


            if (btnDown != null) //it is down
            {                    //toggle it, now it should been up
                btnDown.BackColor = KeyUpColor;
                btnDown.ForeColor = btnKey0.ForeColor;
                btn.BackColor     = KeyUpColor;
                btn.ForeColor     = btnKey0.ForeColor;
                return(true);
            }
            else
            {
                btn.BackColor = KeyDownColor;
                return(false);
            }
        }
Ejemplo n.º 2
0
        /************************************************************************/

        /*
         * return the key code .
         */
        /************************************************************************/
        private string DoOnScreenKeyDownUp(CKbdKey btn, COnScreenKbdKey key)
        {
            CKbdKey btnDown     = null;
            bool    bWithUpCode = false;

            if (key.m_strCode == "[Shift]" ||
                key.m_strCode == "[RightShift]")
            {                               //shift key
                btnDown = shift_is_down();
                show_keys(btnDown == null); //toggle
                bWithUpCode = true;
            }
            else if (key.m_strCode == "[Alt]" ||
                     key.m_strCode == "[RightAlt]")
            { //alt key
                btnDown     = alt_is_down();
                bWithUpCode = true;
            }
            else if (key.m_strCode == "[Ctrl]" ||
                     key.m_strCode == "[RightCtrl]")
            { //alt key
                btnDown     = ctrl_is_down();
                bWithUpCode = true;
            }
            else if (key.m_strCode == "[Win]" ||
                     key.m_strCode == "[RightWin]")
            { //alt key
                btnDown     = win_is_down();
                bWithUpCode = true;
            }

            if (!bWithUpCode)
            {
                return("");
            }

            if (btnDown != null) //it is down
            {                    //toggle it, now it should been up
                btnDown.BackColor = KeyUpColor;
                btnDown.ForeColor = btnKey0.ForeColor;
                btn.BackColor     = KeyUpColor;
                btn.ForeColor     = btnKey0.ForeColor;
                return(((COnScreenKbdKey)btnDown.Tag).m_strUpCode);
            }
            else
            {
                btn.BackColor = KeyDownColor;
                return(key.m_strShiftCode);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// it is old version keyclick event, just for backup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnKeyClickedOld(object sender, EventArgs e)
        {
            CKbdKey btn = (CKbdKey)sender;


            COnScreenKbdKey key = (COnScreenKbdKey)btn.Tag;


            if (shift_is_down() != null)
            {
                m_strPressedKeyCode = key.m_strShiftCode;
            }
            else
            {
                m_strPressedKeyCode = key.m_strCode;
            }
            //some keys with keyup code
            string strKeyWithUp = DoOnScreenKeyDownUp(btn, key);


            if (_ForCombination)
            {//in combination, don't allow keyup code.
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                //for normal input, allow keyup code.
                if (strKeyWithUp.Length > 0)
                {
                    m_strPressedKeyCode = strKeyWithUp;
                }

                if (this.FocusedTextBox == null)
                {
                    return;
                }
                string s = GetSelectedKeyCode();
                if (s.Length <= 0)
                {
                    return;
                }
                this.FocusedTextBox.AddKeyCode(s);
            }
        }
Ejemplo n.º 4
0
        private void OnKeyClicked(object sender, EventArgs e)
        {
            CKbdKey btn = (CKbdKey)sender;

            COnScreenKbdKey key = (COnScreenKbdKey)btn.Tag;

            if (handle_function_keys(btn, key))
            {
                return;
            }
            //if (IsShiftKeyUpClick(btn, key))
            //{
            //    //show_keys(false);
            //    return;
            //}

            if (shift_is_down() != null)
            {
                m_strPressedKeyCode = key.m_strShiftCode;
            }
            else
            {
                m_strPressedKeyCode = key.m_strCode;
            }
            //some keys with keyup code
            //string strKeyWithUp = DoOnScreenKeyDownUp(btn, key);


            if (_ForCombination)
            {//in combination, don't allow keyup code.
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                //for normal input, allow keyup code.
                //if (strKeyWithUp.Length > 0)
                //    m_strPressedKeyCode = strKeyWithUp;

                if (this.FocusedTextBox == null)
                {
                    return;
                }
                string s = GetSelectedKeyCode();
                if (s.Length <= 0)
                {
                    return;
                }
                //this.FocusedTextBox.fix_function_keys_up(null);

                this.FocusedTextBox.AddKeyCode(s);

                /*
                 * if (key.m_strUpCode.Length >0)
                 * //if (strKeyWithUp.Length >0)
                 *  this.FocusedTextBox.AddKeyCode(key.m_strUpCode);
                 * */
                append_function_key_up();
                reset_all_function_buttons();
            }
        }
Ejemplo n.º 5
0
        private bool handle_function_keys(CKbdKey button, COnScreenKbdKey key)
        {
            if (key.m_strCode == KB9Const.CTRL_DOWN ||
                key.m_strCode == KB9Const.RCTRL_DOWN ||
                key.m_strCode == KB9Const.SHIFT_DOWN ||
                key.m_strCode == KB9Const.RSHIFT_DOWN ||
                key.m_strCode == KB9Const.ALT_DOWN ||
                key.m_strCode == KB9Const.RALT_DOWN ||
                key.m_strCode == KB9Const.WIN_DOWN ||
                key.m_strCode == KB9Const.RWIN_DOWN)
            {
                if (shift_is_down() != null)
                {
                    m_strPressedKeyCode = key.m_strShiftCode;
                }
                else
                {
                    m_strPressedKeyCode = key.m_strCode;
                }

                if (_ForCombination)
                {                 //in combination, don't allow keyup code.
                    return(true); //the function keys is not allowed in combination
                    //  this.DialogResult = DialogResult.OK;
                    // this.Close();
                }
                else
                {
                    if (this.FocusedTextBox == null)
                    {
                        return(false);
                    }
                    string s = GetSelectedKeyCode();
                    if (s.Length <= 0)
                    {
                        return(false);
                    }

                    if (!key_is_down(button))
                    {
                        this.FocusedTextBox.AddKeyCode(key.m_strCode);
                    }
                    else
                    {
                        this.FocusedTextBox.AddKeyCode(key.m_strUpCode);
                    }

                    /*
                     * if (key.m_strUpCode.Length >0)
                     * //if (strKeyWithUp.Length >0)
                     *  this.FocusedTextBox.AddKeyCode(key.m_strUpCode);
                     * */
                }
                if (button.BackColor == KeyDownColor)
                {
                    button.BackColor = btnKey0.BackColor;
                }
                else
                {
                    button.BackColor = KeyDownColor;
                }

                return(true);
            }
            else //normal key pressed
            {
                return(false);
            }
        }