Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/AlignCentersHorizontallyTool.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/AlignCentersHorizontallyTool.cs
r2768 r4068 1 using System;2 using System.Collections.Generic;3 using System.Text;4 using System.Collections;5 1 using System.Drawing; 6 using System.Windows.Forms;7 2 8 namespace Netron.Diagramming.Core 9 { 10 // ---------------------------------------------------------------------- 3 namespace Netron.Diagramming.Core { 4 // ---------------------------------------------------------------------- 5 /// <summary> 6 /// Aligns the center of the selected entities horizontally. 7 /// </summary> 8 // ---------------------------------------------------------------------- 9 public class AlignCentersHorizontallyTool : AlignmentToolBase { 10 // ------------------------------------------------------------------ 11 11 /// <summary> 12 /// Aligns the center of the selected entities horizontally.12 /// Constructor. 13 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 } 14 /// <param name="toolName">string: The name of this tool</param> 15 // ------------------------------------------------------------------ 16 public AlignCentersHorizontallyTool(string toolName) 17 : base(toolName) { 18 } 27 19 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; 20 // ------------------------------------------------------------------ 21 /// <summary> 22 /// Aligns the center of all selected entities horizontally. The 23 /// 'X' 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; 39 30 40 for (int i = 1; i < entities.Length; i++) 41 { 42 IDiagramEntity entity = entities[i]; 31 for (int i = 1; i < entities.Length; i++) { 32 IDiagramEntity entity = entities[i]; 43 33 44 45 46 47 48 34 // Keep the entities same y location but offset it's 35 // x location. 36 offset = new Point( 37 this.centerOfFirstEntity.X - entity.Center.X, 38 0); 49 39 50 // Move the entity by this amount. 51 entity.MoveBy(offset); 52 } 53 } 40 // Move the entity by this amount. 41 entity.MoveBy(offset); 42 } 54 43 } 44 } 55 45 }
Note: See TracChangeset
for help on using the changeset viewer.