using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace FastReport.Utils { public partial class Converter { internal static Dictionary ValidShortcutKeys = new Dictionary() { { Keys.ShiftKey, "Shift" }, { Keys.ControlKey, "Ctrl" }, { Keys.Menu, "Alt" }, { Keys.LShiftKey, "LShift" }, { Keys.RShiftKey, "RShift" }, { Keys.LControlKey, "LCtrl" }, { Keys.RControlKey, "RCtrl" }, { Keys.LMenu, "LAlt" }, { Keys.RMenu, "RAlt" }, { Keys.A, "A" }, { Keys.B, "B" }, { Keys.C, "C" }, { Keys.D, "D" }, { Keys.D0, "0" }, { Keys.D1, "1" }, { Keys.D2, "2" }, { Keys.D3, "3" }, { Keys.D4, "4" }, { Keys.D5, "5" }, { Keys.D6, "6" }, { Keys.D7, "7" }, { Keys.D8, "8" }, { Keys.D9, "9" }, { Keys.Delete, "Delete" }, { Keys.Down, "Down" }, { Keys.E, "E" }, { Keys.End, "End" }, { Keys.F, "F" }, { Keys.F1, "F1" }, { Keys.F10, "F10" }, { Keys.F11, "F11" }, { Keys.F12, "F12" }, { Keys.F13, "F13" }, { Keys.F14, "F14" }, { Keys.F15, "F15" }, { Keys.F16, "F16" }, { Keys.F17, "F17" }, { Keys.F18, "F18" }, { Keys.F19, "F19" }, { Keys.F2, "F2" }, { Keys.F20, "F20" }, { Keys.F21, "F21" }, { Keys.F22, "F22" }, { Keys.F23, "F23" }, { Keys.F24, "F24" }, { Keys.F3, "F3" }, { Keys.F4, "F4" }, { Keys.F5, "F5" }, { Keys.F6, "F6" }, { Keys.F7, "F7" }, { Keys.F8, "F8" }, { Keys.F9, "F9" }, { Keys.G, "G" }, { Keys.H, "H" }, { Keys.I, "I" }, { Keys.Insert, "Insert" }, { Keys.J, "J" }, { Keys.K, "K" }, { Keys.L, "L" }, { Keys.Left, "Left" }, { Keys.M, "M" }, { Keys.N, "N" }, { Keys.NumLock, "NumLock" }, { Keys.NumPad0, "NumPad0" }, { Keys.NumPad1, "NumPad1" }, { Keys.NumPad2, "NumPad2" }, { Keys.NumPad3, "NumPad3" }, { Keys.NumPad4, "NumPad4" }, { Keys.NumPad5, "NumPad5" }, { Keys.NumPad6, "NumPad6" }, { Keys.NumPad7, "NumPad7" }, { Keys.NumPad8, "NumPad8" }, { Keys.NumPad9, "NumPad9" }, { Keys.O, "O" }, { Keys.OemBackslash, "\\" }, { Keys.OemClear, "Clear" }, { Keys.OemCloseBrackets, "]" }, { Keys.Oemcomma, "," }, { Keys.OemMinus, "-" }, { Keys.OemOpenBrackets, "[" }, { Keys.OemPeriod, "." }, { Keys.OemPipe, "|" }, { Keys.Oemplus, "+" }, { Keys.OemQuestion, "?" }, { Keys.OemQuotes, "\"" }, { Keys.OemSemicolon, ";" }, { Keys.Oemtilde, "~" }, { Keys.P, "P" }, { Keys.Pause, "Pause" }, { Keys.Q, "Q" }, { Keys.R, "R" }, { Keys.Right, "Right" }, { Keys.S, "S" }, { Keys.Space, "Space" }, { Keys.T, "T" }, { Keys.Tab, "Tab" }, { Keys.U, "U" }, { Keys.Up, "Up" }, { Keys.V, "V" }, { Keys.W, "W" }, { Keys.X, "X" }, { Keys.Y, "Y" }, { Keys.Z, "Z" }, { Keys.Alt, "Alt" }, { Keys.Shift, "Shift" }, { Keys.Control, "Ctrl" }, }; internal static string ShortcutKeysToStr(Keys key) { List result = new List(); var keys = ValidShortcutKeys.Keys.ToList(); keys.Sort(); keys.Reverse(); foreach (var k in keys) { if (key.HasFlag(k)) { result.Add(ValidShortcutKeys[k]); key &= ~k; } } if (key != Keys.None) result.Add(key.ToString()); else if (result.Count == 0) result.Add("None"); if (result.Contains("LShift") || result.Contains("RShift") || result.FindAll((string s) => s == "Shift").Count > 1) result.Remove("Shift"); if (result.Contains("LCtrl") || result.Contains("RCtrl") || result.FindAll((string s) => s == "Ctrl").Count > 1) result.Remove("Ctrl"); if (result.Contains("LAlt") || result.Contains("RAlt") || result.FindAll((string s) => s == "Alt").Count > 1) result.Remove("Alt"); return string.Join(" + ", result.ToArray()); } } }