// This sets up the panel for a specific day
public void SetupDay(DateTime day)
{
thisday = day;
string datestr = day.ToLongDateString();
datelabel.Text = datestr.Replace(",", " ").ToUpper();
Deselect();
// Determine begin and end date for this day
DateTime dstart = new DateTime(day.Year, day.Month, day.Day);
DateTime dend = new DateTime(dstart.Year, dstart.Month, dstart.Day);
dend = dend.AddDays(1);
dend = dend.AddTicks(-1);
// Setup items
List <AgendaItem> items = General.Agenda.GetItems(dstart, dend);
for (int i = 0; i < NUM_ITEMS; i++)
{
// Within range of items or this day?
if (i < items.Count)
{
AgendaItem ditem = items[i];
DateTime itemend = ditem.startdate + ditem.duration;
itemlabels[i].Text = ditem.startdate.Hour + ":" + ditem.startdate.Minute.ToString("00") + " -";
itemlabels[i].Visible = true;
itemends[i].Text = itemend.Hour + ":" + itemend.Minute.ToString("00");
itemends[i].Visible = true;
itembuttons[i].Text = ditem.ToString();
itembuttons[i].ColorText = ditem.color;
itembuttons[i].SetupColors(General.Colors);
itembuttons[i].Tag = ditem;
itembuttons[i].Visible = true;
}
else
{
itembuttons[i].Tag = null;
itemlabels[i].Visible = false;
itembuttons[i].Visible = false;
itemends[i].Visible = false;
}
}
}