MessageBeep() private method

private MessageBeep ( int type ) : bool
type int
return bool
示例#1
0
        /// <summary>
        /// Process the incoming key as being pressed.
        /// </summary>
        /// <param name="key">Key data.</param>
        public void AppendKeyPress(char key)
        {
            // We only use uppercase characters
            key = char.ToUpper(key);

            // Find the new prefix with the additional key
            string newPrefix = _prefix + key;

            // Search for any keytip that is an exact match
            foreach (ViewDrawRibbonKeyTip viewKeyTip in _viewList)
            {
                if (viewKeyTip.KeyTipInfo.KeyString.Equals(newPrefix))
                {
                    // Invoke the target
                    viewKeyTip.KeyTipInfo.KeyTipSelect(_ribbon);
                    return;
                }
            }

            // Search to see if any keytip has this as a prefix
            bool found = false;

            foreach (ViewDrawRibbonKeyTip viewKeyTip in _viewList)
            {
                if (viewKeyTip.KeyTipInfo.KeyString.StartsWith(newPrefix))
                {
                    found = true;
                    break;
                }
            }

            if (found)
            {
                // Append the character to the prefix string
                _prefix += key;

                // Hide ourself and then show again to force redraw
                PI.ShowWindow(Handle, (short)PI.SW_HIDE);

                // Use timer to force redraw
                StartTimer();
            }
            else
            {
                // Escape key is not considered an error character
                if (key != 27)
                {
                    // Issue a windows error sound
                    PI.MessageBeep(PI.MESSAGE_BEEP_ERROR);
                }
            }
        }