コード例 #1
0
        internal static string ShortcutName(KeyData kdata) //access thru Guppy.ShortcutName
        {
            List <string> parts  = new List <string>();
            int           keyval = (int)kdata.KeyCode;

            if (kdata.Ctrl)
            {
                parts.Add("Ctrl");
            }
            if (kdata.Shift)
            {
                parts.Add("Shift");
            }
            if (kdata.Alt)
            {
                parts.Add("Alt");
            }

            //if this is a typable key, add it directly:
            int unmod = keyval & 0xfffff; //remove shift,control etc.

            if (unmod >= 33 && unmod < (int)KeyCode.XBase)
            {
                parts.Add(((char)unmod).ToString().ToUpper());
            }
            else
            {
                string s;
                switch ((KeyCode)unmod)
                {
                case KeyCode.Space: s = "Space"; break;

                case KeyCode.Backspace: s = "BackSpace"; break;

                case KeyCode.Tab: s = "Tab"; break;

                case KeyCode.LineFeed: s = "LineFeed"; break;

                case KeyCode.Return: s = "Return"; break;

                case KeyCode.Escape: s = "Escape"; break;

                case KeyCode.Home: s = "Home"; break;

                case KeyCode.Up: s = "Up"; break;

                case KeyCode.PageUp: s = "PageUp"; break;

                case KeyCode.PageDown: s = "PageDown"; break;

                case KeyCode.Left: s = "Left"; break;

                case KeyCode.Right: s = "Right"; break;

                case KeyCode.End: s = "End"; break;

                case KeyCode.Down: s = "Down"; break;

                case KeyCode.Insert: s = "Insert"; break;

                case KeyCode.Delete: s = "Delete"; break;

                case KeyCode.Pause: s = "Pause"; break;

                case KeyCode.CapsLock: s = "CapsLock"; break;

                case KeyCode.F1: s = "F1"; break;

                case KeyCode.F2: s = "F2"; break;

                case KeyCode.F3: s = "F3"; break;

                case KeyCode.F4: s = "F4"; break;

                case KeyCode.F5: s = "F5"; break;

                case KeyCode.F6: s = "F6"; break;

                case KeyCode.F7: s = "F7"; break;

                case KeyCode.F8: s = "F8"; break;

                case KeyCode.F9: s = "F9"; break;

                case KeyCode.F10: s = "F10"; break;

                case KeyCode.F11: s = "F11"; break;

                case KeyCode.F12: s = "F12"; break;

                case KeyCode.Print: s = "Print"; break;

                case KeyCode.Menu: s = "Menu"; break;

                case KeyCode.NumLock: s = "NumLock"; break;

                case KeyCode.ScrollLock: s = "ScrollLock"; break;

                default: s = "???"; break;     //whats this?
                }

                parts.Add(s);
            }

            return(string.Join("+", parts.ToArray()));
        }
コード例 #2
0
 public KeyEventArgs(KeyData data)
 {
     this.KeyData = data;
 }