[2768] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Text;
|
---|
| 4 | using System.Collections;
|
---|
| 5 | using System.Drawing;
|
---|
| 6 | using System.Windows.Forms;
|
---|
| 7 |
|
---|
| 8 | namespace Netron.Diagramming.Core
|
---|
| 9 | {
|
---|
| 10 | // ----------------------------------------------------------------------
|
---|
| 11 | /// <summary>
|
---|
| 12 | /// Aligns the bottom edges of the selected entities.
|
---|
| 13 | /// </summary>
|
---|
| 14 | // ----------------------------------------------------------------------
|
---|
| 15 | public class AlignBottomEdgesTool : AlignmentToolBase
|
---|
| 16 | {
|
---|
| 17 | // ------------------------------------------------------------------
|
---|
| 18 | /// <summary>
|
---|
| 19 | /// Constructor.
|
---|
| 20 | /// </summary>
|
---|
| 21 | /// <param name="toolName">string: The name of this tool</param>
|
---|
| 22 | // ------------------------------------------------------------------
|
---|
| 23 | public AlignBottomEdgesTool(string toolName)
|
---|
| 24 | : base(toolName)
|
---|
| 25 | {
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | // ------------------------------------------------------------------
|
---|
| 29 | /// <summary>
|
---|
| 30 | /// Aligns the bottom edges of all selected entities. The vertical
|
---|
| 31 | /// location of the first entity in the selection is used for all
|
---|
| 32 | /// other entities vertical location.
|
---|
| 33 | /// </summary>
|
---|
| 34 | // ------------------------------------------------------------------
|
---|
| 35 | public override void Align(IDiagramEntity[] entities)
|
---|
| 36 | {
|
---|
| 37 | // We want to align the bottom edges, so we need to set the
|
---|
| 38 | // vertical location of each shape to one value. We're
|
---|
| 39 | // going use the first entity in the selection to determine
|
---|
| 40 | // this setting.
|
---|
| 41 | Point offset;
|
---|
| 42 |
|
---|
| 43 | for (int i = 1; i < entities.Length; i++)
|
---|
| 44 | {
|
---|
| 45 | IDiagramEntity entity = entities[i];
|
---|
| 46 |
|
---|
| 47 | // Keep the entities same y location but offset it's
|
---|
| 48 | // x location.
|
---|
| 49 | offset = new Point(
|
---|
| 50 | 0,
|
---|
| 51 | this.bottomEdgeOfFirstEntity - entity.Rectangle.Bottom);
|
---|
| 52 |
|
---|
| 53 | // Move the entity by this amount.
|
---|
| 54 | entity.MoveBy(offset);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | }
|
---|