public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken, double x, double y) { Func <TimeSpan> customWaitTime = () => waitTime() / 10; if (!color.HasValue) { color = RGBColor.Random(); } HorizontalScanLineEffect hline = new HorizontalScanLineEffect(customWaitTime, color); hline.X = x; hline.AutoRepeat = false; layer.PlaceEffect(hline); VerticalScanLineEffect vline = new VerticalScanLineEffect(customWaitTime, color); vline.Y = y; vline.AutoRepeat = false; layer.PlaceEffect(vline); hline.Start(); vline.Start(); return(Task.Run(async() => { await Task.Delay(customWaitTime() * 15); hline.Stop(); vline.Stop(); await Task.Delay(TimeSpan.FromSeconds(1)); layer.Effects.Remove(hline); layer.Effects.Remove(vline); })); }
public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { //Non repeating effects should not run on baselayer if (layer.IsBaseLayer) { return; } Func <TimeSpan> customWaitTime = () => waitTime() / 10; var center = EffectSettings.LocationCenter; var randomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(fadeToZero: false, waitTime: customWaitTime); randomPulseEffect.X = center.X; randomPulseEffect.Y = center.Y; cancellationToken.Register(() => { try { randomPulseEffect.Stop(); } catch { } layer.Effects.Remove(randomPulseEffect); }); layer.PlaceEffect(randomPulseEffect); randomPulseEffect.AutoRepeat = false; randomPulseEffect.Start(); await Task.Delay(waitTime() * 2, cancellationToken); randomPulseEffect.Stop(); }
public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { Func <TimeSpan> customWaitTime = () => waitTime() / 10; var bottomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); bottomPulseEffect.AutoRepeat = false; bottomPulseEffect.Y = -1; layer.PlaceEffect(bottomPulseEffect); var topPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); topPulseEffect.AutoRepeat = false; topPulseEffect.Y = 1; layer.PlaceEffect(topPulseEffect); while (!cancellationToken.IsCancellationRequested) { bottomPulseEffect.Start(); await Task.Delay(waitTime() * 2.2); topPulseEffect.Start(); await Task.Delay(waitTime() * 2.2); } cancellationToken.Register(() => { bottomPulseEffect.Stop(); layer.Effects.Remove(bottomPulseEffect); topPulseEffect.Stop(); layer.Effects.Remove(topPulseEffect); }); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken, double x, double y) { RedLightEffect effect = new RedLightEffect(); effect.X = x; effect.Y = y; layer.PlaceEffect(effect); effect.Start(); return(Task.Run(async() => { await Task.Delay(waitTime()); effect.Stop(); layer.Effects.Remove(effect); })); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken, double x, double y) { Func <TimeSpan> customWaitTime = () => waitTime() / 10; Q42.HueApi.Streaming.Effects.RandomPulseEffect effect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(false, customWaitTime); effect.X = x; effect.Y = y; effect.AutoRepeat = false; layer.PlaceEffect(effect); effect.Start(); return(Task.Run(async() => { await Task.Delay(waitTime() * 2); effect.Stop(); await Task.Delay(TimeSpan.FromSeconds(1)); layer.Effects.Remove(effect); })); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { Func <TimeSpan> customWaitTime = () => waitTime() / 10; var center = EffectSettings.LocationCenter; var randomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); randomPulseEffect.X = center.X; randomPulseEffect.Y = center.Y; layer.PlaceEffect(randomPulseEffect); randomPulseEffect.Start(); cancellationToken.Register(() => { randomPulseEffect.Stop(); layer.Effects.Remove(randomPulseEffect); }); return(Task.CompletedTask); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { Func <TimeSpan> customWaitTime = () => waitTime() / 10; if (!color.HasValue) { color = RGBColor.Random(); } var center = EffectSettings.LocationCenter; var rotatingEffect = new RotatingLineEffect(cancellationToken, color.Value, customWaitTime); rotatingEffect.X = center.X; rotatingEffect.Y = center.Y; layer.PlaceEffect(rotatingEffect); rotatingEffect.Start(); cancellationToken.Register(() => { rotatingEffect.Stop(); layer.Effects.Remove(rotatingEffect); }); return(Task.CompletedTask); }