Skip to content

Commit d04ef1d

Browse files
committed
feat/Improve colouring chunks when expanding
1 parent b8d0d5a commit d04ef1d

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

Pure3DDataViewer/Pure3DDataViewer/FrmMain.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,8 @@ private async void TVChunks_BeforeExpand(object sender, TreeViewCancelEventArgs
23312331
var currentBatchSize = Math.Min(batchSize, childChunks.Count - i);
23322332

23332333
var newNodes = new List<TreeNode>(currentBatchSize);
2334+
var errorColours = Settings.GetErrorChunkColour();
2335+
var chunkColours = new Dictionary<Type, (Color BackColour, Color ForeColour)>();
23342336
for (var j = 0; j < currentBatchSize; j++)
23352337
{
23362338
token.ThrowIfCancellationRequested();
@@ -2343,8 +2345,25 @@ private async void TVChunks_BeforeExpand(object sender, TreeViewCancelEventArgs
23432345
{
23442346
Tag = child
23452347
};
2348+
var childType = child.GetType();
2349+
2350+
(Color BackColour, Color ForeColour) colours;
2351+
if (child.ValidateChunks().Any())
2352+
{
2353+
colours = errorColours;
2354+
}
2355+
else if (!chunkColours.TryGetValue(childType, out colours))
2356+
{
2357+
colours = Settings.GetChunkColour(childType);
2358+
chunkColours[childType] = colours;
2359+
}
2360+
2361+
if (childNode.BackColor != colours.BackColour)
2362+
childNode.BackColor = colours.BackColour;
2363+
2364+
if (childNode.ForeColor != colours.ForeColour)
2365+
childNode.ForeColor = colours.ForeColour;
23462366

2347-
ApplyNodeStyling(childNode, child, child.ValidateChunks().Any());
23482367
SubscribeNode(childNode, child);
23492368

23502369
if (child.Children.Count > 0)

0 commit comments

Comments
 (0)