public void CheckLedChange() { Stopwatch sw = Stopwatch.StartNew(); var client = new OpenRGBClient(name: "OpenRGB.NET Test: CheckLedChange"); var controllerCount = client.GetControllerCount(); var devices = new Device[controllerCount]; for (int i = 0; i < controllerCount; i++) { devices[i] = client.GetControllerData(i); } for (int i = 0; i < controllerCount; i++) { var device = devices[i]; var originalColors = Color.GetHueRainbow(device.Leds.Length); client.UpdateLeds(i, originalColors.ToArray()); var updatedColors = client.GetControllerData(i).Colors; Assert.True(updatedColors.SequenceEqual(originalColors)); } client.Dispose(); sw.Stop(); Output.WriteLine($"Time elapsed: {(double)sw.ElapsedTicks / Stopwatch.Frequency * 1000} ms."); }
protected override void Update(Dictionary <object, Color> dataSet) { try { OpenRGBColor[] list = new OpenRGBColor[_ledcount]; for (int i = 0; i < _ledcount; i++) { list[i] = new OpenRGBColor(); } //int index; foreach (KeyValuePair <object, Color> data in dataSet) { //index = (int)data.Key; //list[index] = new OpenRGBColor(data.Value.GetR(), data.Value.GetG(), data.Value.GetB()); for (int j = 0; j < _ledcount; j++) { list[j] = new OpenRGBColor(data.Value.GetR(), data.Value.GetG(), data.Value.GetB()); } } _openRGB.UpdateLeds(_deviceid, list); } catch (Exception ex) { throw; } }
public override void Shutdown() { if (!IsInitialized) { return; } foreach (var d in _devices) { try { _openRgb.UpdateLeds(d.Index, d.OrgbDevice.Colors); } catch { //we tried. } } _openRgb?.Dispose(); _openRgb = null; IsInitialized = false; }