/// <summary>
        /// Gets the mouse lightweight control that is located at the specified client point.
        /// </summary>
        /// <param name="point">A point that contains the coordinates where you want to look for a
        /// control. Coordinates are expressed relative to the upper-left corner of the control's
        /// client area.</param>
        /// <returns>The BehaviorControl at the specified client point.  If there is no
        /// BehaviorControl at the specified client point, the GetMouseBehaviorControlAtClientPoint
        /// method returns a null reference.</returns>
        private BehaviorControl GetMouseBehaviorControlAtClientPoint(Point point)
        {
            //	Map the client point to a virtual client point.
            point = ClientPointToVirtualClientPoint(point);

            //	Enumerate the lightweight controls, in Z order, to locate one at the virtual point.
            for (int index = Controls.Count - 1; index >= 0; index--)
            {
                //	Access the lightweight control.
                BehaviorControl BehaviorControl = Controls[index];

                //	If the lightweight control is visible, and the virtual client point is inside
                //	it, translate the virtual client point to be relative to the location of the
                //	lightweight control and recursively ask the lightweight control to return the
                //	lightweight control at the virtual client point.  This will find the innermost
                //	lightweight control, at the top of the Z order, that contains the virual client
                //	point.
                if (BehaviorControl.Visible && BehaviorControl.VirtualBounds.Contains(point))
                {
                    //	Translate the virtual point to be relative to the location of the lightweight control.
                    point.Offset(BehaviorControl.VirtualLocation.X * -1, BehaviorControl.VirtualLocation.Y * -1);

                    //	Recursively get the mouse lightweight control at the translated point.
                    return(BehaviorControl.GetBehaviorControlAtPoint(point));
                }
            }

            //	The client point is not inside any lightweight control.
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Gets the Behavior control that is located at the specified point.
        /// </summary>
        /// <param name="point">A Point that contains the coordinates where you want to look for a control.
        ///	Coordinates are expressed relative to the upper-left corner of the control's client area.</param>
        /// <returns>Behavior control at the specified point.</returns>
        internal BehaviorControl GetBehaviorControlAtPoint(Point point)
        {
            //	Enumerate the Behavior controls, in Z order, to locate one at the virtual point.
            for (int index = Controls.Count - 1; index >= 0; index--)
            {
                //	Access the Behavior control.
                BehaviorControl BehaviorControl = Controls[index];

                //	If the Behavior control is visible, and the point is within its virtual
                //	bounds, then recursively search for the right control.
                if (BehaviorControl.Visible && BehaviorControl.VirtualBounds.Contains(point))
                {
                    //	Translate the point to be relative to the location of the Behavior control.
                    point.Offset(BehaviorControl.VirtualLocation.X * -1, BehaviorControl.VirtualLocation.Y * -1);

                    //	Recursively search for the right Behavior control.
                    return(BehaviorControl.GetBehaviorControlAtPoint(point));
                }
            }

            //	The point is not inside a child Behavior control of this Behavior control,
            //	so it's inside this Behavior control.
            return(this);
        }