Beispiel #1
0
        private void CreateAnimation(GuidedTourItem item)
        {
            if (animateGuideStoryboard != null)
            {
                RemoveAnimation();
            }
            else
            {
                animateGuideStoryboard = new Storyboard();
            }

            double          from = 0, to = 0;
            DoubleAnimation doubleAnimation = new DoubleAnimation();
            IEasingFunction easing          = null; // new CircleEase() { EasingMode = EasingMode.EaseOut };

            switch (item.Placement)
            {
            case GuidedTourItem.ItemPlacement.Left:
            case GuidedTourItem.ItemPlacement.Right:
                to   = item.Placement == GuidedTourItem.ItemPlacement.Right ? item.Position.X + ANIMATION_MOVEMENT : item.Position.X - ANIMATION_MOVEMENT;
                from = item.Position.X;
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)"));
                break;

            case GuidedTourItem.ItemPlacement.Top:
            case GuidedTourItem.ItemPlacement.Bottom:
                to   = item.Placement == GuidedTourItem.ItemPlacement.Top ? item.Position.Y - ANIMATION_MOVEMENT : item.Position.Y + ANIMATION_MOVEMENT;
                from = item.Position.Y;
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                break;
            }

            doubleAnimation.From        = from;
            doubleAnimation.To          = to;
            doubleAnimation.Duration    = new Duration(new TimeSpan(0, 0, 0, 0, ANIMATION_DURATION));
            doubleAnimation.BeginTime   = TimeSpan.FromSeconds(0.3);
            doubleAnimation.AutoReverse = true;
            Storyboard.SetTarget(doubleAnimation, item);
            animateGuideStoryboard.Children.Add(doubleAnimation);
            doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            doubleAnimation.EasingFunction = easing;
            animateGuideStoryboard.Begin();
        }
Beispiel #2
0
        private void SetGuideItemPosition(GuidedTourItem item)
        {
            if (!IsLoaded)
            {
                return;
            }

            var targetPoint = item.Target.PointToScreen(new Point(0, 0));
            var thisPoint   = this.PointToScreen(new Point(0, 0));

            switch (item.Placement)
            {
            case GuidedTourItem.ItemPlacement.Left:
                item.Position = new Point((targetPoint.X - thisPoint.X) - item.ActualWidth - MARGIN, targetPoint.Y - thisPoint.Y + ((item.Target.ActualHeight / 2) - (item.ActualHeight / 2)));
                break;

            case GuidedTourItem.ItemPlacement.Right:
                item.Position = new Point((targetPoint.X - thisPoint.X) + item.Target.ActualWidth + MARGIN, targetPoint.Y - thisPoint.Y + ((item.Target.ActualHeight / 2) - (item.ActualHeight / 2)));
                break;

            case GuidedTourItem.ItemPlacement.Bottom:
                item.Position = new Point((targetPoint.X - thisPoint.X) + ((item.Target.ActualWidth / 2) - (item.ActualWidth / 2)),
                                          targetPoint.Y - thisPoint.Y + (item.Target.ActualHeight + MARGIN));
                break;

            case GuidedTourItem.ItemPlacement.Top:
                item.Position = new Point((targetPoint.X - thisPoint.X) + ((item.Target.ActualWidth / 2) - (item.ActualWidth / 2)),
                                          targetPoint.Y - thisPoint.Y - (item.ActualHeight + MARGIN));
                break;

            default:
                item.Position = new Point((targetPoint.X - thisPoint.X) + ((item.Target.ActualWidth / 2) - (item.ActualWidth / 2)), targetPoint.Y - thisPoint.Y + ((item.Target.ActualHeight / 2) - (item.ActualHeight / 2)));
                break;
            }

            SetLeft(item, item.Position.X);
            SetTop(item, item.Position.Y);
        }
Beispiel #3
0
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        public void Dispose()
        {
            CurrentItem = null;

            RemoveAnimation();
        }