public void SendData(int ledCount, byte[] colorArray, LightingMode mode)
        {
            if (!enabled)
            {
                return;
            }
            List <Point> points = new List <Point>();

            if (mode == LightingMode.Line)
            {
                for (int i = 0; i < ledCount; i++)
                {
                    Color c = Color.FromArgb(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                    int   x = (int)Utils.Scale(i, 0, ledCount, 0, 22);// TODO: Handle keyboards without numpads
                    points.Clear();
                    points.Add(new Point(x, 0));
                    points.Add(new Point(x, 1));
                    points.Add(new Point(x, 2));
                    points.Add(new Point(x, 3));
                    points.Add(new Point(x, 4));
                    points.Add(new Point(x, 5));
                    try
                    {
                        keyboardFrame.SetKeys(points, c);
                    } catch (Exception)
                    {
                        Console.WriteLine("Error sending data to Chroma keyboard. Perhaps it doesn't have a keypad");
                    }
                }
            }
            else if (mode == LightingMode.Point)
            {
                points.Clear();
                for (int i = 0; i < 22; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        points.Add(new Point(i, j));
                    }
                }
                try
                {
                    keyboardFrame.SetKeys(points, Color.FromArgb(colorArray[0], colorArray[1], colorArray[2]));
                } catch (Exception) // TODO: Handle keyboards without numpads
                {
                    Console.WriteLine("Error sending data to Chroma keyboard. Perhaps it doesn't have a keypad");
                }
            }
            else if (mode == LightingMode.Keyboard)
            {
                foreach (RzKey key in numPadKeys)
                {
                    keyboardFrame.SetKey(key, Color.Black); // set numpad keys to black
                }
                for (int i = 0; i < 88; i++)
                {
                    Color c = Color.FromArgb(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                    keyboardFrame.SetKey(indexKeyMap[i], c);
                }
            }
            else
            {
                Console.Error.WriteLine("RazerChroma: Invalid lighting mode");
                throw new ArgumentException("Invalid lighting mode");
            }

            keyboardFrame.Update();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Running!!");
            NativeRazerApi api = new NativeRazerApi();

            System.Threading.Thread.Sleep(1000);
            ChromaDevice[] allDevices       = GetAllDevices();
            ChromaDevice[] connectedDevices = GetActiveDevices(allDevices, api);
            Console.ForegroundColor = ConsoleColor.Green;
            foreach (ChromaDevice connectedDevice in connectedDevices)
            {
                Console.WriteLine("Device detected: " + connectedDevice.Name);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Setting keyboard color to yellow");
            api.CreateKeyboardEffect(new RazerChroma.Net.Keyboard.Effects.Static(new NativeWin32.ColorRef(255, 255, 0, 0))).Set();
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Setting mouse color to red");
            api.CreateMouseEffect(new RazerChroma.Net.Mouse.Effects.Static(RazerChroma.Net.Mouse.Definitions.RzLed.All, new NativeWin32.ColorRef(255, 0, 0, 0))).Set();
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Setting headset color to green");
            api.CreateHeadSetEffect(new RazerChroma.Net.HeadSet.Effects.Static(new NativeWin32.ColorRef(0, 255, 0, 0))).Set();
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Setting mousemat color to blue");
            api.CreateMousepadEffect(new RazerChroma.Net.MousePad.Effects.Static(new NativeWin32.ColorRef(0, 0, 255, 0))).Set();
            Console.ResetColor();


            Console.WriteLine("First test, Please check that your devices have the right light color, If you dont have that device it is ok.");
            Console.WriteLine("Done, Click an to Continue...");
            Console.ReadKey();

            KeyboradFrame keyboardFrame = new KeyboradFrame(api);
            MouseFrame    mouseFrame    = new MouseFrame(api);
            MousepadFrame mousepadFrame = new MousepadFrame(api);
            HeadsetFrame  headsetFrame  = new HeadsetFrame(api);

            keyboardFrame.SetKey(0, 1, Color.Red);
            keyboardFrame.SetKey(Definitions.RzKey.F, Color.Green);
            keyboardFrame.SetKeys(1, 0, 2, 1, Color.Yellow);
            mouseFrame.SetKey(RazerChroma.Net.Mouse.Definitions.RzLed2.Scrollwheel, Color.Purple);
            mousepadFrame.SetKeys(0, 5, Color.Green);
            headsetFrame.Set(Color.Red);

            headsetFrame.Update();
            mousepadFrame.Update();
            mouseFrame.Update();
            keyboardFrame.Update();
            Console.WriteLine("Done, Click an to Continue...");


            Console.ReadKey();
        }