public virtual void MouseUp(Control c, Point pt, MouseButtons button)
{
// If the mouse is currently captured
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 (_target.ElementState == PaletteState.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.
_target.ElementState = PaletteState.Tracking;
// Can only click if enabled
if (_target.Enabled)
{
// Generate a click event
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);
}
}
}