Files
rookie/RoundedRectangleF.cs
SytheZN d3a2c4012c Release/RSL-2.17 (#128)
* fix: pull to desktop not resetting work status.

resolves #104

* Create Text File with upload size for verification

* bump version

* better public config handling

* code cleanup

Co-authored-by: Fenopy <Fenopie@Gmail.com>
2022-12-05 23:42:59 +02:00

48 lines
1.6 KiB
C#

using System.Drawing;
using System.Drawing.Drawing2D;
namespace AndroidSideloader
{
public class RoundedRectangleF
{
private Point location;
private readonly float x, y;
private readonly float width, height;
public RoundedRectangleF(float width, float height, float radius, float x = 0, float y = 0)
{
location = new Point(0, 0);
Radius = radius;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
Path = new GraphicsPath();
if (radius <= 0)
{
Path.AddRectangle(new RectangleF(x, y, width, height));
return;
}
RectangleF upperLeftRect = new RectangleF(x, y, 2 * radius, 2 * radius);
RectangleF upperRightRect = new RectangleF(width - (2 * radius) - 1, x, 2 * radius, 2 * radius);
RectangleF lowerLeftRect = new RectangleF(x, height - (2 * radius) - 1, 2 * radius, 2 * radius);
RectangleF lowerRightRect = new RectangleF(width - (2 * radius) - 1, height - (2 * radius) - 1, 2 * radius, 2 * radius);
Path.AddArc(upperLeftRect, 180, 90);
Path.AddArc(upperRightRect, 270, 90);
Path.AddArc(lowerRightRect, 0, 90);
Path.AddArc(lowerLeftRect, 90, 90);
Path.CloseAllFigures();
}
public RoundedRectangleF()
{
}
public GraphicsPath Path { get; }
public RectangleF Rect => new RectangleF(x, y, width, height);
public float Radius { get; set; }
}
}