Пример #1
0
        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;
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 private void OnDrawItem(object sender, DrawItemEventArgs e)
 {
     DrawItem?.Invoke(this, e);
 }
Пример #4
0
 /// <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);
 }
Пример #5
0
 private void Listbox_DrawItem(object sender, DrawItemEventArgs e)
 {
     DrawItem?.Invoke(sender, e);
 }