示例#1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            VirtualHeight = 0;
            draw_y        = 0;

            g.TranslateTransform(0, -_vScroll.Value);        //根据滚动条的值设置坐标偏移

            using (SolidBrush brush = new SolidBrush(this.ForeColor))
                using (Pen pen = new Pen(brush, 1))
                {
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    foreach (var item in Nodes)
                    {
                        item.Bounds = new Rectangle(0, draw_y, this.Width, rowHeight);
                        item.Level  = 0;
                        DrawNode(g, brush, pen, item);
                        draw_y += rowHeight;
                    }
                }
            g.ResetTransform();             //重置坐标系

            //if (!scrollBottom)
            _vScroll.VirtualHeight = VirtualHeight + 5; //绘制完成计算虚拟高度决定是否绘制滚动条
            if (MouseVisible && _vScroll.Visible)       //是否绘制滚动条
            {
                _vScroll.ReDrawScroll(g);
            }
        }
示例#2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            VirtualHeight = 0;
            VirtualWidth  = 0;
            Graphics g = e.Graphics;

            //绘制边框
            if (borderStyle == BorderStyle.FixedSingle)
            {
                Pen     pen   = new Pen(Color.FromArgb(100, 100, 100));
                Point[] point = new Point[4];
                point[0] = new Point(0, 0);
                point[1] = new Point(Width - 1, 0);
                point[2] = new Point(Width - 1, Height - 1);
                point[3] = new Point(0, Height - 1);
                g.DrawPolygon(pen, point);//
            }

            g.TranslateTransform(-listHScroll.Value, 0); //根据滚动条的值设置坐标偏移
            g.TranslateTransform(0, -chatVScroll.Value); //根据滚动条的值设置坐标偏移
            DrawColumn(g);
            g.ResetTransform();                          //重置坐标系
            chatVScroll.VirtualHeight = VirtualHeight;   //绘制完成计算虚拟高度决定是否绘制滚动条
            if (chatVScroll.Visible)                     //是否绘制滚动条
            {
                chatVScroll.ReDrawScroll(g);
            }

            listHScroll.VirtualWidth = VirtualWidth;
            if (listHScroll.Visible)
            {
                listHScroll.ReDrawScroll(g);
            }
        }
示例#3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (Adapter == null)
            {
                return;
            }
            VirtualHeight = 0;
            VirtualWidth  = 0;


            if (_animationManager.IsAnimating() && _clickViewHolder != null)
            {
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                Color bg = BackColor.TakeBackColor();//取相反色
                using (SolidBrush hrush = new SolidBrush(Color.FromArgb(50, bg)))
                {
                    float      animationValue = (float)_animationManager.GetProgress();
                    float      x    = _animationManager.GetMouseDown().X - animationValue / 2;
                    float      y    = _animationManager.GetMouseDown().Y - animationValue / 2;
                    RectangleF rect = new RectangleF(x, y, animationValue, animationValue);
                    e.Graphics.FillEllipse(hrush, rect);
                }
                e.Graphics.SmoothingMode = SmoothingMode.Default;
            }

            int count = Adapter.GetItemCount();

            for (int i = 0; i < count; i++)
            {
                ViewHolder viewHolder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                VirtualHeight += viewHolder.Bounds.Height;
                VirtualWidth  += viewHolder.Bounds.Width;

                if (viewHolder.Bounds.Bottom >= 0 && viewHolder.Bounds.Y <= this.Height)
                {
                    Adapter.OnDrawItem(e.Graphics, viewHolder, i);
                }
            }

            _vScroll.VirtualHeight = VirtualHeight;  //绘制完成计算虚拟高度决定是否绘制滚动条
            if (_MouseVisible && _vScroll.Visible)   //是否绘制滚动条
            {
                _vScroll.ReDrawScroll(e.Graphics);
            }
        }
示例#4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            VirtualHeight = 0;

            _rows.Clear();

            e.Graphics.TranslateTransform(-_hScroll.Value, 0);        //根据滚动条的值设置坐标偏移

            DrawColumn(e.Graphics);

            e.Graphics.TranslateTransform(0, -_vScroll.Value);        //根据滚动条的值设置坐标偏移



            if (DataSource != null)
            {
                e.Graphics.TranslateClip(0, ColumnHeight);//平移 绕过 标题

                using (SolidBrush solidBrush = new SolidBrush(this.ForeColor))
                {
                    Pen    pen   = new Pen(BorderColor);
                    string value = string.Empty;
                    float  y     = ColumnHeight;
                    VirtualHeight = ColumnHeight;
                    int i = 0;
                    foreach (var item in DataSource)
                    {
                        DrawRow(e.Graphics, solidBrush, pen, y, item);
                        RectangleF rectangle = new RectangleF(0, y, (this.Width > VirtualWidth) ? VirtualWidth : this.VirtualWidth, RowHeight);
                        _rows.Add(rectangle);

                        y += RowHeight;
                        e.Graphics.DrawLine(pen, 0, y, (this.Width > VirtualWidth) ? VirtualWidth : this.VirtualWidth, y);
                        VirtualHeight += RowHeight;

                        if (SelectionIndex == i)
                        {
                            solidBrush.Color = SelectionColor;
                            e.Graphics.FillRectangle(solidBrush, rectangle);
                        }
                        else if (m_MouseMoveIndex == i)
                        {
                            solidBrush.Color = MouseMoveColor;
                            e.Graphics.FillRectangle(solidBrush, rectangle);
                        }
                        i++;
                    }
                }
                e.Graphics.TranslateClip(0, -ColumnHeight);
            }

            if (m_DragRowOrColumn == 0)
            {
                if (m_MousePreview != null)
                {
                    e.Graphics.DrawImage(m_MousePreview, m_MouseMovePos.X - m_MouseDownOffset.X, m_MouseMovePos.Y - m_MouseDownOffset.Y);
                }
                //绘制预插入的位置
                if (!m_Prepare.IsEmpty)
                {
                    e.Graphics.DrawRectangle(Pens.Black, m_Prepare.X - 0.5f, m_Prepare.Y, m_Prepare.Width + 0.5f, m_Prepare.Height);
                    e.Graphics.FillRectangle(Brushes.White, m_Prepare);
                }
            }
            e.Graphics.ResetTransform();             //重置坐标系

            _vScroll.VirtualHeight = VirtualHeight;  //绘制完成计算虚拟高度决定是否绘制滚动条
            if (_MouseVisible && _vScroll.Visible)   //是否绘制滚动条
            {
                _vScroll.ReDrawScroll(e.Graphics);
            }

            _hScroll.VirtualWidth = VirtualWidth;
            if (_MouseVisible && _hScroll.Visible)
            {
                _hScroll.ReDrawScroll(e.Graphics);
            }


            if (m_DragRowOrColumn == 1)
            {
                if (m_MousePreview != null)
                {
                    e.Graphics.DrawImage(m_MousePreview, m_MouseMovePos.X - m_MouseDownOffset.X, m_MouseMovePos.Y - m_MouseDownOffset.Y);
                }
                //绘制预插入的位置
                if (!m_Prepare.IsEmpty)
                {
                    e.Graphics.DrawRectangle(Pens.Black, m_Prepare.X - 0.5f, m_Prepare.Y, m_Prepare.Width + 0.5f, m_Prepare.Height);
                    e.Graphics.FillRectangle(Brushes.White, m_Prepare);
                }
            }
        }