using System.Windows.Forms;
namespace Netron.Diagramming.Core {
///
/// This tool informs the IController to display a ContextMenu when
/// the right mouse button is clicked once.
///
public class ContextTool : AbstractTool, IMouseListener {
#region Fields
#endregion
#region Constructor
// ------------------------------------------------------------------
///
/// Initializes a new instance of the class.
///
/// The name of the tool.
// ------------------------------------------------------------------
public ContextTool(string name)
: base(name) {
}
#endregion
#region Methods
// ------------------------------------------------------------------
///
/// Called when the tool is activated.
///
// ------------------------------------------------------------------
protected override void OnActivateTool() {
}
// ------------------------------------------------------------------
///
/// Handles the mouse down event.
///
/// The
/// instance
/// containing the event data.
/// Returns 'true' if the event was handled, otherwise
/// 'false'.
// ------------------------------------------------------------------
public bool MouseDown(MouseEventArgs e) {
if (!IsSuspended && this.Enabled) {
if (e.Button == MouseButtons.Right && e.Clicks == 1) {
// Just the base menu for now.
ToolStripItem[] additionalItems = null;
this.Controller.RaiseOnShowContextMenu(
new EntityMenuEventArgs(null, e, ref additionalItems));
return true;
}
}
return false;
}
// ------------------------------------------------------------------
///
/// Handles the mouse move event - nothing is performed here.
///
/// The
/// instance
/// containing the event data.
// ------------------------------------------------------------------
public void MouseMove(MouseEventArgs e) {
}
// ------------------------------------------------------------------
///
/// Handles the mouse up event - nothing is performed here.
///
/// The
/// instance
/// containing the event data.
// ------------------------------------------------------------------
public void MouseUp(MouseEventArgs e) {
}
#endregion
}
}