private void DrawFooter(Graphics graphics)
        {
            if (!ShowFooter)
            {
                return;
            }

            var rect = _bound.FooterBound;

            rect = rect.ReduceLeft(GetOffsetLeft());
            var e = new TreeListItemRenderEventArgs(Footer, graphics, rect)
            {
                DrawState = DrawState.Normal
            };

            Renderer.DrawFooterBackground(e);

            if (Footer == null)
            {
                return;
            }

            e.Graphics.KeepClip(_bound.FooterBound, () =>
            {
                DrawCells(e.Graphics, e.Item.Cells, e.Bounds, e.DrawState);
            });
        }
Beispiel #2
0
        /// <summary>
        /// 绘制页脚。
        /// </summary>
        /// <param name="e"></param>
        public virtual void DrawFooterBackground(TreeListItemRenderEventArgs e)
        {
            using (var br = new LinearGradientBrush(e.Bounds, Color.FromArgb(250, 250, 250), Color.FromArgb(240, 240, 240), 90))
            {
                e.Graphics.FillRectangle(br, e.Bounds);
            }

            e.Graphics.DrawLine(Pens.LightGray, e.Bounds.X, e.Bounds.Y, e.Bounds.Right, e.Bounds.Y);
        }
Beispiel #3
0
        protected virtual Color GetItemBackgroundColor(TreeListItemRenderEventArgs e)
        {
            if (e.DrawState == DrawState.Selected)
            {
                return(e.Item.TreeList.Focused ? SystemColors.Highlight : SystemColors.ButtonFace);
            }
            else if (e.Item.BackgroundColor != Color.Empty)
            {
                return(e.Item.BackgroundColor);
            }
            else if (e.Alternate && e.Item.TreeList.AlternateBackColor != Color.Empty)
            {
                return(e.Item.TreeList.AlternateBackColor);
            }

            return(e.Item.TreeList.BackColor);
        }
        private void DrawItem(TreeListItemRenderEventArgs e, bool setClip = true)
        {
            e.Graphics.KeepClip(_bound.ItemBound, () =>
            {
                Renderer.DrawItem(e);
                DrawCells(e.Graphics, e.Item.Cells, e.Bounds, e.DrawState);
            }, setClip);

            if (ShowRowNumber)
            {
                var e3 = new TreeListRowNumberRenderEventArgs(this, RowNumberIndex + e.Item.DataIndex, e.Graphics, new Rectangle(_bound.WorkBound.X, e.Bounds.Y, RowNumberWidth, e.Bounds.Height));

                e.Graphics.KeepClip(_bound.RowNumberBound, () =>
                {
                    e3.DrawState = e.DrawState;
                    DrawRowNumber(e3);
                });
            }
        }
Beispiel #5
0
        /// <summary>
        /// 绘制 <see cref="TreeListItem"/> 的背景。
        /// </summary>
        /// <param name="e"></param>
        protected virtual void DrawItemBackground(TreeListItemRenderEventArgs e)
        {
            //绘制背景图像
            if (e.Item.TreeList.BackgroundImage != null)
            {
                e.Graphics.KeepClip(e.Bounds, () =>
                {
                    var be = new BackgroundRenderEventArgs(e.Item.TreeList, e.Graphics, e.Item.TreeList.GetBoundSet().ItemBound);
                    ThemeManager.BaseRenderer.DrawBackground(be);
                });
            }

            var backColor = GetItemBackgroundColor(e);

            if (!backColor.IsEmpty)
            {
                using (var brush = new SolidBrush(backColor))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// 绘制 <see cref="TreeList"/> 中的行。
 /// </summary>
 /// <param name="e"></param>
 public virtual void DrawItem(TreeListItemRenderEventArgs e)
 {
     DrawItemBackground(e);
 }
        /// <summary>
        /// 处理当前鼠标经过的对象。
        /// </summary>
        /// <param name="info"></param>
        /// <param name="drawState"></param>
        private void ProcessHitTestInfo(TreeListHitTestInfo info, DrawState drawState)
        {
            if (info.Bounds.IsEmpty)
            {
                return;
            }

            switch (info.HitTestType)
            {
            case TreeListHitTestType.Column:
                var column = (TreeListColumn)info.Element;
                using (var graphics = CreateGraphics())
                {
                    var drawArgs = new TreeListColumnRenderEventArgs(column, graphics, info.Bounds)
                    {
                        DrawState = drawState
                    };
                    graphics.KeepClip(_bound.ColumnBound, () => Renderer.DrawColumnHeader(drawArgs));
                }

                break;

            case TreeListHitTestType.ColumnSize:
                Cursor = Cursors.VSplit;
                break;

            case TreeListHitTestType.Cell:
                if (info.Owner != null)
                {
                    ProcessHitTestInfo(info.Owner, drawState);
                }

                var cell = (TreeListCell)info.Element;
                var rect = GetCellTextRectangle(cell, info.Bounds);
                ShowToolTip(cell, rect);
                break;

            case TreeListHitTestType.Item:
                if (HandCursor)
                {
                    Cursor = Cursors.Hand;
                }

                if (drawState == DrawState.Pressed || !HotTracking)
                {
                    return;
                }

                var vitem = (VirtualTreeListItem)info.Element;
                var item  = (TreeListItem)vitem.Item;
                if (item.Selected)
                {
                    return;
                }

                using (var graphics = CreateGraphics())
                {
                    var drawArgs = new TreeListItemRenderEventArgs(item, graphics, info.Bounds)
                    {
                        DrawState = drawState,
                        Alternate = vitem.Index % 2 != 0
                    };
                    DrawItem(drawArgs);
                }

                break;
            }
        }