public void SetWave(Color col) { _cancellationTokenSource = new CancellationTokenSource(); var rzSt = new Task(() => { StopEffects(); Thread.Sleep(100); ColorCycle(col, _cancellationTokenSource.Token); }, _cancellationTokenSource.Token); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); }
public void UpdateState(string type, Color col, bool disablekeys, [Optional] Color col2, [Optional] bool direction, [Optional] int speed) { if (!_logitechDeviceKeyboard) { return; } MemoryTasks.Cleanup(); _cancellationTokenSource?.Cancel(); if (type == "reset") { StopEffects(); Thread.Sleep(100); SetLights(Color.FromArgb(0, 0, 0)); } else if (type == "static") { var rzSt = new Task(() => { StopEffects(); Thread.Sleep(100); SetLights(col); }); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); } else if (type == "transition") { var rzSt = new Task(() => { StopEffects(); Thread.Sleep(100); SetLights(col); }); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); } else if (type == "wave") { _cancellationTokenSource = new CancellationTokenSource(); var rzSt = new Task(() => { StopEffects(); Thread.Sleep(100); ColorCycle(col, _cancellationTokenSource.Token); }, _cancellationTokenSource.Token); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); } else if (type == "breath") { _cancellationTokenSource = new CancellationTokenSource(); var rzSt = new Task(() => { //TODO: Does this need to be canceled since it is infinite? //Roxas: I'm not using the breath effect currently so as I don't know what purpose it will serve, having a cancellation token is probably a good idea. Pulse(col, LogitechSdkWrapper.LogiLedDurationInfinite, 60); }, _cancellationTokenSource.Token); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); } else if (type == "pulse") { var rzSt = new Task(() => { StopEffects(); Thread.Sleep(100); SetLights(col); }); MemoryTasks.Add(rzSt); MemoryTasks.Run(rzSt); } MemoryTasks.Cleanup(); }
public void UpdateState(string type, Color col, bool disablekeys, [Optional] Color col2, [Optional] bool direction, [Optional] int speed) { if (!_initialized) { return; } MemoryTasks.Cleanup(); if (type == "reset") { try { if (_roccatDeviceKeyboard && disablekeys != true) { // } } catch { // } } else if (type == "static") { try { if (_roccatDeviceKeyboard && disablekeys != true) { UpdateRoccatStateAll(col); } } catch (Exception ex) { Write.WriteConsole(ConsoleTypes.Error, @"Corsair (Static)" + ex.Message); } } else if (type == "transition") { var crSt = new Task(() => { if (_roccatDeviceKeyboard && disablekeys != true) { // } }); MemoryTasks.Add(crSt); MemoryTasks.Run(crSt); } else if (type == "wave") { var crSt = new Task(() => { if (_roccatDeviceKeyboard && disablekeys != true) { // } }); MemoryTasks.Add(crSt); MemoryTasks.Run(crSt); } else if (type == "breath") { var crSt = new Task(() => { try { if (_roccatDeviceKeyboard && disablekeys != true) { // } } catch (Exception ex) { Write.WriteConsole(ConsoleTypes.Error, @"Coolermaster (Breath): " + ex.Message); } }); MemoryTasks.Add(crSt); MemoryTasks.Run(crSt); } else if (type == "pulse") { var crSt = new Task(() => { if (_roccatDeviceKeyboard && disablekeys != true) { // } }, _ccts.Token); MemoryTasks.Add(crSt); MemoryTasks.Run(crSt); //RzPulse = true; } MemoryTasks.Cleanup(); }