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/AlignBottomEdgesTool.cs @ 2768

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

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

File size: 2.1 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 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}
Note: See TracBrowser for help on using the repository browser.