示例#1
0
        public void FadeItemConstructorWithFadeItem()
        {
            tlog.Debug(tag, $"FadeItemConstructorWithFadeItem START");

            using (View view = new View())
            {
                using (TimePeriod timePeriod = new TimePeriod(300))
                {
                    using (AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default))
                    {
                        using (FadeItem item = new FadeItem(view, 0.3f, false, timePeriod, alphaFunction))
                        {
                            var testingTarget = new FadeItem(item);
                            Assert.IsNotNull(testingTarget, "Should be not null!");
                            Assert.IsInstanceOf <FadeItem>(testingTarget, "Should be an Instance of FadeItem!");

                            testingTarget.Dispose();
                            // disposed
                            testingTarget.Dispose();
                        }
                    }
                }
            }

            tlog.Debug(tag, $"FadeItemConstructorWithFadeItem END (OK)");
        }
示例#2
0
        private void FadeTimerColor(FadeItem init, FadeItem dest)
        {
            var current = new FadeItem()
            {
                Time = this.CurrentTime, Color = this.TimerColor
            };

            ////this.TimerColor = ColorFader.Linear(init, dest, current);
            this.TimerColor = ColorFader.BoundedExponential(init, dest, current);
        }
示例#3
0
        private void TimerTickState()
        {
            bool     fade = false;
            FadeItem init = new FadeItem
            {
                Color = this.Settings.VisualSettings.RunningColor,
                Time  = this.Settings.TimerDuration.Duration
            };

            FadeItem dest = new FadeItem
            {
                Color = default(Color),
                Time  = default(int),
            };

            switch (this.TimerState)
            {
            case TimerState.Running:
            {
                if (this.Settings.TimerDuration.HasFirstWarning)
                {
                    fade       = true;
                    init.Color = this.Settings.VisualSettings.RunningColor;
                    init.Time  = this.Settings.TimerDuration.Duration;
                    if (this.Settings.VisualSettings.CounterMode == TimerVisualSettings.TimerCounterMode.CountUp)
                    {
                        init.Time = 0;
                    }

                    dest.Color = this.Settings.VisualSettings.WarningColor;
                    dest.Time  = this.Settings.TimerDuration.WarningTime;
                }

                break;
            }

            case TimerState.FirstWarning:
            {
                fade       = true;
                init.Color = this.Settings.VisualSettings.WarningColor;
                init.Time  = this.Settings.TimerDuration.WarningTime;

                if (this.Settings.TimerDuration.HasSecondWarning)
                {
                    dest.Color = this.Settings.VisualSettings.SecondWarningColor;
                    dest.Time  = this.Settings.TimerDuration.SecondWarningTime;
                }
                else
                {
                    dest.Color = this.Settings.VisualSettings.ExpiredColor;
                    dest.Time  = 0;
                    if (this.Settings.VisualSettings.CounterMode == TimerVisualSettings.TimerCounterMode.CountUp)
                    {
                        dest.Time = this.Settings.TimerDuration.Duration;
                    }
                }

                //					this.TimerColor = this.Settings.VisualSettings.WarningColor;
                break;
            }

            case TimerState.SecondWarning:
            {
                fade       = true;
                init.Color = this.Settings.VisualSettings.SecondWarningColor;
                init.Time  = this.Settings.TimerDuration.SecondWarningTime;

                dest.Color = this.Settings.VisualSettings.ExpiredColor;
                dest.Time  = 0;
                if (this.Settings.VisualSettings.CounterMode == TimerVisualSettings.TimerCounterMode.CountUp)
                {
                    dest.Time = this.Settings.TimerDuration.Duration;
                }

                //					this.TimerColor = this.Settings.VisualSettings.WarningColor;
                break;
            }

            case TimerState.Expired:
            {
                if (!this.Settings.BlinkOnExpired || !this.blinkManager.IsBlinking)
                {
                    this.TimerColor = this.Settings.VisualSettings.ExpiredColor;
                }

                if (this.Settings.BlinkOnExpired)
                {
                    if (!this.blinkManager.IsBlinking)
                    {
                        this.blinkManager.StartBlinking();
                        this.OnTimeExpired();
                    }
                }
                else
                {
                    this.OnTimeExpired();
                }

                break;
            }


            case TimerState.Stopped:
            {
                this.StopTimer();
                if (!this.DisplayFinalMessage())
                {
                    this.DisplayTimeElapsed(this.CurrentTime);
                }

                this.OnDurationElapsed();

                break;
            }

            default:
                break;
            }

            if (fade)
            {
                this.FadeTimerColor(init, dest);
            }
        }