Exemplo n.º 1
0
        public BaseCodeFader(List<Color> colorPattern, List<float> fadePattern)
        {
            if (colorPattern.Count() != fadePattern.Count())
            {
                throw new ArgumentException("colorPattern and fadePattern must have an equal number of items.");
            }

            ColorPattern = colorPattern;
            FadePattern = fadePattern;

            maxPatternIndex = ColorPattern.Count() - 1;

            Loops = false;

            CurrentFaderModel = new CodeFaderModel()
            {
                CurrentColor = colorPattern[currentIndex],
                CurrentFadeTime = fadePattern[currentIndex],
                FadeComplete = false
            };
        }
Exemplo n.º 2
0
        public void GetNext()
        {
            bool indexIsInRange = currentIndex <= maxPatternIndex;

            if (!indexIsInRange && Loops)
            {
                currentIndex = 0;
                indexIsInRange = true;
            }
            else if (!Loops && !indexIsInRange)
            {
                fadeComplete = true;
            }

            CodeFaderModel model = new CodeFaderModel()
            {
                FadeComplete = fadeComplete
            };

            if (!fadeComplete)
            {
                if (indexIsInRange)
                {
                    model.CurrentColor = ColorPattern[currentIndex];
                    model.CurrentFadeTime = FadePattern[currentIndex];

                    currentIndex++;
                }
            }

            CurrentFaderModel = model;
        }
Exemplo n.º 3
0
        public void Reset()
        {
            currentIndex = 0;

            CurrentFaderModel = new CodeFaderModel()
            {
                CurrentColor = ColorPattern[currentIndex],
                CurrentFadeTime = FadePattern[currentIndex],
                FadeComplete = false
            };
        }