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/UngroupTool.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.4 KB
Line 
1using System.Windows.Forms;
2
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// Group tool
6  /// </summary>
7  class UngroupTool : AbstractTool, IMouseListener {
8
9    #region Fields
10
11    #endregion
12
13    #region Constructor
14    /// <summary>
15    /// Initializes a new instance of the <see cref="T:UngroupTool"/> class.
16    /// </summary>
17    /// <param name="name">The name of the tool.</param>
18    public UngroupTool(string name)
19      : base(name) {
20    }
21    #endregion
22
23    #region Methods
24
25    /// <summary>
26    /// Called when the tool is activated.
27    /// </summary>
28    protected override void OnActivateTool() {
29      bool valid = true;
30
31      #region Validation of the selection
32
33      //make sure we have the correct stuff on the table
34      if (this.Controller.Model.Selection.SelectedItems == null || this.Controller.Model.Selection.SelectedItems.Count == 0) {
35        MessageBox.Show("Nothing is selected, you need to select an existing group.", "Nothing selected.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
36        valid = false;
37      } else if (this.Controller.Model.Selection.SelectedItems.Count != 1) {
38        MessageBox.Show("Multiple items are selected, select only one group.", "Multiple items", MessageBoxButtons.OK, MessageBoxIcon.Hand);
39        valid = false;
40      } else if (!(this.Controller.Model.Selection.SelectedItems[0] is IGroup)) {
41        MessageBox.Show("The selected item is not a group.", "Not a group.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
42        valid = false;
43      }
44      #endregion
45
46      if (valid) {
47        UngroupCommand cmd = new UngroupCommand(this.Controller, this.Controller.Model.Selection.SelectedItems[0] as IGroup);
48        this.Controller.UndoManager.AddUndoCommand(cmd);
49        cmd.Redo();
50      }
51      DeactivateTool();
52      return;
53    }
54
55    /// <summary>
56    /// Handles the mouse down event
57    /// </summary>
58    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
59    public bool MouseDown(MouseEventArgs e) {
60      return false;
61    }
62
63    /// <summary>
64    /// Handles the mouse move event
65    /// </summary>
66    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
67    public void MouseMove(MouseEventArgs e) {
68
69    }
70    public void MouseUp(MouseEventArgs e) {
71
72    }
73    #endregion
74
75
76  }
77
78}
Note: See TracBrowser for help on using the repository browser.