Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
            }));
        }
Exemplo n.º 3
0
        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 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);
            });
        }