public void Dispose() { if (api != null) { api.Dispose(); } api = null; keyboardFrame = null; }
public MousepadFrame(NativeRazerApi api) { this._api = api; this.rawEffect = new RazerChroma.Net.MousePad.Effects.Custom(new NativeWin32.ColorRef[RazerChroma.Net.MousePad.Definitions.MaxLeds]); this.lastEffect = null; for (int i = 0; i < RazerChroma.Net.MousePad.Definitions.MaxLeds; i++) { this.rawEffect.Color[i].A = 255; this.rawEffect.Color[i].R = 0; this.rawEffect.Color[i].G = 0; this.rawEffect.Color[i].B = 0; } }
static ChromaDevice[] GetActiveDevices(ChromaDevice[] deviceSet, NativeRazerApi api) { List <ChromaDevice> connectedDevices = new List <ChromaDevice>(); foreach (ChromaDevice device in deviceSet) { RazerChroma.Net.ChromaSDK.DeviceInfoType queryResult = api.TryQueryDevice(device.id, out bool Success); if (Success && queryResult.Connected > 0) { connectedDevices.Add(device); } } return(connectedDevices.ToArray()); }
public KeyboradFrame(NativeRazerApi api) { this._api = api; this.rawEffect = new RazerChroma.Net.Keyboard.Effects.Custom(new NativeWin32.ColorRef[RazerChroma.Net.Keyboard.Definitions.MaxRow, RazerChroma.Net.Keyboard.Definitions.MaxCol]); this.lastEffect = null; for (int row = 0; row < RazerChroma.Net.Keyboard.Definitions.MaxRow; row++) { for (int col = 0; col < RazerChroma.Net.Keyboard.Definitions.MaxCol; col++) { this.rawEffect.Color[row, col].A = 255; this.rawEffect.Color[row, col].R = 0; this.rawEffect.Color[row, col].G = 0; this.rawEffect.Color[row, col].B = 0; } } }
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; }
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(); }
public HeadsetFrame(NativeRazerApi api) { this._api = api; this.rawEffect = new RazerChroma.Net.HeadSet.Effects.Static(new NativeWin32.ColorRef(0, 0, 0, 255)); this.lastEffect = null; }