private void DrawItemHandler(object sender, DrawItemEventArgs ev) { if (this.plugin == null || ev.Index == -1) { return; } Rectangle bounds = ev.Bounds; // draw background ev.DrawBackground(); // draw border ev.Graphics.DrawRectangle(Pens.Gray, bounds); ServerItem serverItem = (ServerItem)this.Items[ev.Index]; // Find the area in which to put the text and draw. this.layoutRect.X = bounds.Left + 32 + (3 * ItemMargin); this.layoutRect.Y = bounds.Top + (ItemMargin * 2); this.layoutRect.Width = bounds.Right - ItemMargin - this.layoutRect.X; this.layoutRect.Height = bounds.Bottom - ItemMargin - this.layoutRect.Y; // draw server item id and name if ((ev.State & DrawItemState.Selected) == DrawItemState.Selected) { this.pen.Brush = WhiteBrush; ev.Graphics.DrawString(serverItem.ToString(), this.Font, WhiteBrush, this.layoutRect); } else { this.pen.Brush = BlackBrush; ev.Graphics.DrawString(serverItem.ToString(), this.Font, BlackBrush, this.layoutRect); } this.destRect.Y = bounds.Top + ItemMargin; ClientItem clientItem = this.plugin.GetClientItem(serverItem.ClientId); if (clientItem != null) { Bitmap bitmap = clientItem.GetBitmap(); if (bitmap != null) { this.sourceRect.Width = bitmap.Width; this.sourceRect.Height = bitmap.Height; ev.Graphics.DrawImage(bitmap, this.destRect, this.sourceRect, GraphicsUnit.Pixel); } } // draw item border ev.Graphics.DrawRectangle(this.pen, this.destRect); // draw focus rect ev.DrawFocusRectangle(); }
protected override void PaintContent(Graphics graphics) { List <int> range = GetIndexesInView().ToList(); if (range.Count == 0) { return; } int min = range.Min(); int max = range.Max(); int width = Math.Max(ContentSize.Width, Viewport.Width); Rectangle rect = new Rectangle(0, 0, width, ItemSize); for (int i = min; i <= max; i++) { rect.Y = i * ItemSize; if (SelectedIndices.Count > 0 && SelectedIndices.Contains(i)) { graphics.FillRectangle(Colors.ListSelectionBrush, rect); } else { graphics.FillRectangle(Colors.ListBackgroudBrush, rect); } ServerItem item = Items[i]; // find the area in which to put the text and draw. m_layoutRect.X = rect.Left + 32 + (3 * ItemMargin); m_layoutRect.Y = rect.Top + (ItemMargin * 2); m_layoutRect.Width = rect.Right - ItemMargin - m_layoutRect.X; m_layoutRect.Height = rect.Bottom - ItemMargin - m_layoutRect.Y; m_destRect.Y = rect.Top + ItemMargin; // draw view background graphics.FillRectangle(Colors.ListViewBackgroudBrush, m_destRect); // draw text graphics.DrawString(item.ToString(), Font, Colors.TextColorBrush, m_layoutRect); ClientItem clientItem = Plugin.GetClientItem(item.ClientId); if (clientItem != null) { Bitmap bitmap = clientItem.GetBitmap(); if (bitmap != null) { m_sourceRect.Width = bitmap.Width; m_sourceRect.Height = bitmap.Height; graphics.DrawImage(bitmap, m_destRect, m_sourceRect, GraphicsUnit.Pixel); } } // draw view border graphics.DrawRectangle(Colors.BorderColorPen, m_destRect); // draw border graphics.DrawRectangle(Colors.BorderColorPen, rect); } }