using System.Drawing; namespace Netron.Diagramming.Core { // ---------------------------------------------------------------------- /// /// Aligns the bottom edges of the selected entities. /// // ---------------------------------------------------------------------- public class AlignBottomEdgesTool : AlignmentToolBase { // ------------------------------------------------------------------ /// /// Constructor. /// /// string: The name of this tool // ------------------------------------------------------------------ public AlignBottomEdgesTool(string toolName) : base(toolName) { } // ------------------------------------------------------------------ /// /// Aligns the bottom edges of all selected entities. The vertical /// location of the first entity in the selection is used for all /// other entities vertical location. /// // ------------------------------------------------------------------ public override void Align(IDiagramEntity[] entities) { // We want to align the bottom edges, so we need to set the // vertical location of each shape to one value. We're // going use the first entity in the selection to determine // this setting. Point offset; for (int i = 1; i < entities.Length; i++) { IDiagramEntity entity = entities[i]; // Keep the entities same y location but offset it's // x location. offset = new Point( 0, this.bottomEdgeOfFirstEntity - entity.Rectangle.Bottom); // Move the entity by this amount. entity.MoveBy(offset); } } } }