OnMouseDown
(
MouseButtonEventArgs e
)
{
AssertValid();
// Do nothing if the drawing isn't in a stable state.
if (this.IsLayingOutGraph)
{
return;
}
// Remove any vertex tooltip that might exist and reset the helper
// object that figures out when to show tooltips.
ResetVertexToolTipTracker();
if ( DragMightBeInProgress() )
{
// This can occur if the user clicks another button while dragging
// with the left button.
return;
}
// Check whether the user clicked on a vertex.
Point oMouseLocation = e.GetPosition(this);
IVertex oClickedVertex;
Boolean bVertexClicked =
TryGetVertexFromPoint(oMouseLocation, out oClickedVertex);
FireGraphMouseDown(e, oClickedVertex);
if (bVertexClicked)
{
FireVertexClick(oClickedVertex);
if (e.ClickCount == 2)
{
FireVertexDoubleClick(oClickedVertex);
}
}
// Some drag operations can be cancelled with the Escape key, so
// capture keyboard focus.
Keyboard.Focus(this);
if (m_eMouseMode == MouseMode.DoNothing)
{
return;
}
switch (e.ChangedButton)
{
case MouseButton.Left:
OnMouseDownLeft(e, oMouseLocation, oClickedVertex);
break;
case MouseButton.Middle:
OnMouseDownMiddle(oMouseLocation);
break;
case MouseButton.Right:
OnMouseDownRight(oMouseLocation, oClickedVertex);
break;
default:
break;
}
}