-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransform.cs
53 lines (48 loc) · 2.68 KB
/
Transform.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
52
53
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElearningDesktop
{
class Transform
{
public static GraphicsPath BorderRadius(Rectangle objectShape, int intensity, bool topLeft, bool topRight, bool bottomRight, bool bottomLeft)
{
GraphicsPath desiredShape = new GraphicsPath();
if (topLeft && topRight)
{
desiredShape.AddArc(objectShape.X - 1, objectShape.Y - 1, intensity, intensity, 180, 90); // canto superior esquerdo
desiredShape.AddArc(objectShape.X + objectShape.Width - intensity, objectShape.Y - 1, intensity, intensity, 270, 90); // canto superior direito
}
else if (topLeft)
{
desiredShape.AddArc(objectShape.X - 1, objectShape.Y - 1, intensity, intensity, 180, 90); // canto superior esquerdo
desiredShape.AddLine(objectShape.X - 1 - intensity, objectShape.Y - 1, objectShape.X + objectShape.Width, objectShape.Y - 1);
}
else
{
desiredShape.AddLine(objectShape.X - 1, objectShape.Y - 1, objectShape.X + objectShape.Width - intensity, objectShape.Y - 1);
desiredShape.AddArc(objectShape.X + objectShape.Width - intensity, objectShape.Y - 1, intensity, intensity, 270, 90); // canto superior direito
}
if(bottomLeft && bottomRight)
{
desiredShape.AddArc(objectShape.X + objectShape.Width - intensity, objectShape.Y + objectShape.Height - intensity, intensity, intensity, 0, 90); //canto inferior direito
desiredShape.AddArc(objectShape.X - 1, objectShape.Y + objectShape.Height - intensity, intensity, intensity, 90, 90);// canto inferior esquerdo
}
else if (bottomLeft)
{
desiredShape.AddLine(objectShape.Width, objectShape.Y + objectShape.Height, objectShape.X - 1 - intensity, objectShape.Y + objectShape.Height);
desiredShape.AddArc(objectShape.X - 1, objectShape.Y + objectShape.Height - intensity, intensity, intensity, 90, 90);// canto inferior esquerdo
}
else
{
desiredShape.AddArc(objectShape.X + objectShape.Width - intensity, objectShape.Y + objectShape.Height - intensity, intensity, intensity, 0, 90); //canto inferior direito
desiredShape.AddLine(objectShape.X + objectShape.Width, objectShape.Y + objectShape.Height, objectShape.X - 1, objectShape.Y + objectShape.Height);
}
return desiredShape;
}
}
}