コード例 #1
0
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;

            if ((toolStrip is ToolStripDropDown) && (e.Item is ToolStripMenuItem))
            {
                Rectangle imageRectangle = e.ImageRectangle;
                if (e.Item.RightToLeft == RightToLeft.Yes)
                {
                    imageRectangle.X -= 2;
                }
                else
                {
                    imageRectangle.X += 2;
                }
                imageRectangle.Width = 13;
                imageRectangle.Y++;
                imageRectangle.Height -= 3;
                using (new SmoothingModeGraphics(graphics))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(imageRectangle);
                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor    = Color.White;
                            brush.SurroundColors = new Color[] { ControlPaint.Light(this.ColorTable.Back) };
                            Blend   blend    = new Blend();
                            float[] numArray = new float[3];
                            numArray[1]     = 0.3f;
                            numArray[2]     = 1f;
                            blend.Positions = numArray;
                            float[] numArray2 = new float[3];
                            numArray2[1]  = 0.5f;
                            numArray2[2]  = 1f;
                            blend.Factors = numArray2;
                            brush.Blend   = blend;
                            graphics.FillRectangle(brush, imageRectangle);
                        }
                    }
                    using (Pen pen = new Pen(ControlPaint.Light(this.ColorTable.Back)))
                    {
                        graphics.DrawRectangle(pen, imageRectangle);
                    }
                    ControlPaintEx.DrawCheckedFlag(graphics, imageRectangle, this.ColorTable.Fore);
                    return;
                }
            }
            base.OnRenderItemCheck(e);
        }
コード例 #2
0
        private void DrawCheckedFlagTest(Graphics g)
        {
            Rectangle rect = new Rectangle(50, 50, 20, 20);

            ControlPaintEx.DrawCheckedFlag(g, rect, Color.Black);
        }