using Colore;
using Colore.Data;
using Colore.Effects.Keyboard;
using System;
namespace ChromaController
{
internal class FlashKey : KeyEffect
{
public float FlashTime { get; }
///
/// Flashes key with specified color for specified time.
///
/// The that will flash
/// The startcolor
/// The endcolor
/// The amount of steps that will be shown
public FlashKey(Key[] keys, Color color1, Color color2, int flashTime, int delayTime = 0) : base(keys, color1, color2, delayTime)
{
if (flashTime <= 0) throw new ArgumentException("argument should be between 0 and 1", "stepPercentage");
FlashTime = flashTime;
}
public FlashKey(Key key, Color color1, Color color2, int flashTime, int delayTime = 0)
: this(new Key[] { key }, color1, color2, flashTime, delayTime)
{
}
public override bool Step(IChroma chroma)
{
bool baseResult = base.Step(chroma);
if (StepCounter <= DelayTime) return baseResult;
if (StepCounter > FlashTime + DelayTime)
{
chroma.Keyboard.SetKeysAsync(Keys, Color2, false);
return true;
}
chroma.Keyboard.SetKeysAsync(Keys, Color1, false);
return baseResult;
}
}
}