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 }; }
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; }
public void Reset() { currentIndex = 0; CurrentFaderModel = new CodeFaderModel() { CurrentColor = ColorPattern[currentIndex], CurrentFadeTime = FadePattern[currentIndex], FadeComplete = false }; }