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/GroupTool.cs @ 2868

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

finished mapping from OperatorGraph to GraphVisualizationInfo (ticket #867)

File size: 2.6 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    /// Group tool
11    /// </summary>
12    class GroupTool : AbstractTool, IMouseListener
13    {
14
15        #region Fields
16     
17        #endregion
18
19        #region Constructor
20        /// <summary>
21        /// Initializes a new instance of the <see cref="T:GroupTool"/> class.
22        /// </summary>
23        /// <param name="name">The name of the tool.</param>
24        public GroupTool(string name)
25            : base(name)
26        {
27        }
28        #endregion
29
30        #region Methods
31
32        /// <summary>
33        /// Called when the tool is activated.
34        /// </summary>
35        protected override void OnActivateTool()
36        {
37            bool valid = true;
38            //make sure we have the correct stuff on the table
39            if (this.Controller.Model.Selection.SelectedItems == null || this.Controller.Model.Selection.SelectedItems.Count == 0)
40            {
41                MessageBox.Show("Nothing is selected, you need to select at least two items to create a group.", "Nothing selected.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
42                valid = false;
43            } else if (this.Controller.Model.Selection.SelectedItems.Count <= 1)
44            {
45                MessageBox.Show("You need at least two items to create a group.", "Multiple items.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
46                valid = false;
47            }
48            if (valid)
49            {
50              Bundle bundle = new Bundle(this.Controller.Model.Selection.SelectedItems);
51
52                GroupCommand cmd = new GroupCommand(this.Controller, bundle);
53
54                this.Controller.UndoManager.AddUndoCommand(cmd);
55
56                cmd.Redo();
57            }
58            DeactivateTool();
59            return;
60        }
61
62        /// <summary>
63        /// Handles the mouse down event
64        /// </summary>
65        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
66        public bool MouseDown(MouseEventArgs e)
67        {
68            return false;
69        }
70
71        /// <summary>
72        /// Handles the mouse move event
73        /// </summary>
74        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
75        public void MouseMove(MouseEventArgs e)
76        {
77
78        }
79        public void MouseUp(MouseEventArgs e)
80        {
81
82        }
83        #endregion
84
85
86    }
87
88}
Note: See TracBrowser for help on using the repository browser.