Пример #1
0
        private void windowListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.Index == -1)
            {
                return;
            }

            var window = filteredWindows[e.Index];
            var image  = iconService.GetIconImage(window.GetProcess());

            if (image != null)
            {
                image = (Image)(new Bitmap(image, new Size(16, 16)));
            }
            else
            {
                image = (Image)(new Bitmap(16, 16));
            }
            e.Graphics.DrawImage(image, e.Bounds.X, e.Bounds.Y);
            e.Graphics.DrawString(windowListBox.Items[e.Index].ToString(),
                                  new System.Drawing.Font(windowListBox.Items[e.Index].ToString(), 12),
                                  new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                                  e.Bounds.X + image.Width,
                                  e.Bounds.Y);
        }