Exemple #1
0
 private void BeeMovedHandler(object sender, BeeMovedEventArgs e)
 {
     if (_bees.ContainsKey(e.BeeThatMoved))
     {
         BeeStarHelper.MoveElementOnCanvas(_bees[e.BeeThatMoved], e.X, e.Y);
     }
     else
     {
         AnimatedImage newAnimatedImage = BeeStarHelper.BeeFactory(e.BeeThatMoved.Width, e.BeeThatMoved.Height, TimeSpan.FromMilliseconds(20));
         BeeStarHelper.SetCanvasLocation(newAnimatedImage, e.X, e.Y);
         _bees[e.BeeThatMoved] = newAnimatedImage;
         _sprites.Add(newAnimatedImage);
     }
 }
 void BeeMovedHandler(object sender, BeeMovedEventArgs e)
 {
     if (!_bees.ContainsKey(e.BeeThatMoved))
     {
         AnimatedImage beeControl = BeeStarHelper.BeeFactory(e.BeeThatMoved.Width, e.BeeThatMoved.Height, TimeSpan.FromMilliseconds(20));
         BeeStarHelper.SetCanvasLocation(beeControl, e.X, e.Y);
         _bees[e.BeeThatMoved] = beeControl;
         _sprites.Add(beeControl);
     }
     else
     {
         AnimatedImage beeImageMoved = _bees[e.BeeThatMoved];
         BeeStarHelper.MoveElementOnCanvas(beeImageMoved, e.X, e.Y);
     }
 }
Exemple #3
0
 private void _model_BeeMoved(object sender, BeeMovedEventArgs e)
 {
     if (!_bees.ContainsKey(e.BeeThatMoved) || (_bees.ContainsKey(e.BeeThatMoved) && _bees[e.BeeThatMoved] == null))
     {
         AnimatedImage image =
             BeeStarHelper.BeeFactory(e.BeeThatMoved.Width, e.BeeThatMoved.Height,
                                      TimeSpan.FromMilliseconds(50));
         BeeStarHelper.SetCanvasLocation(image, e.X, e.Y);
         _bees.Add(e.BeeThatMoved, image);
         _sprites.Add(image);
     }
     else
     {
         AnimatedImage imageToMove = _bees[e.BeeThatMoved];
         BeeStarHelper.MoveElementOnCanvas(imageToMove, e.X, e.Y);
     }
 }
        void BeeMovedHandler(object sender, BeeMovedEventArgs e)
        {
            // The _bees dictionary maps Bee objects in the Model to AnimatedImage controls
            // in the view. When a bee is moved, the BeeViewModel fires its BeeMoved event to
            // tell anyone listening which bee moved and its new location. If the _bees
            // dictionary doesn't already contain an AnimatedImage control for the bee, it needs
            // to create a new one, set its canvas location, and update both _bees and _sprites.
            // If the _bees dictionary already has it, then we just need to look up the corresponding
            // AnimatedImage control and move it on the canvas to its new location with an animation.

            if (!_bees.ContainsKey(e.BeeThatMoved))
            {
                AnimatedImage beeControl = BeeStarHelper.BeeFactory(e.BeeThatMoved.Width, e.BeeThatMoved.Height, TimeSpan.FromMilliseconds(20));
                BeeStarHelper.SetCanvasLocation(beeControl, e.X, e.Y);
                _bees[e.BeeThatMoved] = beeControl;
                _sprites.Add(beeControl);
            }
            else
            {
                BeeStarHelper.MoveElementOnCanvas(_bees[e.BeeThatMoved], e.X, e.Y);
            }
        }