public virtual PActivity DirectCameraViewToFocus(PCamera aCamera, PNode aFocusNode, PPickPath path, int duration) { PMatrix originalViewMatrix = aCamera.ViewMatrix; // Scale the canvas to include SizeF s = new SizeF(1, 0); s = aFocusNode.GlobalToLocal(s); float scaleFactor = s.Width / aCamera.ViewScale; PointF scalePoint = PUtil.CenterOfRectangle(aFocusNode.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(aFocusNode.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); PMatrix resultingMatrix = aCamera.ViewMatrix; aCamera.ViewMatrix = originalViewMatrix; // Animate the canvas so that it ends up with the given // view transform. PActivity animateCameraViewActivity = AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration); PControl controlNode = (PControl)aFocusNode; aCamera.Root.WaitForActivities(); controlNode.CurrentCanvas = path.TopCamera.Canvas; PointF pf = path.GetPathTransformTo(controlNode).Transform(new PointF(controlNode.X, controlNode.Y)); controlNode.ControlLocation = new Point((int)pf.X, (int)pf.Y); controlNode.Editing = true; return animateCameraViewActivity; }
/// <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 == PathPickMode.Fast) { return base.PickAfterChildren(pickPath); } else { return Intersects(pickPath.PickBounds, pickPath.GetPathTransformTo(this)); } }