Exemplo n.º 1
0
 public TextFormatting(TextFormatting aCopy)
 {
     m_alignment = aCopy.m_alignment;
     m_foreColor = aCopy.m_foreColor;
     m_backColor = aCopy.m_backColor;
     m_padding   = aCopy.m_padding;
 }
Exemplo n.º 2
0
        public virtual void PaintCellText(Graphics dc,
                                          Rectangle cellRect,
                                          Node node,
                                          TreeListColumn column,
                                          TreeList.TextFormatting format,
                                          object data)
        {
            if (data != null)
            {
                cellRect = AdjustRectangle(cellRect, format.Padding);
                //dc.DrawRectangle(Pens.Black, cellRect);

                Color color = format.ForeColor;
                if (node.ForeColor != Color.Transparent)
                {
                    color = node.ForeColor;
                }
                if (m_owner.FocusedNode == node && Application.RenderWithVisualStyles == false && m_owner.Focused)
                {
                    color = SystemColors.HighlightText;
                }
                TextFormatFlags flags = TextFormatFlags.EndEllipsis | format.GetFormattingFlags();

                Font f           = m_owner.Font;
                Font disposefont = null;

                if (node.Bold && node.Italic)
                {
                    disposefont = f = new Font(f, FontStyle.Bold | FontStyle.Italic);
                }
                else if (node.Bold)
                {
                    disposefont = f = new Font(f, FontStyle.Bold);
                }
                else if (node.Italic)
                {
                    disposefont = f = new Font(f, FontStyle.Italic);
                }

                string datastring = "";

                if (m_converter != null)
                {
                    datastring = m_converter(column, data);
                }
                else
                {
                    datastring = data.ToString();
                }

                TextRenderer.DrawText(dc, datastring, f, cellRect, color, flags);

                if (disposefont != null)
                {
                    disposefont.Dispose();
                }
            }
        }
Exemplo n.º 3
0
        public virtual void PaintCellBackground(Graphics dc,
                                                Rectangle cellRect,
                                                Node node,
                                                TreeListColumn column,
                                                TreeList.TextFormatting format,
                                                object data)
        {
            Color c = Color.Transparent;

            Point mousePoint = m_owner.PointToClient(Cursor.Position);
            Node  hoverNode  = m_owner.CalcHitNode(mousePoint);

            if (format.BackColor != Color.Transparent)
            {
                c = format.BackColor;
            }

            if (!m_owner.NodesSelection.Contains(node) && m_owner.FocusedNode != node &&
                !(hoverNode == node && m_owner.RowOptions.HoverHighlight) &&
                node.DefaultBackColor != Color.Transparent)
            {
                c = node.DefaultBackColor;
            }

            if (node.BackColor != Color.Transparent && !m_owner.NodesSelection.Contains(node) && m_owner.SelectedNode != node)
            {
                c = node.BackColor;
            }

            if (column.Index < node.IndexedBackColor.Length && node.IndexedBackColor[column.Index] != Color.Transparent)
            {
                c = node.IndexedBackColor[column.Index];
            }

            if (c != Color.Transparent)
            {
                Rectangle r = cellRect;
                r.X     -= Math.Max(0, column.CalculatedRect.Width - cellRect.Width);
                r.Width += Math.Max(0, column.CalculatedRect.Width - cellRect.Width);
                SolidBrush brush = new SolidBrush(c);
                dc.FillRectangle(brush, r);
                brush.Dispose();
            }
        }
Exemplo n.º 4
0
        public virtual void DrawHeader(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format, bool isHot, bool highlight)
        {
            Rectangle textRect = AdjustRectangle(cellRect, format.Padding);

            if (!Application.RenderWithVisualStyles)
            {
                ControlPaint.DrawButton(dc, cellRect,
                                        m_owner.ViewOptions.UserRearrangeableColumns && highlight ? ButtonState.Pushed : ButtonState.Flat);
                DrawHeaderText(dc, textRect, column, format);
                return;
            }
            VisualStyleElement element = VisualStyleElement.Header.Item.Normal;

            if (isHot || highlight)
            {
                element = VisualStyleElement.Header.Item.Hot;
            }
            if (VisualStyleRenderer.IsElementDefined(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(dc, cellRect);

                if (format.BackColor != Color.Transparent)
                {
                    SolidBrush brush = new SolidBrush(format.BackColor);
                    dc.FillRectangle(brush, cellRect);
                    brush.Dispose();
                }
                //dc.DrawRectangle(Pens.Black, cellRect);

                DrawHeaderText(dc, textRect, column, format);
            }
        }
Exemplo n.º 5
0
        public void DrawHeaderText(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format)
        {
            Color           color = format.ForeColor;
            TextFormatFlags flags = TextFormatFlags.EndEllipsis | format.GetFormattingFlags();

            TextRenderer.DrawText(dc, column.Caption, column.Font, cellRect, color, flags);
        }
Exemplo n.º 6
0
        public virtual void PaintCellPlusMinus(Graphics dc, Rectangle glyphRect, Node node, TreeListColumn column, TreeList.TextFormatting format)
        {
            if (!Application.RenderWithVisualStyles)
            {
                // find square rect first
                int diff = glyphRect.Height - glyphRect.Width;
                glyphRect.Y      += diff / 2;
                glyphRect.Height -= diff;

                // draw 8x8 box centred
                while (glyphRect.Height > 8)
                {
                    glyphRect.Height -= 2;
                    glyphRect.Y      += 1;
                    glyphRect.X      += 1;
                }

                // make a box
                glyphRect.Width = glyphRect.Height;

                // clear first
                SolidBrush brush = new SolidBrush(format.BackColor);
                if (format.BackColor == Color.Transparent)
                {
                    brush = new SolidBrush(m_owner.BackColor);
                }
                dc.FillRectangle(brush, glyphRect);
                brush.Dispose();

                // draw outline
                Pen p = new Pen(SystemColors.ControlDark);
                dc.DrawRectangle(p, glyphRect);
                p.Dispose();

                p = new Pen(SystemColors.ControlText);

                // reduce box for internal lines
                glyphRect.X     += 2; glyphRect.Y += 2;
                glyphRect.Width -= 4; glyphRect.Height -= 4;

                // draw horizontal line always
                dc.DrawLine(p, glyphRect.X, glyphRect.Y + glyphRect.Height / 2, glyphRect.X + glyphRect.Width, glyphRect.Y + glyphRect.Height / 2);

                // draw vertical line if this should be a +
                if (!node.Expanded)
                {
                    dc.DrawLine(p, glyphRect.X + glyphRect.Width / 2, glyphRect.Y, glyphRect.X + glyphRect.Width / 2, glyphRect.Y + glyphRect.Height);
                }

                p.Dispose();
                return;
            }

            VisualStyleElement element = VisualStyleElement.TreeView.Glyph.Closed;

            if (node.Expanded)
            {
                element = VisualStyleElement.TreeView.Glyph.Opened;
            }

            if (VisualStyleRenderer.IsElementDefined(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(dc, glyphRect);
            }
        }
Exemplo n.º 7
0
 public TextFormatting(TextFormatting aCopy)
 {
     m_alignment = aCopy.m_alignment;
     m_foreColor = aCopy.m_foreColor;
     m_backColor = aCopy.m_backColor;
     m_padding	= aCopy.m_padding;
 }