Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/ContextTool.cs @ 16462

Last change on this file since 16462 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.9 KB
Line 
1using System.Windows.Forms;
2
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// This tool informs the IController to display a ContextMenu when
6  /// the right mouse button is clicked once.
7  /// </summary>
8  public class ContextTool : AbstractTool, IMouseListener {
9
10    #region Fields
11
12    #endregion
13
14    #region Constructor
15
16    // ------------------------------------------------------------------
17    /// <summary>
18    /// Initializes a new instance of the <see cref="T:HoverTool"/> class.
19    /// </summary>
20    /// <param name="name">The name of the tool.</param>
21    // ------------------------------------------------------------------
22    public ContextTool(string name)
23      : base(name) {
24    }
25
26    #endregion
27
28    #region Methods
29
30    // ------------------------------------------------------------------
31    /// <summary>
32    /// Called when the tool is activated.
33    /// </summary>
34    // ------------------------------------------------------------------
35    protected override void OnActivateTool() {
36    }
37
38    // ------------------------------------------------------------------
39    /// <summary>
40    /// Handles the mouse down event.
41    /// </summary>
42    /// <param name="e">The
43    /// <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance
44    /// containing the event data.</param>
45    /// <returns>Returns 'true' if the event was handled, otherwise
46    /// 'false'.</returns>
47    // ------------------------------------------------------------------
48    public bool MouseDown(MouseEventArgs e) {
49      if (!IsSuspended && this.Enabled) {
50        if (e.Button == MouseButtons.Right && e.Clicks == 1) {
51          // Just the base menu for now.
52          ToolStripItem[] additionalItems = null;
53
54          this.Controller.RaiseOnShowContextMenu(
55              new EntityMenuEventArgs(null, e, ref additionalItems));
56          return true;
57        }
58      }
59      return false;
60    }
61
62    // ------------------------------------------------------------------
63    /// <summary>
64    /// Handles the mouse move event - nothing is performed here.
65    /// </summary>
66    /// <param name="e">The
67    /// <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance
68    /// containing the event data.</param>
69    // ------------------------------------------------------------------
70    public void MouseMove(MouseEventArgs e) {
71    }
72
73    // ------------------------------------------------------------------
74    /// <summary>
75    /// Handles the mouse up event - nothing is performed here.
76    /// </summary>
77    /// <param name="e">The
78    /// <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance
79    /// containing the event data.</param>
80    // ------------------------------------------------------------------
81    public void MouseUp(MouseEventArgs e) {
82    }
83
84    #endregion
85  }
86
87}
Note: See TracBrowser for help on using the repository browser.