UMD.HCIL.Piccolo.Event.PInputEventArgs.GetPositionRelativeTo C# (CSharp) Method

GetPositionRelativeTo() public method

Return the mouse position relative to a given node on the pick path.
public GetPositionRelativeTo ( PNode nodeOnPath ) : PointF
nodeOnPath PNode /// The returned position will be in the local coordinate system of this node. ///
return System.Drawing.PointF
		public virtual PointF GetPositionRelativeTo(PNode nodeOnPath) {
			PointF r = CanvasPosition;
			return pickPath.CanvasToLocal(r, nodeOnPath);
		}

Usage Example

        /// <summary>
        /// Overridden.  Do auto-panning even when the mouse is not moving.
        /// </summary>
        /// <param name="sender">The source of the drag event.</param>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected override void OnDragActivityStep(object sender, PInputEventArgs e)
        {
            base.OnDragActivityStep(sender, e);

            if (!autopan)
            {
                return;
            }

            PCamera    c = e.Camera;
            RectangleF b = c.Bounds;
            PointF     l = e.GetPositionRelativeTo(c);

            PUtil.OutCode outcode = PUtil.RectangleOutCode(l, b);
            SizeF         delta   = SizeF.Empty;

            if ((outcode & PUtil.OutCode.Top) != 0)
            {
                delta.Height = ValidatePanningDelta(-1.0f - (0.5f * Math.Abs(l.Y - b.Y)));
            }
            else if ((outcode & PUtil.OutCode.Bottom) != 0)
            {
                delta.Height = ValidatePanningDelta(1.0f + (0.5f * Math.Abs(l.Y - (b.Y + b.Height))));
            }

            if ((outcode & PUtil.OutCode.Right) != 0)
            {
                delta.Width = ValidatePanningDelta(1.0f + (0.5f * Math.Abs(l.X - (b.X + b.Width))));
            }
            else if ((outcode & PUtil.OutCode.Left) != 0)
            {
                delta.Width = ValidatePanningDelta(-1.0f - (0.5f * Math.Abs(l.X - b.X)));
            }

            delta = c.LocalToView(delta);

            if (delta.Width != 0 || delta.Height != 0)
            {
                c.TranslateViewBy(delta.Width, delta.Height);
            }
        }
All Usage Examples Of UMD.HCIL.Piccolo.Event.PInputEventArgs::GetPositionRelativeTo