// This sets up the control to show the given items public void SetupItems(List<AgendaItem> items, DateTime date) { DisplayLabel l1 = null; DisplayLabel l2 = null; CleanupControls(); // Make labels int top = textlabel1.Top; foreach(AgendaItem i in items) { string timestr; // Determine how to display this item if((i.startdate.Year == date.Year) && (i.startdate.Month == date.Month) && (i.startdate.Day == date.Day)) { if(i.recur == AgendaItemRecur.Annually) timestr = ""; else timestr = i.startdate.Hour + ":" + i.startdate.Minute.ToString("00"); } else if(i.recur == AgendaItemRecur.None) timestr = ""; else continue; // Will this item reach the end of the control? if(((top + textlabel1.Height) >= this.ClientRectangle.Height) && (l1 != null) && (l2 != null)) { // Make the previous item display "More" l1.Text = ""; l2.Text = "More..."; l2.ColorText = ColorIndex.ControlNormal; l2.SetupColors(General.Colors); // We can't go any further break; } else { // Time l1 = new DisplayLabel(); l1.AutoSize = timelabel1.AutoSize; l1.ColorBackground = timelabel1.ColorBackground; l1.ColorText = i.color; l1.Font = timelabel1.Font; l1.Location = new Point(timelabel1.Left, top); l1.Size = timelabel1.Size; l1.Text = timestr; l1.TextAlign = timelabel1.TextAlign; l1.Visible = true; l1.SetupColors(General.Colors); Controls.Add(l1); labels.Add(l1); l1.BringToFront(); // Description l2 = new DisplayLabel(); l2.AutoSize = textlabel1.AutoSize; l2.AutoEllipsis = textlabel1.AutoEllipsis; l2.Anchor = textlabel1.Anchor; l2.ColorBackground = textlabel1.ColorBackground; l2.ColorText = i.color; l2.Font = textlabel1.Font; l2.Location = new Point(textlabel1.Left, top); l2.Size = textlabel1.Size; l2.Text = "\u2022 " + i.ToString(); l2.TextAlign = textlabel1.TextAlign; l2.UseMnemonic = textlabel1.UseMnemonic; l2.Visible = true; l2.SetupColors(General.Colors); Controls.Add(l2); labels.Add(l2); l2.BringToFront(); // Position for next labels top += textlabel1.Height + textlabel1.Margin.Bottom + textlabel1.Margin.Top; } } }
// This sets up the control to show the given items public void SetupItems(List <AgendaItem> items, DateTime date) { DisplayLabel l1 = null; DisplayLabel l2 = null; CleanupControls(); // Make labels int top = textlabel1.Top; foreach (AgendaItem i in items) { string timestr; // Determine how to display this item if ((i.startdate.Year == date.Year) && (i.startdate.Month == date.Month) && (i.startdate.Day == date.Day)) { if (i.recur == AgendaItemRecur.Annually) { timestr = ""; } else { timestr = i.startdate.Hour + ":" + i.startdate.Minute.ToString("00"); } } else if (i.recur == AgendaItemRecur.None) { timestr = ""; } else { continue; } // Will this item reach the end of the control? if (((top + textlabel1.Height) >= this.ClientRectangle.Height) && (l1 != null) && (l2 != null)) { // Make the previous item display "More" l1.Text = ""; l2.Text = "More..."; l2.ColorText = ColorIndex.ControlNormal; l2.SetupColors(General.Colors); // We can't go any further break; } else { // Time l1 = new DisplayLabel(); l1.AutoSize = timelabel1.AutoSize; l1.ColorBackground = timelabel1.ColorBackground; l1.ColorText = i.color; l1.Font = timelabel1.Font; l1.Location = new Point(timelabel1.Left, top); l1.Size = timelabel1.Size; l1.Text = timestr; l1.TextAlign = timelabel1.TextAlign; l1.Visible = true; l1.SetupColors(General.Colors); Controls.Add(l1); labels.Add(l1); l1.BringToFront(); // Description l2 = new DisplayLabel(); l2.AutoSize = textlabel1.AutoSize; l2.AutoEllipsis = textlabel1.AutoEllipsis; l2.Anchor = textlabel1.Anchor; l2.ColorBackground = textlabel1.ColorBackground; l2.ColorText = i.color; l2.Font = textlabel1.Font; l2.Location = new Point(textlabel1.Left, top); l2.Size = textlabel1.Size; l2.Text = "\u2022 " + i.ToString(); l2.TextAlign = textlabel1.TextAlign; l2.UseMnemonic = textlabel1.UseMnemonic; l2.Visible = true; l2.SetupColors(General.Colors); Controls.Add(l2); labels.Add(l2); l2.BringToFront(); // Position for next labels top += textlabel1.Height + textlabel1.Margin.Bottom + textlabel1.Margin.Top; } } }