Exemple #1
0
        /// <summary>
        /// 绘制 <see cref="TreeList"/> 的子项。
        /// </summary>
        /// <param name="e"></param>
        public virtual void DrawCell(TreeListCellRenderEventArgs e)
        {
            var drenderer = CreateDecorationRenderer(e.Cell);

            if (drenderer != null)
            {
                drenderer.DrawCell(e);
            }
        }
Exemple #2
0
        /// <summary>
        /// 绘制指定的 <see cref="TreeListCell"/> 对象。
        /// </summary>
        /// <param name="e"></param>
        public override void DrawCell(TreeListCellRenderEventArgs e)
        {
            var rect = e.Bounds;

            rect.Inflate(-1, -1);

            DrawProgressBackground(e.Graphics, e.Cell, rect);

            if (e.Cell.Value == null)
            {
                return;
            }

            rect.Inflate(-1, -1);
            var r = Convert.ToDecimal(e.Cell.Value);

            rect.Width = (int)(rect.Width * r);
            DrawProgressValueBar(e.Graphics, e.Cell, rect);
        }
Exemple #3
0
        /// <summary>
        /// 绘制指定的 <see cref="TreeListCell"/> 对象。
        /// </summary>
        /// <param name="e"></param>
        public override void DrawCell(TreeListCellRenderEventArgs e)
        {
            if (e.Cell.Value == null)
            {
                return;
            }

            var iw = Properties.Resources.start2.Width;
            var ih = Properties.Resources.start2.Height;
            var l  = e.Bounds.X + 2;
            var t  = e.Bounds.Y + (e.Bounds.Height - ih) / 2;
            var r  = Convert.ToDecimal(e.Cell.Value);

            for (var i = 0; i < r; i++)
            {
                e.Graphics.DrawImage(Properties.Resources.start2, l, t);
                l += iw + 4;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="cells">要绘制的子项。</param>
        /// <param name="bound"><see cref="TreeListItem"/> 的绘制范围。</param>
        /// <param name="drawState">绘制状态。</param>
        private void DrawCells(Graphics g, TreeListCellCollection cells, Rectangle bound, DrawState drawState)
        {
            var x         = bound.X;
            var isDrawing = false;

            foreach (var cell in cells)
            {
                if (cell.Column.Hidden)
                {
                    continue;
                }

                var rect = new Rectangle(x, bound.Top, cell.Column.Width, bound.Height);
                if (!bound.IntersectsWith(rect) && isDrawing)
                {
                    break;
                }

                rect.Inflate(-2, 0);
                var e = new TreeListCellRenderEventArgs(cell, g, rect)
                {
                    DrawState = drawState
                };

                g.KeepClip(rect, () =>
                {
                    Renderer.DrawCell(e);
                });

                if (e.Cell.Item.TreeList.ShowGridLines)
                {
                    rect.Inflate(2, 0);
                    Renderer.DrawCellGridLines(e.Graphics, rect);
                }

                x        += cell.Column.Width;
                isDrawing = true;
            }
        }
Exemple #5
0
        /// <summary>
        /// 绘制指定的 <see cref="TreeListCell"/> 对象。
        /// </summary>
        /// <param name="e"></param>
        public override void DrawCell(TreeListCellRenderEventArgs e)
        {
            var cl = e.Cell.Item.TreeList.GetColumnBound(e.Cell.Column);

            switch (e.Cell.BoxType)
            {
            case BoxType.RadioButton:
                ThemeManager.BaseRenderer.DrawRadioButton(e.Graphics, e.Bounds, e.Cell.Checked, true);
                break;

            case BoxType.CheckBox:
                ThemeManager.BaseRenderer.DrawCheckbox(e.Graphics, e.Bounds, e.Cell.Checked, false, true);
                break;
            }

            DrawCellText(e.Graphics, e.Cell, e.Bounds, e.DrawState);

            if (!e.Cell.IsValid)
            {
                DrawInvalidate(e.Graphics, e.Cell, e.Bounds);
            }
        }
Exemple #6
0
 /// <summary>
 /// 绘制指定的 <see cref="TreeListCell"/> 对象。
 /// </summary>
 /// <param name="e"></param>
 public abstract void DrawCell(TreeListCellRenderEventArgs e);
        public override void DrawCell(TreeListCellRenderEventArgs e)
        {
            var   item      = e.Cell.Item;
            var   treeList  = item.TreeList;
            var   rect      = e.Bounds;
            var   plusRect  = Rectangle.Empty;
            var   imageRect = Rectangle.Empty;
            var   checkRect = Rectangle.Empty;
            Image image     = null;

            rect = rect.ReduceRight(item.Level * treeList.Indent);

            if (treeList.ShowPlusMinus)
            {
                plusRect = new Rectangle(rect.X, rect.Top, 16, rect.Height);
                rect     = rect.ReduceRight(16);
            }

            //图标绘制区
            if (item.Items.Count > 0 || item.ShowExpanded)
            {
                if (item.Expended)
                {
                    image = treeList.UseDefaultNodeImage ? Resource.tree_folder_open : treeList.DefaultExpandNodeImage;
                }
                else if (!item.Expended || item.ShowExpanded)
                {
                    image = treeList.UseDefaultNodeImage ? Resource.tree_folder : treeList.DefaultCollapseNodeImage;
                }
            }

            image = image ?? e.Cell.Item.GetImage() ?? (treeList.UseDefaultNodeImage ? Resource.tree_file : treeList.DefaultImage);

            //画连接线段
            if (!plusRect.IsEmpty && treeList.ShowPlusMinusLines)
            {
                DrawItemPlusMinusLines(e.Graphics, plusRect, e.Cell.Item);
            }

            //画展开/收缩小图标
            if (!plusRect.IsEmpty && (item.Items.Count > 0 || item.ShowExpanded))
            {
                DrawItemPlusMinus(e.Graphics, plusRect, item.Expended);
            }

            if (treeList.ShowCheckBoxes && item.ShowBox)
            {
                var h = (rect.Height - 15) / 2;
                checkRect = new Rectangle(rect.X, rect.Top + h, 15, 15);
                rect      = rect.ReduceRight(17);
                ThemeManager.BaseRenderer.DrawCheckbox(e.Graphics, checkRect, item.Checked, item.Mixed, item.Enabled);
            }

            imageRect = image == null ? Rectangle.Empty : GetItemImageRect(image, rect);

            if (!imageRect.IsEmpty && image != null)
            {
                e.Graphics.DrawImage(image, imageRect.Middle(16, 16));
                rect = rect.ReduceRight(image.Width);
            }

            DrawCellText(e.Graphics, e.Cell, rect, e.DrawState);

            if (!e.Cell.IsValid)
            {
                DrawInvalidate(e.Graphics, e.Cell, e.Bounds);
            }
        }