public override async void Execute(object parameter)
        {
            JsonObject obj = this.Data.JsonObject;
            await obj.TreatAsJson();

            _tree.SelectItem(obj.ViewObject).IsExpanded = true;
            if (obj.AllChildren.Count <= 10)
            {
                _tree.ExpandSubtree(obj.ViewObject, int.MaxValue);
            }
        }
Exemple #2
0
        internal void ApplyExpandRule(CustomTreeView tree)
        {
            if (_expandByRules == null)
            {
                _expandByRules = new SingularAction(tree.Dispatcher);
            }

            FileLogger.Assert(_expandByRules.Dispatcher == tree.Dispatcher);

            bool expandedSomething = false;

            _expandByRules.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Background,
                async(actionId, action) =>
            {
                foreach (JsonObject jsonObj in this.AllChildren)
                {
                    int?depth = jsonObj.Rules.ExpandChildren;
                    if (depth.HasValue)
                    {
                        tree.ExpandToItem(jsonObj.ViewObject);
                        tree.ExpandSubtree(jsonObj.ViewObject, depth.Value);
                        expandedSomething = true;
                    }
                    if (!await action.YieldAndContinue(actionId))
                    {
                        return(false);
                    }
                }

                if (!expandedSomething)
                {
                    tree.ExpandAll(this.ExpandLevelWithLessThanCount(50));
                }

                return(true);
            });
        }