implement
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace AipsCore.Domain.Models.Shape.Enums;
|
||||
|
||||
public enum ShapeTypeEnum
|
||||
{
|
||||
Rectangle,
|
||||
Line,
|
||||
Arrow,
|
||||
Text
|
||||
}
|
||||
23
dotnet/AipsCore/Domain/Models/Shape/Shape.cs
Normal file
23
dotnet/AipsCore/Domain/Models/Shape/Shape.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Drawing;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape;
|
||||
|
||||
public abstract class Shape
|
||||
{
|
||||
public ShapeId Id { get; }
|
||||
|
||||
public abstract ShapeTypeEnum ShapeType { get; }
|
||||
|
||||
public Position Position { get; private set; }
|
||||
|
||||
public Color Color { get; private set; }
|
||||
|
||||
protected Shape(ShapeId id, Position position, Color color)
|
||||
{
|
||||
Id = id;
|
||||
Position = position;
|
||||
Color = color;
|
||||
}
|
||||
}
|
||||
19
dotnet/AipsCore/Domain/Models/Shape/Sub/Arrow/Arrow.cs
Normal file
19
dotnet/AipsCore/Domain/Models/Shape/Sub/Arrow/Arrow.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Drawing;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Arrow;
|
||||
|
||||
public class Arrow : Shape
|
||||
{
|
||||
public Position EndPosition { get; private set; }
|
||||
public Thickness Thickness { get; private set; }
|
||||
|
||||
public Arrow(ShapeId id, Position position, Color color, Position endPosition, Thickness thickness) : base(id, position, color)
|
||||
{
|
||||
EndPosition = endPosition;
|
||||
Thickness = thickness;
|
||||
}
|
||||
|
||||
public override ShapeTypeEnum ShapeType => ShapeTypeEnum.Arrow;
|
||||
}
|
||||
19
dotnet/AipsCore/Domain/Models/Shape/Sub/Line/Line.cs
Normal file
19
dotnet/AipsCore/Domain/Models/Shape/Sub/Line/Line.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Drawing;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Line;
|
||||
|
||||
public class Line : Shape
|
||||
{
|
||||
public Position EndPosition { get; private set; }
|
||||
public Thickness Thickness { get; private set; }
|
||||
|
||||
public Line(ShapeId id, Position position, Color color, Position endPosition, Thickness thickness) : base(id, position, color)
|
||||
{
|
||||
EndPosition = endPosition;
|
||||
Thickness = thickness;
|
||||
}
|
||||
|
||||
public override ShapeTypeEnum ShapeType => ShapeTypeEnum.Line;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Drawing;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.Rectangle;
|
||||
|
||||
public class Rectangle : Shape
|
||||
{
|
||||
public override ShapeTypeEnum ShapeType => ShapeTypeEnum.Rectangle;
|
||||
|
||||
public Position EndPosition { get; }
|
||||
|
||||
public Thickness BorderThickness { get; }
|
||||
|
||||
public Rectangle(ShapeId id, Position position, Color color, Position endPosition, Thickness borderThickness)
|
||||
: base(id, position, color)
|
||||
{
|
||||
EndPosition = endPosition;
|
||||
BorderThickness = borderThickness;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Drawing;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.Shape.Sub.TextShape.ValueObjects;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.TextShape;
|
||||
|
||||
public class TextShape : Shape
|
||||
{
|
||||
public TextShapeValue TextShapeValue { get; private set; }
|
||||
|
||||
public TextShapeSize TextShapeSize { get; private set; }
|
||||
|
||||
public TextShape(ShapeId id, Position position, Color color, TextShapeValue textShapeValue, TextShapeSize textShapeSize)
|
||||
: base(id, position, color)
|
||||
{
|
||||
TextShapeValue = textShapeValue;
|
||||
TextShapeSize = textShapeSize;
|
||||
}
|
||||
|
||||
public override ShapeTypeEnum ShapeType => ShapeTypeEnum.Text;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
using AipsCore.Domain.Common.Validation.Rules;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.TextShape.ValueObjects;
|
||||
|
||||
public record TextShapeSize : AbstractValueObject
|
||||
{
|
||||
public const int MaxTextShapeSize = 72;
|
||||
public const int MinTextShapeSize = 8;
|
||||
|
||||
public int Size { get; }
|
||||
|
||||
public TextShapeSize(int size)
|
||||
{
|
||||
Size = size;
|
||||
}
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return
|
||||
[
|
||||
new MaxValueRule<int>(Size, MaxTextShapeSize),
|
||||
new MinValueRule<int>(Size, MinTextShapeSize)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.Sub.TextShape.ValueObjects;
|
||||
|
||||
public record TextShapeValue: AbstractValueObject
|
||||
{
|
||||
public string Text { get; }
|
||||
|
||||
public TextShapeValue(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
23
dotnet/AipsCore/Domain/Models/Shape/ValueObjects/Position.cs
Normal file
23
dotnet/AipsCore/Domain/Models/Shape/ValueObjects/Position.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
public record Position : AbstractValueObject
|
||||
{
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
|
||||
public Position(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
using AipsCore.Domain.Common.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
public record ShapeId(string Value) : DomainId(Value);
|
||||
@@ -0,0 +1,27 @@
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
using AipsCore.Domain.Common.Validation.Rules;
|
||||
|
||||
namespace AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
public record Thickness : AbstractValueObject
|
||||
{
|
||||
private const int MaxThickness = 8;
|
||||
private const int MinThickness = 1;
|
||||
|
||||
private readonly int _value;
|
||||
|
||||
public Thickness(int value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return
|
||||
[
|
||||
new MinValueRule<int>(_value, MinThickness),
|
||||
new MaxValueRule<int>(_value, MaxThickness),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user