public virtual void MouseUp(Control c, Point pt, MouseButtons button)
{
if (_captured)
{
// Not capturing mouse input anymore
_captured = false;
// Only interested in left mouse being released
if (button == MouseButtons.Left)
{
// Only if the button is still pressed, do we generate a click
if (_targetImage.Pressed)
{
// Move back to hot tracking state, we have to do this
// before the click is generated because the click processing
// might change focus and so cause the MouseLeave to be
// called and change the state. If this was after the click
// then it would overwrite and lose that leave state change.
_targetImage.Pressed = false;
_targetImage.Tracking = true;
// Can only click if enabled
if (_targetImage.Enabled)
OnClick(new MouseEventArgs(MouseButtons.Left, 1, pt.X, pt.Y, 0));
}
// Repaint to reflect new state
OnNeedPaint(false);
}
else
{
// Update the visual state
UpdateTargetState(pt);
}
}
// If user is releasing the right mouse button
if (button == MouseButtons.Right)
{
// And it was pressed over the tab
if (_rightButtonDown)
{
_rightButtonDown = false;
// Raises event so a context menu for the ribbon can be shown
OnContextClick(new MouseEventArgs(MouseButtons.Right, 1, pt.X, pt.Y, 0));
}
}
}