-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIcon.cs
More file actions
49 lines (43 loc) · 1.22 KB
/
Icon.cs
File metadata and controls
49 lines (43 loc) · 1.22 KB
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
using Cosmos.System.Graphics;
using System.Drawing;
using Cosmos.System.Graphics.Fonts;
namespace IronOS
{
public class Icon
{
private string label;
private int x, y;
private int size = 40;
private Pen iconPen = new Pen(Color.LightGray);
private Pen textPen = new Pen(Color.White);
public Icon(string label, int x, int y)
{
this.label = label;
this.x = x;
this.y = y;
}
public void Draw(Canvas canvas)
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
canvas.DrawPoint(iconPen, x + i, y + j);
}
}
canvas.DrawString(label, PCScreenFont.Default, textPen, x + 5, y + size + 2);
}
public bool IsHovered(int mouseX, int mouseY)
{
return mouseX >= x && mouseX <= x + size &&
mouseY >= y && mouseY <= y + size;
}
public void CheckClick(int mouseX, int mouseY, bool clicked)
{
if (clicked && IsHovered(mouseX, mouseY))
{
// Future: launch app
}
}
}
}