-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamplesDialog.cs
More file actions
68 lines (54 loc) · 1.84 KB
/
ExamplesDialog.cs
File metadata and controls
68 lines (54 loc) · 1.84 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.Display.Dialogs;
namespace LcdDraw
{
public class ExamplesDialog: Dialog{
private int _currentScreen;
private Point _center;
public ExamplesDialog(string title) :
base(Font.MediumFont, title, Lcd.Width, Lcd.Height-(int)Font.MediumFont.maxHeight)
{
_currentScreen = 1;
_center = new Point (Lcd.Width / 2, Lcd.Height / 2);
}
protected override bool OnEnterAction ()
{
_currentScreen = (_currentScreen == 1 ? 2 : 1);
Lcd.Instance.Clear ();
return false; // no exit
}
protected override bool OnEscape()
{
return true; // exit
}
protected override void OnDrawContent ()
{
if (_currentScreen == 1)
DrawFirstScreen ();
else
DrawSecondScreen ();
}
private void DrawFirstScreen()
{
Lcd.Instance.DrawLine( new Point (0, 0), new Point (Lcd.Width-1, Lcd.Height-1), true);
Lcd.Instance.DrawLine( new Point (0, Lcd.Height-1), new Point (Lcd.Width-1, 0), true);
Lcd.Instance.DrawLine( new Point (40, 40), new Point (Lcd.Width-40, Lcd.Height-40), true);
Lcd.Instance.DrawLine( new Point (40, 100), new Point (Lcd.Width-20, Lcd.Height-60), true);
Lcd.Instance.DrawCircle (_center, 60, true);
Lcd.Instance.DrawCircle (_center, 50, true);
Lcd.Instance.DrawCircle (_center, 40, true);
Lcd.Instance.DrawCircleFilled (_center, 30, true);
Lcd.Instance.DrawCircleFilled (_center, 20, false);
Lcd.Instance.DrawCircleFilled (_center, 10, true);
Lcd.Instance.DrawEllipse (_center, 60, 30, true);
}
private void DrawSecondScreen()
{
Lcd.Instance.DrawEllipseFilled (_center, 60, 30, true);
Lcd.Instance.DrawEllipseFilled (new Point(0, Lcd.Height/2) , 60, 30, false);
var r = new Rectangle (new Point (15, 28), new Point (Lcd.Width - 15, Lcd.Height - 25));
Lcd.Instance.DrawRectangle (r, true);
}
}
}