Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DarkTreeView rendering optimization. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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