using System.Collections; using System.Collections.Generic; namespace Netron.Diagramming.Core { /// /// Group tool /// class SendToFrontTool : AbstractTool { #region Fields #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The name of the tool. public SendToFrontTool(string name) : base(name) { } #endregion #region Methods /// /// Called when the tool is activated. /// protected override void OnActivateTool() { if (this.Controller.Model.Selection.SelectedItems != null && this.Controller.Model.Selection.SelectedItems.Count > 0) { #region Preparation of the ordering //the items have to be moved in the order of the Paintables //Usually this is a good moment to make a little drawing or example //to see how things function. SortedList list = new SortedList(); foreach (IDiagramEntity entity in this.Controller.Model.Selection.FlattenedSelectionItems) { //the addition will automatically put the item in increasing order list.Add(this.Controller.Model.Paintables.IndexOf(entity), entity); } #endregion //send them backwards for (int k = 0; k < list.Count; k++) { this.Controller.Model.SendToFront(list.Values[k]); } } DeactivateTool(); } #endregion } }