public void Dispose()
 {
     if (api != null)
     {
         api.Dispose();
     }
     api           = null;
     keyboardFrame = null;
 }
 private void Init()
 {
     try
     {
         if (api == null)
         {
             api = new NativeRazerApi();
         }
         if (keyboardFrame == null)
         {
             keyboardFrame = new KeyboradFrame(api);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Error initializing Razer Chroma controller. Is Razer Synapse installed?");
         throw new InvalidOperationException("Error initializing Razer Chroma controller. Is Razer Synapse installed?", e);
     }
 }
 public void SetEnabled(bool enabled)
 {
     if (this.enabled == enabled)
     {
         return;
     }
     if (!enabled)
     {
         if (api != null)
         {
             api.Dispose();
         }
         api           = null;
         keyboardFrame = null;
     }
     else
     {
         Init();
     }
     this.enabled = enabled;
 }
Exemplo n.º 4
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();
        }