Exemple #1
0
 protected override void OnPaintBackground(PaintEventArgs pe)
 {
     //htmlPanel.Width -= 149;
     pe.Graphics.Clear(SystemColors.Info);
     pe.Graphics.DrawRectangle(BrushRegistry.GetPen(Color.FromArgb(103, 103, 103)), pe.ClipRectangle.X, pe.ClipRectangle.Y, pe.ClipRectangle.Width - 1, pe.ClipRectangle.Height - 1);
 }
        protected override void OnPaint(PaintEventArgs pe)
        {
            float yPos       = 1;
            float itemHeight = ItemHeight;
            // Maintain aspect ratio
            //int imageWidth = (int)(itemHeight * imageList.ImageSize.Width / imageList.ImageSize.Height);
            int imageWidth = 16;

            int      curItem = firstItem;
            Graphics g       = pe.Graphics;

            while (curItem < completionData.Length && yPos < Height)
            {
                RectangleF drawingBackground = new RectangleF(1, yPos, Width - 2, itemHeight);
                //drawingBackground.X += 3;
                if (drawingBackground.IntersectsWith(pe.ClipRectangle))
                {
                    // draw Background

                    if (curItem == selectedItem)
                    {
                        Rectangle r = Rectangle.Round(drawingBackground);
                        r.Width  -= 4;
                        r.Height -= 1;

                        r.Width -= imageWidth;
                        r.X     += imageWidth;
                        r.X     += 3;

                        g.DrawRectangle(BrushRegistry.GetPen(Color.FromArgb(229, 195, 101)), r);

                        using (LinearGradientBrush brush = new LinearGradientBrush(r, startColorTop, endColorTop, LinearGradientMode.Vertical))
                        {
                            g.FillRectangle(brush, r.X + 1, r.Y + 1, r.Width - 1, (r.Height / 2));
                        }
                        //Console.WriteLine();
                        g.FillRectangle(BrushRegistry.GetBrush(colorBottom), r.X + 1, r.Y + (r.Height / 2) + 1, r.Width - 1, (r.Height / 2));
                        //LinearGradientBrush gradientBrush = new LinearGradientBrush(r,
                        //g.FillRectangle(SystemBrushes.Highlight, drawingBackground);
                    }
                    else
                    {
                        g.FillRectangle(SystemBrushes.Window, drawingBackground);
                    }

                    // draw Icon
                    int xPos = 0;
                    if (imageList != null && completionData[curItem].ImageIndex < imageList.Images.Count)
                    {
                        g.FillRectangle(SystemBrushes.Window, drawingBackground.X, drawingBackground.Y, imageWidth + 3, itemHeight);
                        g.DrawImage(imageList.Images[completionData[curItem].ImageIndex], new RectangleF(3, yPos + 1, imageWidth, 16));
                        xPos = imageWidth + 3;
                    }

                    // draw text
                    if (curItem == selectedItem)
                    {
                        g.DrawString(completionData[curItem].Text, Font, BrushRegistry.GetBrush(Color.Black), xPos, yPos);
                    }
                    else
                    {
                        g.DrawString(completionData[curItem].Text, Font, SystemBrushes.WindowText, xPos, yPos);
                    }
                }

                yPos += itemHeight;
                ++curItem;
            }
            g.DrawRectangle(SystemPens.ControlDark, new Rectangle(0, 0, Width - 1, Height - 1));
        }