protected internal void DrawMenuItem(Graphics g, int item, bool highlighted) { Rectangle bounds = itemBounds[item]; // Get the area for the text Rectangle textBounds = new Rectangle( bounds.X + ItemPaddingOrigin.X, bounds.Y + ItemPaddingOrigin.Y, bounds.Width - ItemPaddingSize.Width, bounds.Height - ItemPaddingSize.Height); MenuItem menuItem = itemList[item]; if (menuItem.Text == "-") { g.FillRectangle(SystemBrushes.Menu, bounds); ThemeManager.MainPainter.DrawSeparator(g, bounds); } else { if (menuItem.OwnerDraw) { DrawItemEventArgs drawItem = new DrawItemEventArgs(g, SystemInformation.MenuFont, bounds, item, DrawItemState.None); menuItem.OnDrawItem(drawItem); } else { Brush fore, back; if (highlighted) { fore = SystemBrushes.HighlightText; back = SystemBrushes.Highlight; } else { fore = SystemBrushes.MenuText; back = SystemBrushes.Menu; } g.FillRectangle(back, bounds); g.DrawString(menuItem.Text, SystemInformation.MenuFont, fore, textBounds, format); if (this is ContextMenu && menuItem.itemList.Length > 0) { int x = bounds.Right - 7; int y = (bounds.Bottom + bounds.Top) / 2; g.FillPolygon(fore, new PointF[] { new Point(x, y), new Point(x - 5, y - 5), new Point(x - 5, y + 5) }); } } } }