Accord.Controls.Histogram.OnPaint C# (CSharp) Метод

OnPaint() защищенный Метод

Paint the control.
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs Data for Paint event.
Результат void
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // drawing area's width and height
            width = ((values == null) || (vertical == true)) ?
                ClientRectangle.Width - 2 :
                Math.Min(values.Length, ClientRectangle.Width - 2);

            height = ((values == null) || (vertical == false)) ?
                ClientRectangle.Height - 2 :
                Math.Min(values.Length, ClientRectangle.Height - 2);

            int x = 1;
            int y = 1;
            int value;

            // draw rectangle around the image
            g.DrawRectangle(blackPen, x - 1, y - 1, width + 1, height + 1);

            if (values != null)
            {
                int start = Math.Min(this.start, this.stop);
                int stop = Math.Max(this.start, this.stop);

                if (tracking)
                {
                    // fill region of selection
                    Brush brush = new SolidBrush(Color.FromArgb(92, 92, 92));

                    if (vertical)
                    {
                        g.FillRectangle(brush, x, y + start, width, Math.Abs(start - stop) + 1);
                    }
                    else
                    {
                        g.FillRectangle(brush, x + start, y, Math.Abs(start - stop) + 1, height);
                    }
                    brush.Dispose();
                }

                if (max != 0)
                {
                    // scaling factor
                    double factor = (double)((vertical) ? width : height) /
                        ((logarithmic) ? maxLogarithmic : max);

                    // draw histogram
                    for (int i = 0, len = (vertical) ? height : width; i < len; i++)
                    {
                        if (logarithmic)
                        {
                            value = (values[i] == 0) ? 0 : (int)(Math.Log10(values[i]) * factor);
                        }
                        else
                        {
                            value = (int)(values[i] * factor);
                        }

                        if (value != 0)
                        {
                            if (vertical)
                            {
                                g.DrawLine(((tracking) && (i >= start) && (i <= stop)) ? whitePen : drawPen,
                                    new Point(x, y + i),
                                    new Point(x + value, y + i)
                                    );
                            }
                            else
                            {
                                g.DrawLine(((tracking) && (i >= start) && (i <= stop)) ? whitePen : drawPen,
                                    new Point(x + i, y + height - 1),
                                    new Point(x + i, y + height - value)
                                    );
                            }
                        }
                    }
                }
            }

            // Calling the base class OnPaint
            base.OnPaint(e);
        }