Add grouping for Pulse
- Issue MatterHackers/MatterControl#4526 consider grouping pulse models by letter in new tree view
This commit is contained in:
parent
14f85e6953
commit
bffcb0b925
1 changed files with 31 additions and 3 deletions
|
|
@ -302,9 +302,25 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
Text = make.Key,
|
||||
};
|
||||
|
||||
|
||||
string currentGroup = "";
|
||||
|
||||
var context = treeNode;
|
||||
|
||||
foreach (var printer in make.Value.OrderBy(p => p.Key))
|
||||
{
|
||||
treeNode.Nodes.Add(new TreeNode(theme, nodeParent: treeNode)
|
||||
if (make.Key == "Pulse"
|
||||
&& currentGroup != printer.Key[0] + " Series")
|
||||
{
|
||||
currentGroup = printer.Key[0] + " Series";
|
||||
|
||||
treeNode.Nodes.Add(context = new TreeNode(theme, nodeParent: treeNode)
|
||||
{
|
||||
Text = currentGroup,
|
||||
});
|
||||
}
|
||||
|
||||
context.Nodes.Add(new TreeNode(theme, nodeParent: treeNode)
|
||||
{
|
||||
Text = printer.Key,
|
||||
Name = $"Node{make.Key}{printer.Key}",
|
||||
|
|
@ -354,7 +370,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
treeView.SelectedNode = null;
|
||||
}
|
||||
|
||||
private void FilterTree(TreeNode context, string filter, bool parentVisible, List<TreeNode> matches)
|
||||
private bool FilterTree(TreeNode context, string filter, bool parentVisible, List<TreeNode> matches)
|
||||
{
|
||||
bool hasFilterText = context.Text.IndexOf(filter, StringComparison.OrdinalIgnoreCase) != -1;
|
||||
context.Visible = hasFilterText || parentVisible;
|
||||
|
|
@ -364,6 +380,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
context.NodeParent.Visible = true;
|
||||
context.NodeParent.Expanded = true;
|
||||
context.Expanded = true;
|
||||
}
|
||||
|
||||
if (context.NodeParent != null
|
||||
|
|
@ -372,10 +389,21 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
matches.Add(context);
|
||||
}
|
||||
|
||||
bool childMatched = false;
|
||||
|
||||
foreach (var child in context.Nodes)
|
||||
{
|
||||
FilterTree(child, filter, hasFilterText, matches);
|
||||
childMatched = FilterTree(child, filter, hasFilterText || parentVisible, matches);
|
||||
}
|
||||
|
||||
bool hasMatch = childMatched || hasFilterText;
|
||||
|
||||
if (hasMatch)
|
||||
{
|
||||
context.Visible = context.Expanded = true;
|
||||
}
|
||||
|
||||
return hasMatch;
|
||||
}
|
||||
|
||||
private void ResetTree(TreeNode context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue