using System.Windows.Forms; namespace Netron.Diagramming.Core { /// /// Group tool /// class GroupTool : AbstractTool, IMouseListener { #region Fields #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The name of the tool. public GroupTool(string name) : base(name) { } #endregion #region Methods /// /// Called when the tool is activated. /// protected override void OnActivateTool() { bool valid = true; //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 at least two items to create a group.", "Nothing selected.", MessageBoxButtons.OK, MessageBoxIcon.Hand); valid = false; } else if (this.Controller.Model.Selection.SelectedItems.Count <= 1) { MessageBox.Show("You need at least two items to create a group.", "Multiple items.", MessageBoxButtons.OK, MessageBoxIcon.Hand); valid = false; } if (valid) { Bundle bundle = new Bundle(this.Controller.Model.Selection.SelectedItems); GroupCommand cmd = new GroupCommand(this.Controller, bundle); 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 } }