implement
This commit is contained in:
13
dotnet/AipsCore/Domain/Models/Shape/Shape.Move.cs
Normal file
13
dotnet/AipsCore/Domain/Models/Shape/Shape.Move.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape;
|
||||
|
||||
public partial class Shape
|
||||
{
|
||||
public virtual void Move(int newPositionX, int newPositionY)
|
||||
{
|
||||
var newPosition = new Position(newPositionX, newPositionY);
|
||||
|
||||
this.Position = newPosition;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape;
|
||||
|
||||
public abstract class Shape : DomainModel<ShapeId>
|
||||
public abstract partial class Shape : DomainModel<ShapeId>
|
||||
{
|
||||
public WhiteboardId WhiteboardId { get; private set; }
|
||||
|
||||
|
||||
11
dotnet/AipsCore/Domain/Models/Shape/Sub/Arrow/Arrow.Move.cs
Normal file
11
dotnet/AipsCore/Domain/Models/Shape/Sub/Arrow/Arrow.Move.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Arrow;
|
||||
|
||||
public partial class Arrow
|
||||
{
|
||||
public override void Move(int newPositionX, int newPositionY)
|
||||
{
|
||||
EndPosition.X += newPositionX - Position.X;
|
||||
EndPosition.Y += newPositionY - Position.Y;
|
||||
base.Move(newPositionX, newPositionY);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Arrow;
|
||||
|
||||
public class Arrow : Shape
|
||||
public partial class Arrow : Shape
|
||||
{
|
||||
public Position EndPosition { get; private set; }
|
||||
public Thickness Thickness { get; private set; }
|
||||
|
||||
11
dotnet/AipsCore/Domain/Models/Shape/Sub/Line/Line.Move.cs
Normal file
11
dotnet/AipsCore/Domain/Models/Shape/Sub/Line/Line.Move.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Line;
|
||||
|
||||
public partial class Line
|
||||
{
|
||||
public override void Move(int newPositionX, int newPositionY)
|
||||
{
|
||||
EndPosition.X += newPositionX - Position.X;
|
||||
EndPosition.Y += newPositionY - Position.Y;
|
||||
base.Move(newPositionX, newPositionY);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Line;
|
||||
|
||||
public class Line : Shape
|
||||
public partial class Line : Shape
|
||||
{
|
||||
public Position EndPosition { get; private set; }
|
||||
public Thickness Thickness { get; private set; }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Rectangle;
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public override void Move(int newPositionX, int newPositionY)
|
||||
{
|
||||
EndPosition.X += newPositionX - Position.X;
|
||||
EndPosition.Y += newPositionY - Position.Y;
|
||||
base.Move(newPositionX, newPositionY);
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,11 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Rectangle;
|
||||
|
||||
public class Rectangle : Shape
|
||||
public partial class Rectangle : Shape
|
||||
{
|
||||
public override ShapeType ShapeType => ShapeType.Rectangle;
|
||||
|
||||
public Position EndPosition { get; }
|
||||
public Position EndPosition { get; set; }
|
||||
|
||||
public Thickness BorderThickness { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using AipsCore.Domain.Abstract.Validation;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Validation;
|
||||
|
||||
public class ShapeErrors : AbstractErrors<Shape, ShapeId>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
public record Position : AbstractValueObject
|
||||
{
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
|
||||
public Position(int x, int y)
|
||||
{
|
||||
@@ -20,4 +20,14 @@ public record Position : AbstractValueObject
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static Position operator -(Position position, Position otherPosition)
|
||||
{
|
||||
return new Position(position.X - otherPosition.X, position.Y - otherPosition.Y);
|
||||
}
|
||||
|
||||
public static Position operator +(Position position, Position otherPosition)
|
||||
{
|
||||
return new Position(position.X + otherPosition.X, position.Y + otherPosition.Y);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user