Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/AlignBottomEdgesTool.cs @ 12328

Last change on this file since 12328 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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