// ------------------------------------------------------------------ /// <summary> /// Aligns the center of all selected entities vertically. The /// 'Y' component of the center location of the first entity in the /// selection is used for all other entities. /// </summary> // ------------------------------------------------------------------ public override void Align(IDiagramEntity[] entities) { // The amount to offset the entities by. Point offset; for (int i = 1; i < entities.Length; i++) { IDiagramEntity entity = entities[i]; // Keep the entities same x location but offset it's // y location. offset = new Point( 0, this.centerOfFirstEntity.Y - entity.Center.Y); // Move the entity by this amount. entity.MoveBy(offset); } }
// ------------------------------------------------------------------ /// <summary> /// 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. /// </summary> // ------------------------------------------------------------------ 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); } }