-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
RectangleGridAdorner.cs
40 lines (35 loc) · 1.36 KB
/
RectangleGridAdorner.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
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui
{
/// <summary>
/// Rectangle Grid Adorner.
/// </summary>
public class RectangleGridAdorner : RectangleAdorner
{
const int LineMaxLength = 10000;
/// <summary>
/// Initializes a new instance of the <see cref="RectangleGridAdorner"/> class.
/// </summary>
/// <param name="view">An <see cref="IView"/> to create the Adorner around.</param>
/// <param name="density">Override density setting. Default: 1</param>
/// <param name="offset">Offset Point used for positioning drawable object. Default: null</param>
/// <param name="fillColor">Canvas Fill Color.</param>
/// <param name="strokeColor">Canvas Stroke Color.</param>
public RectangleGridAdorner(IView view, float density = 1, Point? offset = null, Color? fillColor = null, Color? strokeColor = null)
: base(view, density, offset, fillColor, strokeColor)
{
}
public override void Draw(ICanvas canvas, RectF dirtyRect)
{
base.Draw(canvas, dirtyRect);
var y = (float)DrawnRectangle.Y;
var x = (float)DrawnRectangle.X;
var width = (float)DrawnRectangle.Width;
var height = (float)DrawnRectangle.Height;
canvas.DrawLine(0, y, LineMaxLength, y);
canvas.DrawLine(0, y + height, LineMaxLength, y + height);
canvas.DrawLine(x, 0, x, LineMaxLength);
canvas.DrawLine(x + width, 0, x + width, LineMaxLength);
}
}
}