System.Windows.Forms.TreeView.OnPaint C# (CSharp) Method

OnPaint() protected method

protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            // Reset filter.
            if (_resetFilterTime > 0)
            {
                _resetFilterTime -= Application.DeltaTime;
                if (_resetFilterTime <= 0)
                    _filter = "";
            }

            e.Graphics.FillRectangle(new SolidBrush(BackColor), 0, 0, Width, Height);

            for (int i = 0; i < scrollNodeList.Count; i++)
            {
                OnDrawNode(new DrawTreeNodeEventArgs(e.Graphics, scrollNodeList[i], scrollNodeList[i].Bounds, TreeNodeStates.Default));
            }

            #region Scroll.
            _scroll_ItemsEstimatedHeigh = Padding.Top + Padding.Bottom + _nodeList.Count * ItemHeight;
            if (_scroll_ItemsEstimatedHeigh > Height) _scrollVisible = true;
            else _scrollVisible = false;

            if (_scrollVisible)
            {
                Color _scrollBarColor = ScrollBarColor;
                if (_scrollHovered || _scroll) _scrollBarColor = ScrollBarHoverColor;

                float _scrollYCoeff = Height / _scroll_ItemsEstimatedHeigh;
                _scrollbarHeight = Height * _scrollYCoeff;
                if (_scrollbarHeight < 8) _scrollbarHeight = 8;
                _scrollbarY = scrollIndex * _scrollYCoeff;

                e.Graphics.FillRectangle(_scrollBarColor, Width - _scrollbarWidth + 2, _scrollbarY, _scrollbarWidth - 2, _scrollbarHeight);
            }
            #endregion

            e.Graphics.DrawRectangle(new Pen(BorderColor), 0, 0, Width, Height);
        }
        protected override object OnPaintEditor(float width)