#lang en <> = Description = [[https://chroma-sdk.github.io/Colore/|Colore]] is an elegant solution for C# developers to work with Razer's Chroma SDK in a way that feels intuitive and similar to other .NET libraries. = Snippets = === Key Converter === Class to convert between Winforms Keys and Colore Keyboard Keys {{{#!highlight c# // Not all possible keys are included. This would not be possible using a dictionary, because winforms has, for instance, just one 'Enter' key, in contrast to Colore's normal- and numpad Enter key. using System.Collections.Generic; using System.Linq; using FormsKey = System.Windows.Forms.Keys; using ColoreKey = Colore.Effects.Keyboard.Key; namespace MyNameSpace { internal class KeyConverter { private readonly Dictionary formsKeys = new Dictionary { {ColoreKey.A, FormsKey.A }, {ColoreKey.B, FormsKey.B }, {ColoreKey.C, FormsKey.C }, {ColoreKey.D, FormsKey.D }, {ColoreKey.E, FormsKey.E }, {ColoreKey.F, FormsKey.F }, {ColoreKey.G, FormsKey.G }, {ColoreKey.H, FormsKey.H }, {ColoreKey.I, FormsKey.I }, {ColoreKey.J, FormsKey.J }, {ColoreKey.K, FormsKey.K }, {ColoreKey.L, FormsKey.L }, {ColoreKey.M, FormsKey.M }, {ColoreKey.N, FormsKey.N }, {ColoreKey.O, FormsKey.O }, {ColoreKey.P, FormsKey.P }, {ColoreKey.Q, FormsKey.Q }, {ColoreKey.R, FormsKey.R }, {ColoreKey.S, FormsKey.S }, {ColoreKey.T, FormsKey.T }, {ColoreKey.U, FormsKey.U }, {ColoreKey.V, FormsKey.V }, {ColoreKey.W, FormsKey.W }, {ColoreKey.X, FormsKey.X }, {ColoreKey.Y, FormsKey.Y }, {ColoreKey.Z, FormsKey.Z }, {ColoreKey.D0, FormsKey.D0 }, {ColoreKey.D1, FormsKey.D1 }, {ColoreKey.D2, FormsKey.D2 }, {ColoreKey.D3, FormsKey.D3 }, {ColoreKey.D4, FormsKey.D4 }, {ColoreKey.D5, FormsKey.D5 }, {ColoreKey.D6, FormsKey.D6 }, {ColoreKey.D7, FormsKey.D7 }, {ColoreKey.D8, FormsKey.D8 }, {ColoreKey.D9, FormsKey.D9 }, {ColoreKey.Num0, FormsKey.NumPad0 }, {ColoreKey.Num1, FormsKey.NumPad1 }, {ColoreKey.Num2, FormsKey.NumPad2 }, {ColoreKey.Num3, FormsKey.NumPad3 }, {ColoreKey.Num4, FormsKey.NumPad4 }, {ColoreKey.Num5, FormsKey.NumPad5 }, {ColoreKey.Num6, FormsKey.NumPad6 }, {ColoreKey.Num7, FormsKey.NumPad7 }, {ColoreKey.Num8, FormsKey.NumPad8 }, {ColoreKey.Num9, FormsKey.NumPad9 }, {ColoreKey.F1, FormsKey.F1 }, {ColoreKey.F2, FormsKey.F2 }, {ColoreKey.F3, FormsKey.F3 }, {ColoreKey.F4, FormsKey.F4 }, {ColoreKey.F5, FormsKey.F5 }, {ColoreKey.F6, FormsKey.F6 }, {ColoreKey.F7, FormsKey.F7 }, {ColoreKey.F8, FormsKey.F8 }, {ColoreKey.F9, FormsKey.F9 }, {ColoreKey.F10, FormsKey.F10 }, {ColoreKey.F11, FormsKey.F11 }, {ColoreKey.F12, FormsKey.F12 }, {ColoreKey.NumDivide, FormsKey.Divide }, {ColoreKey.NumMultiply, FormsKey.Multiply }, {ColoreKey.NumSubtract, FormsKey.Subtract }, {ColoreKey.NumAdd, FormsKey.Add }, {ColoreKey.NumDecimal, FormsKey.Decimal }, {ColoreKey.NumEnter, FormsKey.Enter }, {ColoreKey.NumLock, FormsKey.NumLock }, {ColoreKey.Escape, FormsKey.Escape }, {ColoreKey.PrintScreen, FormsKey.PrintScreen }, {ColoreKey.Scroll, FormsKey.Scroll }, {ColoreKey.Pause, FormsKey.Pause }, {ColoreKey.Insert, FormsKey.Insert }, {ColoreKey.Home, FormsKey.Home }, {ColoreKey.PageUp, FormsKey.PageUp }, {ColoreKey.PageDown, FormsKey.PageDown }, {ColoreKey.Delete, FormsKey.Delete }, {ColoreKey.End, FormsKey.End }, {ColoreKey.OemTilde, FormsKey.Oemtilde }, {ColoreKey.Tab, FormsKey.Tab }, {ColoreKey.CapsLock, FormsKey.CapsLock }, {ColoreKey.LeftShift, FormsKey.LShiftKey }, {ColoreKey.RightShift, FormsKey.RShiftKey }, {ColoreKey.LeftControl, FormsKey.LControlKey }, {ColoreKey.RightControl, FormsKey.RControlKey }, {ColoreKey.LeftWindows, FormsKey.LWin }, {ColoreKey.LeftAlt, FormsKey.Alt }, {ColoreKey.Space, FormsKey.Space }, {ColoreKey.Backspace, FormsKey.Back }, {ColoreKey.Up, FormsKey.Up }, {ColoreKey.Down, FormsKey.Down }, {ColoreKey.Left, FormsKey.Left }, {ColoreKey.Right, FormsKey.Right }, {ColoreKey.OemLeftBracket, FormsKey.OemOpenBrackets }, {ColoreKey.OemRightBracket, FormsKey.OemCloseBrackets }, {ColoreKey.OemComma, FormsKey.Oemcomma }, {ColoreKey.OemPeriod, FormsKey.OemPeriod }, {ColoreKey.KorPipe, FormsKey.OemPipe }, {ColoreKey.OemSemicolon, FormsKey.OemSemicolon}, {ColoreKey.OemApostrophe, FormsKey.OemQuotes }, {ColoreKey.OemSlash, FormsKey.OemQuestion }, }; private readonly Dictionary coloreKeys = new Dictionary(); public KeyConverter() { coloreKeys = formsKeys.ToDictionary(x => x.Value, x => x.Key); // Create Reverse-lookup dictionary } public ColoreKey ToColoreKey(FormsKey key) { return coloreKeys[key]; } public FormsKey ToFormsKey(ColoreKey key) { return formsKeys[key]; } } } }}}