/// <summary> /// Raises the MouseDown event. /// </summary> /// <param name="e">A MouseEventArgs that contains the event data.</param> protected override void OnMouseDown(MouseEventArgs e) { // Cannot process a message for a disposed control if (!IsDisposed && !Disposing && !RootInstance.IsDisposed) { // Do we have a manager for processing mouse messages? if (GetViewManager() != null) { // Convert from control to parent control coordinates Point rootPoint = RootInstance.PointToClient(PointToScreen(new Point(e.X, e.Y))); // Use the root controls view manager to process the event GetViewManager().MouseDown(new MouseEventArgs(e.Button, e.Clicks, rootPoint.X, rootPoint.Y, e.Delta), new Point(e.X, e.Y)); } // If the root control does not have focus, then give it the focus now if (!RootInstance.ContainsFocus && RootInstance.CanSelect) { // Do not change focus at design time because if (!InDesignMode) { RootInstance.Focus(); } } } // Let base class fire events base.OnMouseDown(e); }
/// <summary> /// Raises the MouseUp event. /// </summary> /// <param name="e">A MouseEventArgs that contains the event data.</param> protected override void OnMouseUp(MouseEventArgs e) { // Cannot process a message for a disposed control if (!IsDisposed && !Disposing && !RootInstance.IsDisposed) { // Do we have a manager for processing mouse messages? if (GetViewManager() != null) { // Convert from control to parent control coordinates Point rootPoint = RootInstance.PointToClient(PointToScreen(new Point(e.X, e.Y))); // Use the root controls view manager to process the event GetViewManager().MouseUp(new MouseEventArgs(e.Button, e.Clicks, rootPoint.X, rootPoint.Y, e.Delta), new Point(e.X, e.Y)); } } // Let base class fire events base.OnMouseUp(e); }