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 @ 2768

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

added solution folders and sources for the netron library (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 (Selection.SelectedItems == null || 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            }
44            else if (Selection.SelectedItems.Count <= 1)
45            {
46                MessageBox.Show("You need at least two items to create a group.", "Multiple items.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
47                valid = false;
48            }
49            if (valid)
50            {
51                Bundle bundle = new Bundle(Selection.SelectedItems);
52
53                GroupCommand cmd = new GroupCommand(this.Controller, bundle);
54
55                this.Controller.UndoManager.AddUndoCommand(cmd);
56
57                cmd.Redo();
58            }
59            DeactivateTool();
60            return;
61        }
62
63        /// <summary>
64        /// Handles the mouse down event
65        /// </summary>
66        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
67        public bool MouseDown(MouseEventArgs e)
68        {
69            return false;
70        }
71
72        /// <summary>
73        /// Handles the mouse move event
74        /// </summary>
75        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
76        public void MouseMove(MouseEventArgs e)
77        {
78
79        }
80        public void MouseUp(MouseEventArgs e)
81        {
82
83        }
84        #endregion
85
86
87    }
88
89}
Note: See TracBrowser for help on using the repository browser.