Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/ContextTool.cs @ 2868

Last change on this file since 2868 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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