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 UngroupTool : 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:UngroupTool"/> class.
|
---|
22 | /// </summary>
|
---|
23 | /// <param name="name">The name of the tool.</param>
|
---|
24 | public UngroupTool(string name) : base(name)
|
---|
25 | {
|
---|
26 | }
|
---|
27 | #endregion
|
---|
28 |
|
---|
29 | #region Methods
|
---|
30 |
|
---|
31 | /// <summary>
|
---|
32 | /// Called when the tool is activated.
|
---|
33 | /// </summary>
|
---|
34 | protected override void OnActivateTool()
|
---|
35 | {
|
---|
36 | bool valid = true;
|
---|
37 |
|
---|
38 | #region Validation of the selection
|
---|
39 |
|
---|
40 | //make sure we have the correct stuff on the table
|
---|
41 | if (this.Controller.Model.Selection.SelectedItems == null || this.Controller.Model.Selection.SelectedItems.Count == 0)
|
---|
42 | {
|
---|
43 | MessageBox.Show("Nothing is selected, you need to select an existing group.", "Nothing selected.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
---|
44 | valid = false;
|
---|
45 | } else if (this.Controller.Model.Selection.SelectedItems.Count != 1)
|
---|
46 | {
|
---|
47 | MessageBox.Show("Multiple items are selected, select only one group.", "Multiple items", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
---|
48 | valid = false;
|
---|
49 | } else if (!(this.Controller.Model.Selection.SelectedItems[0] is IGroup))
|
---|
50 | {
|
---|
51 | MessageBox.Show("The selected item is not a group.", "Not a group.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
---|
52 | valid = false;
|
---|
53 | }
|
---|
54 | #endregion
|
---|
55 |
|
---|
56 | if (valid)
|
---|
57 | {
|
---|
58 | UngroupCommand cmd = new UngroupCommand(this.Controller, this.Controller.Model.Selection.SelectedItems[0] as IGroup);
|
---|
59 | this.Controller.UndoManager.AddUndoCommand(cmd);
|
---|
60 | cmd.Redo();
|
---|
61 | }
|
---|
62 | DeactivateTool();
|
---|
63 | return;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /// <summary>
|
---|
67 | /// Handles the mouse down event
|
---|
68 | /// </summary>
|
---|
69 | /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
|
---|
70 | public bool MouseDown(MouseEventArgs e)
|
---|
71 | {
|
---|
72 | return false;
|
---|
73 | }
|
---|
74 |
|
---|
75 | /// <summary>
|
---|
76 | /// Handles the mouse move event
|
---|
77 | /// </summary>
|
---|
78 | /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
|
---|
79 | public void MouseMove(MouseEventArgs e)
|
---|
80 | {
|
---|
81 |
|
---|
82 | }
|
---|
83 | public void MouseUp(MouseEventArgs e)
|
---|
84 | {
|
---|
85 |
|
---|
86 | }
|
---|
87 | #endregion
|
---|
88 |
|
---|
89 |
|
---|
90 | }
|
---|
91 |
|
---|
92 | }
|
---|