Ejemplo n.º 1
0
        private void RenderTags(Canvas canvasOne, Canvas canvasTwo, double X, double Y)
        {
            if(_viewModel.ClickedSpot==null)
            {
                return;
            }

            var random = new Random();
            var index = random.Next(1, 4);
            var uriStr = "ms-appx:///Assets/labels/label_" + index + ".png";
            var tagLeft = new Image { Source = new BitmapImage(new Uri(uriStr, UriKind.RelativeOrAbsolute)) };
            canvasOne.Children.Add(tagLeft);
            tagLeft.RenderTransformOrigin = new Point(0.50, 0.05);
            Canvas.SetLeft(tagLeft, X);
            Canvas.SetTop(tagLeft, Y);
            tagLeft.RenderTransform = new CompositeTransform();
            var anima = tagLeft.AnimateProperty<DoubleAnimationUsingKeyFrames>("(UIElement.RenderTransform).(CompositeTransform.Rotation)").AddEasingKeyFrame(0, 10).AddEasingKeyFrame(1.0, 0, new BackEase());

            var tagRight = new Image { Source = new BitmapImage(new Uri(uriStr, UriKind.RelativeOrAbsolute)) };
            canvasTwo.Children.Add(tagRight);
            tagRight.RenderTransformOrigin = new Point(0.50, 0.05);
            Canvas.SetLeft(tagRight, X);
            Canvas.SetTop(tagRight, Y);
            tagRight.RenderTransform = new CompositeTransform();
            var animaRight = tagRight.AnimateProperty<DoubleAnimationUsingKeyFrames>("(UIElement.RenderTransform).(CompositeTransform.Rotation)").AddEasingKeyFrame(0, 10).AddEasingKeyFrame(1.0, 0, new BackEase());

            var bs = new Storyboard();
            bs.Children.Add(anima);
            bs.Children.Add(animaRight);
            bs.Begin();
            
            _viewModel.FoundSpotsCount++;

            CheckLevelAndGameCompleteStatus();
        }