Example #1
0
        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);
            }
        }
Example #2
0
 private void PaintGridLines(NodeDisplayContext context, ColumnHeaderCollection columnHeaderCollection, Rectangle bounds)
 {
     Color color = this.Tree.GridLinesColor.IsEmpty ? context.NodeRenderer.ColorTable.GridLines : this.Tree.GridLinesColor;
     Graphics g = context.Graphics;
     for (int i = 0; i < columnHeaderCollection.Count; i++)
     {
         ColumnHeader columnHeader = columnHeaderCollection.ColumnAtDisplayIndex(i);
         if (!columnHeader.Visible || columnHeader.Bounds.Width <= 0) continue;
         Rectangle r = columnHeader.Bounds;
         r.Offset(context.Offset);
         if (columnHeaderCollection.ParentNode == null)
         {
             r.Offset(bounds.Location);
             if (!columnHeader.CellsBackColor.IsEmpty)
             {
                 SmoothingMode oldSmoothing = g.SmoothingMode;
                 g.SmoothingMode = SmoothingMode.None;
                 Rectangle rBack = new Rectangle(r.X - 5, context.ClientRectangle.Y, r.Width + 4, context.ClientRectangle.Height);
                 using (SolidBrush brush = new SolidBrush(columnHeader.CellsBackColor))
                     g.FillRectangle(brush, rBack);
                 g.SmoothingMode = oldSmoothing;
             }
         }
         DisplayHelp.DrawLine(g, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Y, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Bottom, color, 1);
     }
 }