예제 #1
0
        public virtual void PaintCell(Graphics dc, 
            Rectangle cellRect,
            Node node,
            TreeListColumn column,
            TreeList.TextFormatting format,
            object data)
        {
            if (format.BackColor != Color.Transparent)
            {
                Rectangle r = cellRect;
                r.X = column.CalculatedRect.X;
                r.Width = column.CalculatedRect.Width;
                SolidBrush brush = new SolidBrush(format.BackColor);
                dc.FillRectangle(brush, r);
                brush.Dispose();
            }
            if (data != null)
            {
                cellRect = CommonTools.Util.AdjustRectangle(cellRect, format.Padding);
                //dc.DrawRectangle(Pens.Black, cellRect);

                Color color = format.ForeColor;
                if (m_owner.FocusedNode == node && Application.RenderWithVisualStyles  == false)
                    color = SystemColors.HighlightText;
                TextFormatFlags flags= TextFormatFlags.EndEllipsis | format.GetFormattingFlags();
                TextRenderer.DrawText(dc, data.ToString(), m_owner.Font, cellRect, color, flags);
            }
        }
예제 #2
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);
 }
예제 #3
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 (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();
            }
        }
예제 #4
0
        public virtual void DrawHeader(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format, bool isHot)
        {
            if (!Application.RenderWithVisualStyles)
            {
                ControlPaint.DrawButton(dc, cellRect, ButtonState.Flat);
                return;
            }
            VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
            if (isHot)
                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();
                }
                cellRect = CommonTools.Util.AdjustRectangle(cellRect, format.Padding);
                //dc.DrawRectangle(Pens.Black, cellRect);

                Color color = format.ForeColor;
                TextFormatFlags flags= TextFormatFlags.EndEllipsis | format.GetFormattingFlags();
                TextRenderer.DrawText(dc, column.Caption, column.Font, cellRect, color, flags);
            }
        }
예제 #5
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);

                Size sz = TextRenderer.MeasureText(dc, datastring, f, new Size(1000000, 10000), flags);

                int treecolumn = node.TreeColumn;
                if (treecolumn < 0)
                    treecolumn = node.OwnerView.TreeColumn;

                if (column.Index == treecolumn)
                    node.ClippedText = (sz.Width > cellRect.Width || sz.Height > cellRect.Height);

                if (disposefont != null) disposefont.Dispose();
            }
        }