Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion DarkUI/Controls/DarkTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,10 +1262,33 @@ private void DrawNode(DarkTreeNode node, Graphics g)
}

// 5. Draw child nodes
DrawChildNodes(node, g);

}

/// <summary>
/// Recursively paints only the nodes and child nodes within the viewport.
/// </summary>
private void DrawChildNodes(DarkTreeNode node, Graphics g)
{
if (node.Expanded)
{
foreach (var childNode in node.Nodes)
DrawNode(childNode, g);
{

if (childNode.Expanded)
DrawChildNodes(childNode, g);

bool isInTopView = Viewport.Top <= childNode.FullArea.Y;
bool isWithin = childNode.FullArea.Y < Viewport.Top + Viewport.Height;
bool isPastBottomView = childNode.FullArea.Y > Viewport.Top + Viewport.Height;

if (isInTopView && isWithin)
DrawNode(childNode, g);

if (isPastBottomView)
break;
}
}
}

Expand Down