private void listBoxSymbols_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
if (e.Index >= 0) {
string id = (string) listBoxSymbols.Items[e.Index];
// Get bounds of where to draw the symbol and its text.
RectangleF symbolGraphicsBounds = e.Bounds;
symbolGraphicsBounds.Width = symbolGraphicsBounds.Height;
RectangleF textBounds = e.Bounds;
textBounds.X += symbolGraphicsBounds.Width + 4;
// Get color to draw with. Draw customize ones in red when not selected.
Color foreColor;
if ((e.State & DrawItemState.Selected) == 0 && TextIsCustomized(id))
foreColor = Color.Red;
else
foreColor = e.ForeColor;
// Draw the symbol.
SmoothingMode oldSmoothing = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
Symbol symbol = symbolDB[id];
symbol.Draw(e.Graphics, foreColor, symbolGraphicsBounds);
e.Graphics.SmoothingMode = oldSmoothing;
// Draw the text. Use English if we're customizing text, otherwise use the set language.
string langId = useAsLocalizeTool ? "en" : LangId;
string text = symbol.GetName(langId);
StringFormat stringFormat = new StringFormat(StringFormat.GenericDefault);
stringFormat.Alignment = StringAlignment.Near;
stringFormat.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString(text, e.Font, new SolidBrush(foreColor), textBounds, stringFormat);
}
e.DrawFocusRectangle();
}