示例#1
0
        private void existingProjects_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Bounds != backingSize)
            {
                backingSize   = e.Bounds;
                backingSize.X = 0;
                backingSize.Y = 0;
                if (backing != null)
                {
                    backing.Dispose();
                }
                backing = new Bitmap(e.Bounds.Width, e.Bounds.Height);
            }
            Graphics g = Graphics.FromImage(backing);

            g.FillRectangle(Brushes.White, backingSize);
            XPaint.PaintXGem(g, 0, 0);
            Rectangle textBounds = backingSize;

            textBounds.X     += 34;
            textBounds.Width -= 34 * 2;
            StringFormat fmt = new StringFormat();

            fmt.LineAlignment = StringAlignment.Center;
            g.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font, Brushes.Black, textBounds, fmt);
            if ((e.State & DrawItemState.Selected) != 0)
            {
                using (Brush b = new SolidBrush(Color.FromArgb(120, Color.Cyan)))
                {
                    g.FillRectangle(b, backingSize);
                }
            }
            g.Dispose();
            e.Graphics.DrawImageUnscaled(backing, e.Bounds.X, e.Bounds.Y);
            e.DrawFocusRectangle();
        }
示例#2
0
 protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
 {
     XPaint.PaintFormBackground(e.Graphics, ClientRectangle, theme);
 }