Skip to content

Commit

Permalink
Merge pull request #43 from ogamespec/main
Browse files Browse the repository at this point in the history
FlipCell
  • Loading branch information
ogamespec authored Apr 26, 2023
2 parents c4be463 + b1ec237 commit 8f82290
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Deroute/CellSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,45 @@ public static void RotateCell (EntityBox box)
public static void FlipCell (EntityBox box)
{
Console.WriteLine("flip");

List<Entity> entities = box.GetEntities();

foreach (var entity in entities)
{
if ((entity.IsCell() || entity.IsUnit()) && entity.Selected)
{
var ports = GetPorts(entity, entities);

switch (entity.LabelAlignment)
{
case TextAlignment.TopLeft:
case TextAlignment.GlobalSettings:
entity.LabelAlignment = TextAlignment.TopRight;
break;

case TextAlignment.TopRight:
entity.LabelAlignment = TextAlignment.TopLeft;
break;

case TextAlignment.BottomRight:
entity.LabelAlignment = TextAlignment.BottomLeft;
break;

case TextAlignment.BottomLeft:
entity.LabelAlignment = TextAlignment.BottomRight;
break;
}

foreach (var port in ports)
{
var midp = entity.LambdaX + entity.LambdaWidth / 2;
var ofs_x = midp - port.LambdaX;
port.LambdaX = midp + ofs_x;
}
}
}

box.Invalidate();
}

public static List<Cell> DeserializeFromFile (string FileName)
Expand Down

0 comments on commit 8f82290

Please sign in to comment.