/// Updates the device with a specified color arrangement. public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } try { byte[] bitmap = new byte[392]; bitmap[0] = 0xF3; bitmap[1] = 0x01; bitmap[2] = 0x00; bitmap[3] = 0x7F; int index = 0; foreach (KeyValuePair <DeviceKeys, System.Drawing.Color> key in keyColors) { if (e.Cancel) { return(false); } index = DrevoRadiSDK.ToDrevoBitmap((int)key.Key); if (index != -1) { index = index * 3 + 4; bitmap[index] = key.Value.R; bitmap[index + 1] = key.Value.G; bitmap[index + 2] = key.Value.B; } } if (this.IsInitialized()) { DrevoRadiSDK.DrevoRadiSetRGB(bitmap, 392); } if (e.Cancel) { return(false); } return(true); } catch (Exception exc) { Global.logger.Error("Drevo device, error when updating device. Error: " + exc); Console.WriteLine(exc); return(false); } return(true); }
public override bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false) { if (!IsInitialized) { return(false); } try { byte[] bitmap = new byte[392]; bitmap[0] = 0xF3; bitmap[1] = 0x01; bitmap[2] = 0x00; bitmap[3] = 0x7F; int index = 0; foreach (var key in keyColors) { index = DrevoRadiSDK.ToDrevoBitmap((int)key.Key); if (index != -1) { index = index * 3 + 4; bitmap[index] = key.Value.R; bitmap[index + 1] = key.Value.G; bitmap[index + 2] = key.Value.B; } } return(DrevoRadiSDK.DrevoRadiSetRGB(bitmap, 392)); } catch (Exception exc) { LogError($"Error when updating device: {exc}"); return(false); } }