コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #3
0
 private void reverse_key_forecolor(CKbdKey key)
 {
     if (key != null)
     {
         if (key.ForeColor == key.BackColor)
         {
             key.ForeColor = btnKey0.ForeColor;
         }
         else
         {
             key.ForeColor = key.BackColor;
         }
         key.Refresh();
     }
 }
コード例 #4
0
        private void btnKey124_Click(object sender, EventArgs e)
        {
            CKbdKey btnDown = null;

            btnDown = btnKey124;
            if (shift_is_down() != null)
            {//toggle it, now it should been up
                btnDown.BackColor = KeyUpColor;
                btnDown.ForeColor = btnKey0.ForeColor;
                show_keys(false);
            }
            else
            {
                btnDown.BackColor = KeyDownColor;
                show_keys(true);
            }
        }
コード例 #5
0
 //private Color KeyUpColor
 //{
 //    get
 //    {
 //        return btnKey0.BackColor;
 //    }
 //}
 private void reset_all_function_buttons()
 {
     CKbdKey[] ar = new CKbdKey[] {
         btnKey54,
         btnKey66,
         btnKey67,
         btnKey68,
         btnKey65,
         btnKey70,
         btnKey71,
         btnKey73,
     };
     for (int i = 0; i < ar.Length; i++)
     {
         ar[i].BackColor = btnKey0.BackColor;
     }
 }
コード例 #6
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);
            }
        }
コード例 #7
0
        private void show_keys(bool bShift)
        {
            int ncount = m_Keys.Length;

            for (int i = 0; i < ncount; i++)
            {
                string  name = string.Format("btnKey{0}", i);
                CKbdKey btn  = GetButton(name);
                if (btn != null)
                {
                    if (!bShift)
                    {
                        btn.Text = m_Keys[i].m_strText;
                        //btn.Tag = m_Keys[i].m_strCode;
                    }
                    else
                    {
                        btn.Text = m_Keys[i].m_strShiftText;
                        //btn.Tag = m_Keys[i].m_strShiftCode;
                    }
                    btn.Tag = m_Keys[i];
                    //disable Ctrl , Shift, Alt and Win when edit combination
                    if (this._ForCombination)
                    {
                        if (btn.Text.Equals("Ctrl") ||
                            btn.Text.Equals("Alt") ||
                            btn.Text.Equals("Shift") ||
                            btn.Text.Equals("Win"))
                        {
                            btn.Enabled = false;
                        }
                    }
                    btn.Refresh();
                }
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
 private bool key_is_down(CKbdKey button)
 {
     return(button.BackColor == KeyDownColor);
 }