示例#1
0
        public override void Start()
        {
            base.Start();

            CalculateMaxRadius();

            var state = new Models.EntertainmentState();

            state.SetBrightness(1);
            state.SetRGBColor(RGBColor.Random());

            this.State = state;

            _cts = new CancellationTokenSource();

            Task.Run(async() =>
            {
                double step = StepSize;
                while (true && !_cts.IsCancellationRequested)
                {
                    Radius += step;
                    await Task.Delay(_waitTime(), _cts.Token).ConfigureAwait(false);
                    if (Radius >= _maxRadius)
                    {
                        if (_fadeToZero)
                        {
                            step = -1 * Math.Abs(StepSize);
                        }
                        else
                        {
                            Radius = 0;

                            if (!AutoRepeat)
                            {
                                break;
                            }

                            state.SetRGBColor(RGBColor.Random());
                        }
                    }
                    if (Radius <= 0)
                    {
                        if (!AutoRepeat)
                        {
                            break;
                        }

                        step = Math.Abs(StepSize);
                        state.SetRGBColor(RGBColor.Random());
                    }
                }
            }, _cts.Token);
        }
        public override void Start()
        {
            base.Start();

            var state = new Models.EntertainmentState();

            state.SetBrightness(1);
            state.SetRGBColor(_color);

            this.State = state;

            _cts = new CancellationTokenSource();

            Task.Run(async() =>
            {
                double step = StepSize;
                if (this.Y > 0)
                {
                    step = -1 * StepSize;
                }

                while (true && !_cts.IsCancellationRequested)
                {
                    await Task.Delay(_waitTime(), _cts.Token).ConfigureAwait(false);
                    if (this.Y >= TurningPoint)
                    {
                        if (!AutoRepeat)
                        {
                            break;
                        }

                        step = -1 * Math.Abs(step);
                    }
                    else if (this.Y <= (-1 * TurningPoint))
                    {
                        if (!AutoRepeat)
                        {
                            break;
                        }

                        step = Math.Abs(step);
                    }

                    this.Y += step;
                }
            }, _cts.Token);
        }
示例#3
0
        public override void Start()
        {
            base.Start();

            var state = new Models.EntertainmentState();

            state.SetBrightness(1);
            state.SetRGBColor(GetRandomColor());

            this.State = state;

            _cts = new CancellationTokenSource();

            Task.Run(async() =>
            {
                double step = 0.2;
                while (true && !_cts.IsCancellationRequested)
                {
                    Radius += step;
                    await Task.Delay(_waitTime.Value.Value, _cts.Token).ConfigureAwait(false);
                    if (Radius >= 2)
                    {
                        if (_fadeToZero)
                        {
                            step = -0.2;
                        }
                        else
                        {
                            Radius = 0;
                            state.SetRGBColor(GetRandomColor());
                        }
                    }
                    if (Radius <= 0)
                    {
                        step = 0.2;
                        state.SetRGBColor(GetRandomColor());
                    }
                }
            }, _cts.Token);
        }