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/AlignCentersHorizontallyTool.cs @ 2868

Last change on this file since 2868 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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