Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/ContextTool.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/ContextTool.cs
r2768 r4068 1 using System;2 using System.Diagnostics;3 using System.Collections;4 using System.Drawing;5 1 using System.Windows.Forms; 6 2 7 namespace Netron.Diagramming.Core 8 { 3 namespace 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 // ------------------------------------------------------------------ 9 17 /// <summary> 10 /// This tool informs the IController to display a ContextMenu when 11 /// the right mouse button is clicked once. 18 /// Initializes a new instance of the <see cref="T:HoverTool"/> class. 12 19 /// </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 20 /// <param name="name">The name of the tool.</param> 21 // ------------------------------------------------------------------ 22 public ContextTool(string name) 23 : base(name) { 98 24 } 99 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 100 87 }
Note: See TracChangeset
for help on using the changeset viewer.