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/AlignCentersVerticallyTool.cs @ 11072

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

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

File size: 1.6 KB
Line 
1using System.Drawing;
2
3namespace Netron.Diagramming.Core {
4  // ----------------------------------------------------------------------
5  /// <summary>
6  /// Aligns the center of the selected entities vertically.
7  /// </summary>
8  // ----------------------------------------------------------------------
9  public class AlignCentersVerticallyTool : AlignmentToolBase {
10    // ------------------------------------------------------------------
11    /// <summary>
12    /// Constructor.
13    /// </summary>
14    /// <param name="toolName">string: The name of this tool</param>
15    // ------------------------------------------------------------------
16    public AlignCentersVerticallyTool(string toolName)
17      : base(toolName) {
18    }
19
20    // ------------------------------------------------------------------
21    /// <summary>
22    /// Aligns the center of all selected entities vertically.  The
23    /// 'Y' component of the center location of the first entity in the
24    /// selection is used for all other entities.
25    /// </summary>
26    // ------------------------------------------------------------------
27    public override void Align(IDiagramEntity[] entities) {
28      // The amount to offset the entities by.
29      Point offset;
30
31      for (int i = 1; i < entities.Length; i++) {
32        IDiagramEntity entity = entities[i];
33
34        // Keep the entities same x location but offset it's
35        // y location.
36        offset = new Point(
37            0,
38            this.centerOfFirstEntity.Y - entity.Center.Y);
39
40        // Move the entity by this amount.
41        entity.MoveBy(offset);
42      }
43    }
44  }
45}
Note: See TracBrowser for help on using the repository browser.