private IEnumerable BuildResultTree(object resultsObject, bool moreAvailable) { var results = resultsObject as ICollection <SearchResult>; if (results == null) { return(results); } var root = new Folder(); if (moreAvailable) { root.Children.Add(new ButtonNode { Text = $"Showing first {results.Count} results. Show all results instead (slow).", OnClick = () => searchLogControl.TriggerSearch(searchLogControl.SearchText, int.MaxValue) }); } root.Children.Add(new Message { Text = $"{results.Count} results. Search took: {Elapsed.ToString()}" }); foreach (var result in results) { TreeNode parent = root; if (result.Node is ParentedNode parentedNode) { var project = parentedNode.GetNearestParent <Project>(); if (project != null) { var projectProxy = root.GetOrCreateNodeWithName <ProxyNode>(project.Name); projectProxy.Original = project; if (projectProxy.Highlights.Count == 0) { projectProxy.Highlights.Add(project.Name); } parent = projectProxy; } } var proxy = new ProxyNode(); proxy.Original = result.Node; proxy.Populate(result); parent.Children.Add(proxy); } if (!root.HasChildren) { root.Children.Add(new Message { Text = "No results found." }); } return(root.Children); }
public IEnumerable BuildResultTree(object resultsObject, bool moreAvailable = false) { var folder = ResultTree.BuildResultTree(resultsObject, moreAvailable, Elapsed); if (moreAvailable) { var showAllButton = new ButtonNode { Text = $"Showing first {folder.Children.Count} results. Show all results instead (slow)." }; showAllButton.OnClick = () => { showAllButton.IsEnabled = false; searchLogControl.TriggerSearch(searchLogControl.SearchText, int.MaxValue); }; folder.AddChildAtBeginning(showAllButton); } return(folder.Children); }