예제 #1
0
        /// <summary>
        /// Sets the view position of the scrollDirector.
        /// </summary>
        /// <param name="point">The new position.</param>
        /// <param name="animate">Indicates whether or not to animate the transition.</param>
        protected virtual void SetViewPosition(Point point, bool animate)
        {
            if (view == null)
            {
                return;
            }

            float oldX = 0, oldY = 0, x = point.X, y = point.Y;

            PointF vp = this.ViewPosition;

            oldX = vp.X;
            oldY = vp.Y;

            // Send the scroll director the exact view position and let it
            // interpret it as needed
            float newX = x;
            float newY = y;

            if ((oldX != newX) || (oldY != newY))
            {
                if (animate)
                {
                    scroll = new ScrollActivity(ViewPosition, point, scrollDirector, animateScrollDuration);
                    Canvas.Root.AddActivity(scroll);
                }
                else
                {
                    scrollDirector.SetViewPosition(newX, newY);
                }
            }
        }
예제 #2
0
 public override void SetRelativeTargetValue(float zeroToOne)
 {
     scrollDirector.SetViewPosition(oldX + zeroToOne * (newX - oldX),
                                    oldY + zeroToOne * (newY - oldY));
 }