Last change
on this file since 16462 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 | |
---|
1 | using System.Drawing;
|
---|
2 |
|
---|
3 | namespace Netron.Diagramming.Core {
|
---|
4 | // ----------------------------------------------------------------------
|
---|
5 | /// <summary>
|
---|
6 | /// Aligns the top edges of the selected entities.
|
---|
7 | /// </summary>
|
---|
8 | // ----------------------------------------------------------------------
|
---|
9 | public class AlignTopEdgesTool : AlignmentToolBase {
|
---|
10 | // ------------------------------------------------------------------
|
---|
11 | /// <summary>
|
---|
12 | /// Constructor.
|
---|
13 | /// </summary>
|
---|
14 | /// <param name="toolName">string: The name of this tool</param>
|
---|
15 | // ------------------------------------------------------------------
|
---|
16 | public AlignTopEdgesTool(string toolName)
|
---|
17 | : base(toolName) {
|
---|
18 | }
|
---|
19 |
|
---|
20 | // ------------------------------------------------------------------
|
---|
21 | /// <summary>
|
---|
22 | /// Aligns the top 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 top 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.topEdgeOfFirstEntity - entity.Rectangle.Top);
|
---|
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.