System.Windows.Forms.CommandBarContextMenu.MenuBarItem.DrawCheck C# (CSharp) Method

DrawCheck() private method

private DrawCheck ( Graphics graphics, Rectangle rectangle, Color color ) : void
graphics System.Drawing.Graphics
rectangle System.Drawing.Rectangle
color Color
return void
            private void DrawCheck(Graphics graphics, Rectangle rectangle, Color color)
            {
                Bitmap bitmap = new Bitmap(rectangle.Width, rectangle.Height);

                Graphics bitmapGraphics = Graphics.FromImage(bitmap);
                ControlPaint.DrawMenuGlyph(bitmapGraphics, 0, 0, rectangle.Width, rectangle.Height, MenuGlyph.Checkmark);
                bitmapGraphics.Flush();

                bitmap.MakeTransparent(Color.White);

                ImageAttributes attributes = new ImageAttributes();
                ColorMap colorMap = new ColorMap();
                colorMap.OldColor = Color.Black;
                colorMap.NewColor = color;
                attributes.SetRemapTable(new ColorMap[] { colorMap });

                graphics.DrawImage(bitmap, rectangle, 0, 0, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel, attributes);
            }