protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.FillRectangle(Brushes.White, this.ClientRectangle); int startPoint = -(offsetPosition % ItemDirectionalSize); Rectangle area = new Rectangle(); for (int index = offsetPosition / ItemDirectionalSize; startPoint < OffsetPosition + DirectionSize; index++) { System.Diagnostics.Debug.WriteLine(index); if (HorizontalMode) { area = new Rectangle(startPoint, 0, ItemDirectionalSize, this.Height); if (DrawItemHorizontal != null) { DrawItemHorizontal.Invoke(this, new DrawItemEventArgs( pe.Graphics, this.Font, area, index, SelectedIndex == index ? DrawItemState.Selected : DrawItemState.None)); } } else { area = new Rectangle(0, startPoint, this.Width, ItemDirectionalSize); if (DrawItem != null) { DrawItem.Invoke(this, new DrawItemEventArgs( pe.Graphics, this.Font, area, index, SelectedIndex == index ? DrawItemState.Selected : DrawItemState.None)); } } startPoint += ItemDirectionalSize; } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (graphics == null) { return; } graphics.Clear(BackColor); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // Draw items via user-code if (DrawItem != null) { if (Items != null) { for (int i = 0; i < Items.Count; i++) { int yPos = (i * (rowHeight + rowDistance)) + scrollAmount + rowDistance; if (yPos >= -rowHeight && yPos < this.Height) { DrawItem?.Invoke(i == selected ? DrawItemState.Selected : DrawItemState.Default, graphics, i, GetItemBounds(i)); } } } } else // Draw default items { if (Items != null) { for (int i = 0; i < Items.Count; i++) { int yPos = (i * (rowHeight + rowDistance)) + scrollAmount + rowDistance; if (yPos >= -rowHeight && yPos < this.Height) { OnDrawItem(i == selected ? DrawItemState.Selected : DrawItemState.Default, graphics, i, GetItemBounds(i)); } } } } e.Graphics.DrawImageUnscaled(buffer, Point.Empty); }
private void OnDrawItem(object sender, DrawItemEventArgs e) { DrawItem?.Invoke(this, e); }
/// <summary> /// Raises the <see cref="E:DrawItem"/> event. /// </summary> /// <param name="e">The <see cref="DrawStepListItemEventArgs"/> instance containing the event data.</param> protected virtual void OnDrawItem(DrawStepListItemEventArgs e) { DrawItem?.Invoke(this, e); }
private void Listbox_DrawItem(object sender, DrawItemEventArgs e) { DrawItem?.Invoke(sender, e); }