using System.Collections; using System.Collections.Generic; namespace Netron.Diagramming.Core { /// /// Group tool /// class SendToBackTool : AbstractTool { #region Fields #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The name of the tool. public SendToBackTool(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 inverse 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 = list.Count - 1; k >= 0; k--) { this.Controller.Model.SendToBack(list.Values[k]); } } DeactivateTool(); } #endregion } }