public void Render()
{
_screen.Clear();
//border
_screen.DrawRectangle(Color.White, 1, 0, 0, AgentSize, AgentSize, 0, 0, Color.Black, 0, 0, Color.Black, 0, 0,
255);
int first = 0;
int last = Items.Count-1;
if ((last - first) > _maxVisible)
{
first = SelectedIndex - (_maxVisible/2);
if (first < 0)
{
first = 0;
}
last = first + _maxVisible - 1;
if (last > Items.Count - 1) last = Items.Count - 1;
}
int top = 0;
int height = MenuFont.Height;
for (int index = first; index <= last; index++)
{
MenuItem item = (Items[index] as MenuItem);
item.Selected = false;
if (index == SelectedIndex) item.Selected = true;
Color backColor = Color.White;
Color textColor = Color.Black;
if (item.Selected)
{
backColor = Color.Black;
textColor = Color.White;
}
_screen.DrawRectangle(backColor, 1, 1, top, Menu.AgentSize - 2, height, 0, 0, backColor, 0, 0, backColor,
0,
0, 255);
_screen.DrawText(item.Title, MenuFont, textColor, 16, top + 1);
if (item.Image != null) _screen.DrawImage(1, top, item.Image, 0,0,item.Image.Width, item.Image.Height);
top += height + 1;
}
_screen.Flush();
}