Skip to content

Commit

Permalink
Addressed new comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvarenga1 committed Feb 28, 2024
1 parent 3fb82b5 commit 53a39dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 43 deletions.
16 changes: 8 additions & 8 deletions src/Blazor.Diagrams.Core/Models/PortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,33 @@ public virtual bool CanAttachTo(ILinkable other)

void ILinkable.RemoveLink(BaseLinkModel link) => _links.Remove(link);

public virtual void SetPortPositionOnNodeSizeChanged(double deltaX, double deltaY)
public virtual void SetPortPositionOnNodeSizeChanged(double deltaWidth, double deltaHeight)
{
switch (Alignment)
{
case PortAlignment.Top:
Position = new Point(Position.X + deltaX / 2, Position.Y);
Position = new Point(Position.X + deltaWidth / 2, Position.Y);
break;
case PortAlignment.TopRight:
Position = new Point(Position.X + deltaX, Position.Y);
Position = new Point(Position.X + deltaWidth, Position.Y);
break;
case PortAlignment.TopLeft:
Position = new Point(Position.X, Position.Y);
break;
case PortAlignment.Right:
Position = new Point(Position.X + deltaX, Position.Y + deltaY / 2);
Position = new Point(Position.X + deltaWidth, Position.Y + deltaHeight / 2);
break;
case PortAlignment.Left:
Position = new Point(Position.X, Position.Y + deltaY / 2);
Position = new Point(Position.X, Position.Y + deltaHeight / 2);
break;
case PortAlignment.Bottom:
Position = new Point(Position.X + deltaX / 2, Position.Y + deltaY);
Position = new Point(Position.X + deltaWidth / 2, Position.Y + deltaHeight);
break;
case PortAlignment.BottomRight:
Position = new Point(Position.X + deltaX, Position.Y + deltaY);
Position = new Point(Position.X + deltaWidth, Position.Y + deltaHeight);
break;
case PortAlignment.BottomLeft:
Position = new Point(Position.X, Position.Y + deltaY);
Position = new Point(Position.X, Position.Y + deltaHeight);
break;
default:
Position = new Point(Position.X, Position.Y);
Expand Down
37 changes: 2 additions & 35 deletions tests/Blazor.Diagrams.Core.Tests/Models/PortModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,8 @@ public void SetPortPositionOnNodeSizeChangedCalculatesCorrectPosition(PortAlignm
port.SetPortPositionOnNodeSizeChanged(100, 100);

// Assert
switch (alignment)
{
case PortAlignment.Top:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.TopRight:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.TopLeft:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.Right:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.Left:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.Bottom:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.BottomRight:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
case PortAlignment.BottomLeft:
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
break;
}
Assert.Equal(expectedXPosition, port.Position.X);
Assert.Equal(expectedYPosition, port.Position.Y);
}
}
}

0 comments on commit 53a39dd

Please sign in to comment.