1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Collections;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Windows.Forms;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|