private void Show(Func <Node, bool> filter) { _filter = filter; var firstCategoryAdded = false; VisibleCategoriesList.Clear(); var loadingCategory = new NodePaletteCategory("..."); VisibleCategoriesList.Add(loadingCategory); new Thread(() => { foreach (var category in CategoriesList) { foreach (var node in category.Nodes) { if (filter(node)) { _diagram.View?.Dispatcher.Invoke(() => VisibleCategoriesList.Add(category)); if (!firstCategoryAdded) { _diagram.View?.Dispatcher.Invoke(() => VisibleCategoriesList.Remove(loadingCategory)); } firstCategoryAdded = true; Thread.Sleep(10); break; } } } if (!firstCategoryAdded) { _diagram.View?.Dispatcher.Invoke(() => VisibleCategoriesList.Remove(loadingCategory)); } }).Start(); }
public void ShowCategory(NodePaletteCategory category) { VisibleNodesList.Clear(); new Thread(() => { foreach (var node in category.Nodes.Where(_filter).OrderBy(n => n.Weight)) { _diagram.View?.Dispatcher.Invoke(() => VisibleNodesList.Add(node)); Thread.Sleep(10); } }).Start(); VisibleCategoriesList.ForEach(l => l.UnselectCategoryItem()); category.SelectCategoryItem(); MousedOverNode = null; }