示例#1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Bitmap   bm = new Bitmap(this.Width, this.Height, e.Graphics);
            Graphics g  = Graphics.FromImage(bm);

            g.FillRectangle(Brushes.LightGray, new Rectangle(0, 0, bm.Width, bm.Height));
            e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(0, 0, this.Width, this.Height));
            int x = 4, y = 4;
            int n = 0;

            foreach (ShapeType shape in Enum.GetValues(typeof(ShapeType)))
            {
                GraphicsPath path = new GraphicsPath();
                ShapeControl.updateOutline(ref path, shape, _width, _height);
                g.FillRectangle(Brushes.LightGray, 0, 0, bm.Width, bm.Height);
                g.FillPath(Brushes.Yellow, path);
                g.DrawPath(Pens.Red, path);
                e.Graphics.DrawImage(bm, x, y, new Rectangle(new Point(0, 0), new Size(_width + 1, _height + 1)), GraphicsUnit.Pixel);
                if (this.shape.Equals(shape))
                {
                    e.Graphics.DrawRectangle(Pens.Red, new Rectangle(new Point(x - 2, y - 2), new Size(_width + 4, _height + 4)));
                }
                n++;
                x = (n % _numcol) * (_width); x = x + (n % _numcol) * 6 + 4;
                y = (n / _numcol) * (_height); y = y + (n / _numcol) * 6 + 4;
            }
        }
示例#2
0
        public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e)
        {
            Bitmap       bm    = new Bitmap(e.Bounds.Width + 4, e.Bounds.Height + 4, e.Graphics);
            Graphics     g     = Graphics.FromImage(bm);
            ShapeType    shape = (ShapeType)e.Value;
            GraphicsPath path  = new GraphicsPath();

            ShapeControl.updateOutline(ref path, shape, e.Bounds.Width - 5, e.Bounds.Height - 5);
            g.FillPath(Brushes.Yellow, path);
            g.DrawPath(Pens.Red, path);
            e.Graphics.DrawImage(bm, 3, 3, new Rectangle(new Point(0, 0), new Size(e.Bounds.Width, e.Bounds.Height)), GraphicsUnit.Pixel);
        }