public async void FilterOn( DependencyExplorerWindowViewModel viewModel, DependencyItem dependencyItem, bool isSourceSide) { if (!TryGetNode(viewModel.SourceNodeName, out Node sourceNode)) { message.ShowInfo( $"The source node no longer exists in the model:\n{viewModel.SourceNodeName.DisplayLongName}"); return; } if (!TryGetNode(viewModel.TargetNodeName, out Node targetNode)) { message.ShowInfo( $"The target node no longer exists in the model:\n{viewModel.TargetNodeName.DisplayLongName}"); return; } if (!TryGetNode(dependencyItem.NodeName, out Node itemNode)) { message.ShowInfo( $"The clicked node no longer exists in the model:\n{dependencyItem.NodeName.DisplayLongName}"); return; } await FilterOn(viewModel, sourceNode, targetNode, itemNode, isSourceSide); }
public DependencyItemViewModel( DependencyItem item, IItemCommands itemCommands, bool isSourceItem) { Item = item; this.itemCommands = itemCommands; this.isSourceItem = isSourceItem; SubItems = ToSubItems(item.SubItems); }
public async Task <IReadOnlyList <DependencyItem> > GetDependencyItemsAsync(Options options) { return(await Task.Run(() => { IEnumerable <Link> links = GetLinks(options); var items = CreateReferenceHierarchy(links, options); DependencyItem rootItem = items[NodeName.Root]; AddMainNodeIfNeeded(rootItem, options); return new List <DependencyItem> { rootItem }; })); }
private void AddMainNodeIfNeeded(DependencyItem rootItem, Options options) { Node mainNode = options.IsSource ? options.SourceNode : options.TargetNode; if (rootItem.SubItems.Any() || mainNode.IsRoot) { return; } DependencyItem current = rootItem; foreach (Node node in mainNode.AncestorsAndSelf().Reverse()) { DependencyItem subItem = new DependencyItem(node.Name, node.HasCode); current.AddChild(subItem); current = subItem; } }
private DependencyItem GetParentItem( IDictionary <NodeName, DependencyItem> items, Node parentNode) { if (items.TryGetValue(parentNode.Name, out DependencyItem parentItem)) { return(parentItem); } parentItem = new DependencyItem(parentNode.Name, parentNode.HasCode); if (!parentNode.IsRoot) { DependencyItem grandParentItem = GetParentItem(items, parentNode.Parent); grandParentItem.AddChild(parentItem); } items[parentNode.Name] = parentItem; return(parentItem); }
private Dictionary <NodeName, DependencyItem> CreateReferenceHierarchy( IEnumerable <Link> links, Options options) { Dictionary <NodeName, DependencyItem> items = new Dictionary <NodeName, DependencyItem>(); items[NodeName.Root] = new DependencyItem(options.SourceNode.Root.Name, false); foreach (Link link in links) { Node node = EndPoint(link, options.IsSource); if (!items.TryGetValue(node.Name, out DependencyItem item)) { DependencyItem parentItem = GetParentItem(items, node.Parent); item = new DependencyItem(node.Name, node.HasCode); parentItem.AddChild(item); items[node.Name] = item; } } return(items); }
public void AddChild(DependencyItem child) { child.Parent = this; SubItems.Add(child); }