Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/AlignRightEdgesTool.cs @ 4068

Last change on this file since 4068 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 right edges of the selected entities.
7  /// </summary>
8  // ----------------------------------------------------------------------
9  public class AlignRightEdgesTool : AlignmentToolBase {
10    // ------------------------------------------------------------------
11    /// <summary>
12    /// Constructor.
13    /// </summary>
14    /// <param name="toolName">string: The name of this tool</param>
15    // ------------------------------------------------------------------
16    public AlignRightEdgesTool(string toolName)
17      : base(toolName) {
18    }
19
20    // ------------------------------------------------------------------
21    /// <summary>
22    /// Aligns the right edges of all selected entities.  The horizontal
23    /// location of the first entity in the selection is used for all
24    /// other entities horizontal location.
25    /// </summary>
26    // ------------------------------------------------------------------
27    public override void Align(IDiagramEntity[] entities) {
28      // We want to align the left edges, so we need to set the
29      // horizontal 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            this.rightEdgeOfFirstEntity - entity.Rectangle.Right,
41            0);
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.