/// Attempts to initialize the device instance. public bool Initialize() { lock (action_lock) { if (!isInitialized) { try { if (!DrevoRadiSDK.DrevoRadiInit()) { Global.logger.Error("Drevo Radi SDK could not be initialized."); isInitialized = false; return(false); } isInitialized = true; return(true); } catch (Exception exc) { Global.logger.Error("There was an error initializing Drevo Radi SDK.\r\n" + exc.Message); return(false); } } return(isInitialized); } }
/// 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 void Shutdown() { if (!IsInitialized) { return; } try { DrevoRadiSDK.DrevoRadiShutdown(); IsInitialized = false; } catch (Exception exc) { LogError("Exception during Shutdown: " + exc); IsInitialized = false; } }
/// Shuts down the device instance. public void Shutdown() { lock (action_lock) { try { if (IsInitialized()) { this.Reset(); isInitialized = false; DrevoRadiSDK.DrevoRadiShutdown(); } } catch (Exception exc) { Global.logger.Error("Drevo device, Exception during Shutdown. Message: " + exc); isInitialized = false; } } }
public override bool Initialize() { if (IsInitialized) { return(IsInitialized); } try { if (!DrevoRadiSDK.DrevoRadiInit()) { LogError("Drevo Radi SDK could not be initialized."); return(IsInitialized = false); } return(IsInitialized = true); } catch (Exception exc) { LogError($"There was an error initializing Drevo Radi SDK: {exc.Message}"); return(IsInitialized = false); } }
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); } }