-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangleBuilder.cs
51 lines (37 loc) · 1.45 KB
/
RectangleBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Developed by Bulat Bagaviev (@sunnyyssh).
// This file is licensed to you under the MIT license.
namespace Sunnyyssh.ConsoleUI;
public sealed class RectangleBuilder : IUIElementBuilder<Rectangle>
{
public Size Size { get; }
public Color Color { get; }
public OverlappingPriority OverlappingPriority { get; init; } = OverlappingPriority.Medium;
public Rectangle Build(UIElementBuildArgs args)
{
ArgumentNullException.ThrowIfNull(args, nameof(args));
var result = new Rectangle(args.Width, args.Height, OverlappingPriority)
{
Color = Color
};
return result;
}
UIElement IUIElementBuilder.Build(UIElementBuildArgs args) => Build(args);
public RectangleBuilder(int width, int height, Color color)
: this(new Size(width, height), color)
{ }
public RectangleBuilder(int width, double heightRelation, Color color)
: this(new Size(width, heightRelation), color)
{ }
public RectangleBuilder(double widthRelation, int height, Color color)
: this(new Size(widthRelation, height), color)
{ }
public RectangleBuilder(double widthRelation, double heightRelation, Color color)
: this(new Size(widthRelation, heightRelation), color)
{ }
public RectangleBuilder(Size size, Color color)
{
ArgumentNullException.ThrowIfNull(size, nameof(size));
Size = size;
Color = color;
}
}