コード例 #1
0
        private void listBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (chk_preview.Checked)
            {
                if (chk_modo2.Checked)
                {
                    e.DrawBackground();
                    ListBox  lb  = (ListBox)sender;
                    RGBPoint pnt = (RGBPoint)lb.Items[e.Index];
                    Color    cc  = pnt.getc();

                    Graphics g = e.Graphics;
                    g.FillRectangle(new SolidBrush(Color.White), e.Bounds);

                    SizeF ss = g.MeasureString(pnt.ToString(), e.Font);
                    g.DrawString(pnt.ToString(), e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
                    g.FillRectangle(new SolidBrush(cc), e.Bounds.X + ss.Width + 5, e.Bounds.Y, 18, e.Bounds.Height);
                    g.DrawString("R (" + cc.R + ")", e.Font, new SolidBrush(Color.FromArgb(cc.R, 0, 0)), new PointF(e.Bounds.X + ss.Width + 25, e.Bounds.Y));
                    g.DrawString("G (" + cc.G + ")", e.Font, new SolidBrush(Color.FromArgb(0, cc.G, 0)), new PointF(e.Bounds.X + ss.Width + 65, e.Bounds.Y));
                    g.DrawString("B (" + cc.B + ")", e.Font, new SolidBrush(Color.FromArgb(0, 0, cc.B)), new PointF(e.Bounds.X + ss.Width + 105, e.Bounds.Y));
                    g.DrawString("A (" + cc.B + ")", e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X + ss.Width + 145, e.Bounds.Y));
                    e.DrawFocusRectangle();
                }
                else
                {
                    e.DrawBackground();
                    ListBox  lb  = (ListBox)sender;
                    RGBPoint pnt = (RGBPoint)lb.Items[e.Index];
                    Color    cc  = pnt.getc();

                    Graphics g = e.Graphics;
                    g.FillRectangle(new SolidBrush(cc), e.Bounds);

                    if ((cc.R + cc.G + cc.B) > 186)
                    {
                        cc = Color.Black;
                    }
                    else
                    {
                        cc = Color.White;
                    }

                    g.DrawString(pnt.ToString(), e.Font, new SolidBrush(cc), new PointF(e.Bounds.X, e.Bounds.Y));
                    e.DrawFocusRectangle();
                }
            }
            else
            {
                e.DrawBackground();
                e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                e.Graphics.DrawString(((RGBPoint)((ListBox)sender).Items[e.Index]).ToString(), e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
                e.DrawFocusRectangle();
            }
        }
コード例 #2
0
 internal void addPunto(RGBPoint rGBPoint)
 {
     lst_puntos.Items.Add(rGBPoint);
 }