internal void PaintColumnHeaders(TreeRenderer renderer, ColumnHeaderCollection columns, Graphics g, bool treeControlHeader)
        {
            ColumnHeaderRendererEventArgs ce = new ColumnHeaderRendererEventArgs();
            ce.Graphics = g;
            ce.Tree = this.Tree;
            ce.SortIndicatorColor = renderer.ColorTable.ColumnSortIndicatorColor;

            ElementStyle defaultNormalStyle = GetDefaultColumnStyleNormal(renderer);
            ElementStyle headerStyle = null;
            if(treeControlHeader)
                headerStyle = this.Tree.ColumnsBackgroundStyle == null ? GetDefaultHeaderStyle(renderer) : this.Tree.ColumnsBackgroundStyle;
            else
                headerStyle = this.Tree.NodesColumnsBackgroundStyle == null ? GetDefaultNodesHeaderStyle(renderer) : this.Tree.NodesColumnsBackgroundStyle;

            if (Tree.ColumnStyleNormal != null && Tree.ColumnStyleNormal.Custom)
                defaultNormalStyle = Tree.ColumnStyleNormal;

            Point offset = Point.Empty;
            if (this.Tree.AutoScroll)
            {
                offset = this.Tree.GetAutoScrollPositionOffset();
                if (treeControlHeader)
                    offset.Y = 0;
            }

            Rectangle columnsBounds = columns.Bounds;
            if (!treeControlHeader) columnsBounds.Offset(offset);
            ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(headerStyle, g, columnsBounds);
            ElementStyleDisplay.Paint(di);
            Color columnSeparator = (headerStyle != null && !headerStyle.BorderColor.IsEmpty) ? headerStyle.BorderColor : Color.Empty;
            for (int i = 0; i < columns.Count; i++)
            {
                ColumnHeader column = columns.ColumnAtDisplayIndex(i);
                if (!column.Visible) continue;
                ElementStyle style = null;
                if (column.StyleNormal != "")
                    style = Tree.Styles[column.StyleNormal].Copy();
                else
                    style = defaultNormalStyle.Copy();

                if (column.IsMouseDown)
                {
                    if (column.StyleMouseDown != "")
                        style.ApplyStyle(Tree.Styles[column.StyleMouseDown]);
                    else if (Tree.ColumnStyleMouseDown != null)
                        style.ApplyStyle(Tree.ColumnStyleMouseDown);
                }
                else if (column.IsMouseOver)
                {
                    if (column.StyleMouseOver != "")
                        style.ApplyStyle(Tree.Styles[column.StyleMouseOver]);
                    else if (Tree.ColumnStyleMouseOver != null)
                        style.ApplyStyle(Tree.ColumnStyleMouseOver);
                }

                ce.ColumnHeader = column;
                Rectangle columnBounds = column.Bounds;
                columnBounds.Offset(offset);
                ce.Bounds = columnBounds;
                ce.Style = style;
                renderer.DrawColumnHeader(ce);
                if (!columnSeparator.IsEmpty)
                    DisplayHelp.DrawLine(g, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Y, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Bottom - 1, columnSeparator, 1);
            }
        }
Exemple #2
0
 /// <summary>
 /// Draws the column header. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
 /// do not want default rendering to occur do not call the base implementation. You can call OnRenderColumnHeader method so events can occur.
 /// </summary>
 /// <param name="e">Information provided for rendering.</param>
 public virtual void DrawColumnHeader(ColumnHeaderRendererEventArgs e)
 {
     OnRenderColumnHeader(e);
 }
Exemple #3
0
 /// <summary>
 /// Raises RenderDragDropMarker event.
 /// </summary>
 /// <param name="e">Event data.</param>
 protected virtual void OnRenderColumnHeader(ColumnHeaderRendererEventArgs e)
 {
     if (RenderColumnHeader != null)
         RenderColumnHeader(this, e);
 }
        internal void DrawColumnHeader(ColumnHeaderRendererEventArgs e, ElementStyleDisplayInfo di)
        {
            // Adjust the header bounds so the header is filled completely
            if (e.Tree != null && e.Tree.CellHorizontalSpacing > 0 && !e.ColumnHeader.IsFirstVisible) {
                Rectangle ob = di.Bounds;
                di.Bounds = new Rectangle(ob.X - e.Tree.CellHorizontalSpacing, ob.Y, ob.Width + e.Tree.CellHorizontalSpacing, ob.Height);
                ElementStyleDisplay.Paint(di);
                di.Bounds = ob;
            }
            else
                ElementStyleDisplay.Paint(di);
            di.Bounds.Inflate(-1, -1);
            if (di.Bounds.Width > 1 && di.Bounds.Height > 1)
            {
                if (e.ColumnHeader.IsFirstVisible)
                {
                    Rectangle r = di.Bounds;
                    r.Width -= 3;
                    r.X += 3;
                    di.Bounds = r;
                }

                if (e.ColumnHeader.SortDirection != eSortDirection.None && !e.SortIndicatorColor.IsEmpty)
                {
                    using (GraphicsPath sortShapePath = UIGraphics.GetTrianglePath(
                        new Point(di.Bounds.Right - 11, di.Bounds.Y + (di.Bounds.Height - 5) / 2), 9, 
                        (e.ColumnHeader.SortDirection == eSortDirection.Ascending ? eTriangleDirection.Top : eTriangleDirection.Bottom)))
                    {
                        SmoothingMode sm = e.Graphics.SmoothingMode;
                        e.Graphics.SmoothingMode = SmoothingMode.Default;
                        using (SolidBrush brush = new SolidBrush(e.SortIndicatorColor))
                            e.Graphics.FillPath(brush, sortShapePath);
                        e.Graphics.SmoothingMode = sm;
                    }
                    di.Bounds.Width -= 12;
                }

                if (e.ColumnHeader.Image != null)
                {
                    Image image = e.ColumnHeader.Image;
                    Rectangle r = di.Bounds;
                    if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Left)
                    {
                        e.Graphics.DrawImage(image, r.X,
                                              r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
                        r.X += image.Width + 2;
                        r.Width -= image.Width + 2;

                    }
                    else if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Right)
                    {
                        e.Graphics.DrawImage(image, r.Right - image.Width,
                                              r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
                        r.Width -= image.Width + 2;
                    }
                    di.Bounds = r;
                }

                ElementStyleDisplay.PaintText(di, e.ColumnHeader.Text, e.Tree.Font);
            }
        }