using System.Windows.Forms; namespace Netron.Diagramming.Core { /// /// Group tool /// class UngroupTool : AbstractTool, IMouseListener { #region Fields #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The name of the tool. public UngroupTool(string name) : base(name) { } #endregion #region Methods /// /// Called when the tool is activated. /// protected override void OnActivateTool() { bool valid = true; #region Validation of the selection //make sure we have the correct stuff on the table if (this.Controller.Model.Selection.SelectedItems == null || this.Controller.Model.Selection.SelectedItems.Count == 0) { MessageBox.Show("Nothing is selected, you need to select an existing group.", "Nothing selected.", MessageBoxButtons.OK, MessageBoxIcon.Hand); valid = false; } else if (this.Controller.Model.Selection.SelectedItems.Count != 1) { MessageBox.Show("Multiple items are selected, select only one group.", "Multiple items", MessageBoxButtons.OK, MessageBoxIcon.Hand); valid = false; } else if (!(this.Controller.Model.Selection.SelectedItems[0] is IGroup)) { MessageBox.Show("The selected item is not a group.", "Not a group.", MessageBoxButtons.OK, MessageBoxIcon.Hand); valid = false; } #endregion if (valid) { UngroupCommand cmd = new UngroupCommand(this.Controller, this.Controller.Model.Selection.SelectedItems[0] as IGroup); this.Controller.UndoManager.AddUndoCommand(cmd); cmd.Redo(); } DeactivateTool(); return; } /// /// Handles the mouse down event /// /// The instance containing the event data. public bool MouseDown(MouseEventArgs e) { return false; } /// /// Handles the mouse move event /// /// The instance containing the event data. public void MouseMove(MouseEventArgs e) { } public void MouseUp(MouseEventArgs e) { } #endregion } }