implement

This commit is contained in:
2026-02-08 21:32:24 +01:00
parent 90c127ddb3
commit 9d95bb5cc3
15 changed files with 313 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
namespace AipsCore.Domain.Models.Shape.Enums;
public enum ShapeTypeEnum
{
Rectangle,
Line,
Arrow,
Text
}

View 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;
}
}

View 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;
}

View 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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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)
];
}
}

View File

@@ -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 [];
}
}

View 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 [
];
}
};

View File

@@ -0,0 +1,5 @@
using AipsCore.Domain.Common.ValueObjects;
namespace AipsCore.Domain.Models.Shape.ValueObjects;
public record ShapeId(string Value) : DomainId(Value);

View File

@@ -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),
];
}
}