public override void DefaultVisit(TreeNodeViewModel node) { if (node == null || SortContext == null) { return; } node.ChildrenSortType = SortContext.SortType; node.ChildrenSortDirection = SortContext.SortDirection; if (node.Children.Count == 0) { return; } else if (node.Children.Count > 1) //Optimization for single element collections - do not sort and reset them { var sorted = NodesSorter.SortNodes(node.Children, SortContext.SortType, SortContext.SortDirection) ?.ToList(capacity: node.Children.Count) ?? Enumerable.Empty <TreeNodeViewModel>(); node.Children.Reset(sorted); } if (SortContext.SortDescendants) { base.DefaultVisit(node); } }
public virtual void VisitNode(TreeNodeViewModel node) { if (node != null) { node.AcceptVisitor(this); } }
public override void DefaultVisit(TreeNodeViewModel node) { if (node == null || node.Children.Count == 0) { return; } foreach (TreeNodeViewModel child in node.Children) { VisitNode(child); } }
protected void SortSubtree(TreeNodeViewModel subTreeRoot, SortType sortType, SortDirection sortDirection, bool sortDescendants) { if (subTreeRoot == null) { return; } try { SortContext = new CodeMapSortContext(sortType, sortDirection, sortDescendants); VisitNode(subTreeRoot); subTreeRoot.Tree.RefreshFlattenedNodesList(); } finally { SortContext = null; } }
protected virtual IEnumerable <TreeNodeViewModel> CreateRoots(TreeViewModel tree, bool expandRoots, CancellationToken cancellation) { if (tree.CodeMapViewModel.DocumentModel == null) { yield break; } foreach (ISemanticModel rootSemanticModel in tree.CodeMapViewModel.DocumentModel.CodeMapSemanticModels) { cancellation.ThrowIfCancellationRequested(); TreeNodeViewModel rootVM = CreateRoot(rootSemanticModel, tree, expandRoots, cancellation); if (rootVM != null) { yield return(rootVM); } } }
public override void VisitNode(TreeNodeViewModel node) { if (node == null) { return; } _recursionDepth++; try { StackGuard.EnsureSufficientExecutionStack(_recursionDepth); node.AcceptVisitor(this); } finally { _recursionDepth--; } }
public AttributeNodeViewModel(TreeNodeViewModel nodeVM, AttributeData attribute, bool isExpanded = false) : base(nodeVM?.Tree, isExpanded) { attribute.ThrowOnNull(nameof(attribute)); Attribute = attribute; int lastDotIndex = Attribute.AttributeClass.Name.LastIndexOf('.'); string attributeName = lastDotIndex >= 0 && lastDotIndex < Attribute.AttributeClass.Name.Length - 1 ? Attribute.AttributeClass.Name.Substring(lastDotIndex + 1) : Attribute.AttributeClass.Name; int lastAttributeSuffixIndex = attributeName.LastIndexOf(AttributeSuffix); bool endsWithSuffix = attributeName.Length == (lastAttributeSuffixIndex + AttributeSuffix.Length); if (lastAttributeSuffixIndex > 0 && endsWithSuffix) { attributeName = attributeName.Remove(lastAttributeSuffixIndex); } Name = $"[{attributeName}]"; }
public static TreeNodeViewModel GetChildToNavigateTo(this IGroupNodeWithCyclingNavigation groupNode) { if (groupNode?.AllowNavigation != true || groupNode.Children.Count == 0) { return(null); } int counter = 0; while (counter < groupNode.Children.Count) { TreeNodeViewModel child = groupNode.Children[groupNode.CurrentNavigationIndex]; groupNode.CurrentNavigationIndex = (groupNode.CurrentNavigationIndex + 1) % groupNode.Children.Count; if (groupNode.CanNavigateToChild(child)) { return(child); } counter++; } return(null); }
protected virtual IEnumerable <TreeNodeViewModel> CreateDacMemberCategoryChildren <TInfo>(DacMemberCategoryNodeViewModel dacMemberCategory, Func <TInfo, TreeNodeViewModel> constructor, CancellationToken cancellation) where TInfo : SymbolItem { var categorySymbols = dacMemberCategory.GetCategoryDacNodeSymbols() .OrderBy(symbol => symbol.DeclarationOrder); if (categorySymbols == null) { yield break; } foreach (TInfo info in categorySymbols) { cancellation.ThrowIfCancellationRequested(); TreeNodeViewModel childNode = constructor(info); if (childNode != null) { yield return(childNode); } } }
public IconViewModel(TreeNodeViewModel node, Icon icon) : base(node) { IconType = icon; }
public void SortSubtree(TreeNodeViewModel subTreeRoot, SortType sortType, SortDirection sortDirection) => SortSubtree(subTreeRoot, sortType, sortDirection, sortDescendants: true);
public void SortChildren(TreeNodeViewModel node, SortType sortType, SortDirection sortDirection) => SortSubtree(node, sortType, sortDirection, sortDescendants: false);
/// <summary> /// This method checks if the node can be sorted with the specified <paramref name="sortType"/> and reordered by sorting of code map nodes. /// </summary> /// <param name="node">The node view model.</param> /// <param name="sortType">Type of the sort.</param> /// <returns/> protected virtual bool IsSortTypeSupported(TreeNodeViewModel node, SortType sortType) => node switch {
public virtual void DefaultVisit(TreeNodeViewModel nodeViewModel) { }
public virtual TResult VisitNode(TreeNodeViewModel node, TInput input) => node != null ? node.AcceptVisitor(this, input) : DefaultValue;
public virtual TResult DefaultVisit(TreeNodeViewModel node, TInput input) => DefaultValue;
protected ExtraInfoViewModel(TreeNodeViewModel node) { Node = node.CheckIfNull(nameof(node)); }