void lastEltToRemove_Stopped()
 {
     this.Visibility = Visibility.Collapsed;
     lastEltToRemove = null;
 }
        private void loadElt(Point p)
        {
            pointsAreadyDone.Add(p);

            SecreteAnimationControl elt = new SecreteAnimationControl();
            elt.Width = secretElementWidth;
            elt.Height = secretElementHeight;

            //RootCanvas
            RootCanvas.Children.Add(elt);
            RootCanvas.Visibility = Visibility.Visible;
            int YIndice = (int)p.Y;
            int XIndice = (int)p.X;
            double left = XIndice * (secretElementWidth);
            double top = YIndice * (secretElementHeight);
            Canvas.SetLeft(elt, left);
            Canvas.SetTop(elt, top);

            elt.ForegroundColor = ColorManager.Instance.RandomAccentBrush;
            // OpacityEffect oe = new OpacityEffect(0, 1, 1, StartAnimationDuration, EasingMode.EaseIn, new CircleEase());
            MoveEffect me = new MoveEffect(new Point(0, -top), new Point(0, 0), 10, StartAnimationDuration, EasingMode.EaseIn, new CircleEase());
            RotateEffect re = new RotateEffect(-90, 0, 1, StartAnimationDuration, EasingMode.EaseOut, new CircleEase());
            re.RotationCenter = new Point(0, 0);
            elt.addStartEffect(me);
            elt.addStartEffect(re);
            // elt.addStartEffect(oe);
            MoveEffect meStop = new MoveEffect(new Point(0, 0), new Point(0, 1.1 * Height), 1, StopAnimationDuration, EasingMode.EaseIn, new CircleEase());
            RotateEffect reStop = new RotateEffect(0, -90, 1, StopAnimationDuration, EasingMode.EaseOut, new CircleEase());
            reStop.RotationCenter = new Point(0, 0);
            elt.addStopEffect(meStop);
            elt.addStopEffect(reStop);
            elt.load();
            listOfElements.Add(elt);
            animStartOfElements.Enqueue(elt);
            animStopOfElements.Enqueue(elt);

        }
 public void StopAnimation()
 {
     if (animStopOfElements != null && animStopOfElements.Count > 0)
     {
         SecreteAnimationControl elt = animStopOfElements.Dequeue();
         lastEltToRemove = elt;
         elt.stop();
     }
     else
     {
         if (lastEltToRemove != null)
             lastEltToRemove.Stopped += lastEltToRemove_Stopped;
         if (animTimer != null)
             animTimer.Stop();
     }
 }