private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { // Cast the sender object back to ListBox type. ListBox theListBox = (ListBox)sender; // Get the string contained in each item. object item = theListBox.Items[e.Index]; // If the item is the selected item, then draw the rectangle // filled in blue. The item is selected when a bitwise And // of the State property and the DrawItemState.Selected // property is true. if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds); } else { // Otherwise, draw the rectangle filled in beige. e.Graphics.FillRectangle(SystemBrushes.ControlLightLight, e.Bounds); } // Draw a rectangle in blue around each item. //e.Graphics.DrawRectangle(Pens.Blue, e.Bounds); if (item is GPLocation) { GPLocation loc = item as GPLocation; e.Graphics.DrawString(loc.getName(), labelCount.Font, Brushes.Black, e.Bounds.X + 4, e.Bounds.Y + 4); e.Graphics.DrawString("Timezone: " + loc.getTimeZone().getFullName(), label1.Font, Brushes.Black, e.Bounds.X + 4, e.Bounds.Y + 20); } else if (item is GPLocationChange) { GPLocationChange chan = item as GPLocationChange; GPGregorianTime gt = new GPGregorianTime(chan.LocationA); gt.setJulianGreenwichTime(new GPJulianTime(chan.julianStart, 0)); string humanStart = string.Format("{0} {1}", gt.getLongTimeString(), chan.LocationA.getTimeZoneName()); e.Graphics.DrawString(gt.getLongDateString() + " - travelling", labelCount.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 4); e.Graphics.DrawLine(Pens.Black, e.Bounds.X + 40, e.Bounds.Y + 4, e.Bounds.X + 40, e.Bounds.Bottom - 4); e.Graphics.DrawString("Start: " + chan.humanStart, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 20); //e.Graphics.DrawString("End: " + chan.humanEnd, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 36); e.Graphics.DrawString("Length: " + chan.humanLength, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 36); } // Draw the focus rectangle around the selected item. e.DrawFocusRectangle(); }
private GPTimeZone getTimeZone(int index) { LocationPickerControl lpic = (index == 0) ? LocationPicker : LocationPicker2; if (lpic != null) { GPLocationProvider lp = lpic.SelectedLocation; if (lp != null) { return(lp.getTimeZone()); } } GPLocation loc = (index == 0) ? LocationObj : LocationObj2; if (loc != null) { return(loc.getTimeZone()); } return(null); }