internal void BeginRemoveAnimation(MSet<LLShape> erasedShapes)
{
var cancellingShapes = erasedShapes.Select(s => Pair.Create(s, s.Opacity)).ToList();
var cancellingTimer = new Timer { Interval = 30, Enabled = true };
var cancellingLayer = AddLayer();
cancellingLayer.Shapes = erasedShapes;
int opacity = 255;
cancellingTimer.Tick += (s, e) =>
{
opacity -= 32;
if (opacity > 0)
{
foreach (var pair in cancellingShapes)
pair.A.Opacity = (byte)(pair.B * opacity >> 8);
cancellingLayer.Invalidate();
}
else
{
DisposeLayerAt(Layers.IndexOf(cancellingLayer));
cancellingTimer.Dispose();
cancellingLayer.Dispose();
}
};
}