Exemple #1
0
 /// <summary>
 /// Overridden.  Performs picking in canvas coordinates if <see cref="PickMode">PickMode</see>
 /// is false.
 /// </summary>
 /// <remarks>
 /// Due to the implementation of the GraphicsPath object, picking in canvas coordinates
 /// is more accurate, but will introduce a significant performance hit.
 /// </remarks>
 protected override bool PickAfterChildren(PPickPath pickPath)
 {
     if (pickMode == PPath.PathPickMode.Fast)
     {
         return(base.PickAfterChildren(pickPath));
     }
     else
     {
         return(Intersects(pickPath.PickBounds, pickPath.GetPathTransformTo(this)));
     }
 }
Exemple #2
0
        /// <summary>
        /// Animates the camera's view to keep the control node on the screen and at 100
        /// percent scale with minimal view movement.
        /// </summary>
        /// <param name="aCamera">The camera whose view will be animated.</param>
        /// <param name="aControlNode">The control node to animate to.</param>
        /// <param name="path">The pick path through which the control node was picked.</param>
        /// <param name="duration">The length of the animation.</param>
        /// <returns>
        /// The activity that animates the camera's view to the control node.
        /// </returns>
        public virtual PActivity DirectCameraViewToControl(PCamera aCamera, PControl aControlNode, PPickPath path, int duration)
        {
            Matrix originalViewMatrix = aCamera.ViewMatrix;

            // Scale the canvas to include
            SizeFx s = new SizeFx(1, 0);

            s = aControlNode.GlobalToLocal(s);

            float   scaleFactor = s.Width / aCamera.ViewScale;
            PointFx scalePoint  = PUtil.CenterOfRectangle(aControlNode.GlobalFullBounds);

            if (scaleFactor != 1)
            {
                aCamera.ScaleViewBy(scaleFactor, scalePoint.X, scalePoint.Y);
            }

            // Pan the canvas to include the view bounds with minimal canvas
            // movement.
            aCamera.AnimateViewToPanToBounds(aControlNode.GlobalFullBounds, 0);

            // Get rid of any white space. The canvas may be panned and
            // zoomed in to do this. But make sure not stay constrained by max
            // magnification.
            //FillViewWhiteSpace(aCamera);

            Matrix resultingMatrix = aCamera.ViewMatrix;

            aCamera.ViewMatrix = originalViewMatrix;

            PControl controlNode = (PControl)aControlNode;

            // Animate the canvas so that it ends up with the given
            // view transform.
            PActivity animateCameraViewActivity = AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration);

            aCamera.Root.WaitForActivities();

            Matrix  pathTransform = path.GetPathTransformTo(controlNode);
            PointFx point         = new PointFx(controlNode.X, controlNode.Y);
            PointFx pf            = MatrixExtensions.Transform(pathTransform, point);

            controlNode.ControlLocation = new System.Drawing.Point((int)pf.X, (int)pf.Y);
            controlNode.CurrentCanvas   = path.TopCamera.Canvas;
            controlNode.Editing         = true;

            return(animateCameraViewActivity);
        }