Add treelistview custom tree lines (colour/width) and text colour

This commit is contained in:
baldurk
2016-05-27 19:29:49 +02:00
parent 54106a2108
commit a85d11643b
3 changed files with 38 additions and 6 deletions
@@ -24,7 +24,10 @@ namespace TreelistView
object m_tag = null;
bool m_bold = false;
bool m_italic = false;
float m_treeLineWidth = 0.0f;
Color m_backCol = Color.Transparent;
Color m_foreCol = Color.Transparent;
Color m_treeLineCol = Color.Transparent;
Color m_defbackCol = Color.Transparent;
Color[] m_backCols = null;
@@ -156,11 +159,26 @@ namespace TreelistView
get { return m_bold; }
set { m_bold = value; }
}
public float TreeLineWidth
{
get { return m_treeLineWidth; }
set { m_treeLineWidth = value; }
}
public Color BackColor
{
get { return m_backCol; }
set { m_backCol = value; }
}
public Color ForeColor
{
get { return m_foreCol; }
set { m_foreCol = value; }
}
public Color TreeLineColor
{
get { return m_treeLineCol; }
set { m_treeLineCol = value; }
}
public Color DefaultBackColor
{
get { return m_defbackCol; }
@@ -204,7 +204,7 @@ namespace TreelistView
node.DefaultBackColor != Color.Transparent)
c = node.DefaultBackColor;
if (node.BackColor != Color.Transparent)
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)
@@ -233,7 +233,9 @@ namespace TreelistView
cellRect = AdjustRectangle(cellRect, format.Padding);
//dc.DrawRectangle(Pens.Black, cellRect);
Color color = format.ForeColor;
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();
@@ -996,8 +996,10 @@ namespace TreelistView
int indentSize = GetIndentSize(node) + 5;
cellRect.X += indentSize;
cellRect.Width -= indentSize;
if (ViewOptions.ShowLine)
PaintLines(dc, cellRect, node);
// save rectangle for line drawing below
Rectangle lineCellRect = cellRect;
cellRect.X += lineindet;
cellRect.Width -= lineindet;
@@ -1015,7 +1017,10 @@ namespace TreelistView
Image icon = hoverNode != null && hoverNode == node ? GetHoverNodeBitmap(node) : GetNodeBitmap(node);
PaintCellBackground(dc, cellRect, node, col);
PaintCellBackground(dc, cellRect, node, col);
if (ViewOptions.ShowLine)
PaintLines(dc, lineCellRect, node);
if (SelectedImage != null && (NodesSelection.Contains(node) || FocusedNode == node))
{
@@ -1079,9 +1084,16 @@ namespace TreelistView
Node parent = node.Parent;
while (parent != null)
{
Pen linePen = null;
if (parent.TreeLineColor != Color.Transparent || parent.TreeLineWidth > 0.0f)
linePen = new Pen(parent.TreeLineColor, parent.TreeLineWidth);
cellRect.X -= ViewOptions.Indent;
dc.DrawLine(pen, cellRect.X, cellRect.Top, cellRect.X, cellRect.Bottom);
dc.DrawLine(linePen != null ? linePen : pen, cellRect.X, cellRect.Top, cellRect.X, cellRect.Bottom);
parent = parent.Parent;
if (linePen != null)
linePen.Dispose();
}
pen.Dispose();