Esempio n. 1
0
 public TreePageViewModel(TreeNode[] nodes)
 {
     Nodes = nodes;
     _details = this.WhenAnyValue(x => x.SelectedNode)
         .Select(x => x != null ? new ControlDetailsViewModel(x.Control) : null)
         .ToProperty(this, x => x.Details);
 }
Esempio n. 2
0
 private void ExpandNode(TreeNode node)
 {
     if (node != null)
     {
         node.IsExpanded = true;
         ExpandNode(node.Parent);
     }
 }
Esempio n. 3
0
        public VisualTreeNode(IVisual visual, TreeNode parent)
            : base((Control)visual, parent)
        {
            var host = visual as IVisualTreeHost;

            if (host?.Root == null)
            {
                Children = visual.VisualChildren.CreateDerivedCollection(x => new VisualTreeNode(x, this));
            }
            else
            {
                Children = new ReactiveList<VisualTreeNode>(new[] { new VisualTreeNode(host.Root, this) });
            }

            if (Control != null)
            {
                IsInTemplate = Control.TemplatedParent != null;
            }
        }
Esempio n. 4
0
        public void SelectControl(IControl control)
        {
            var node = default(TreeNode);

            while (node == null && control != null)
            {
                node = FindNode(control);

                if (node == null)
                {
                    control = control.GetVisualParent<IControl>();
                }
            }            

            if (node != null)
            {
                SelectedNode = node;
                ExpandNode(node.Parent);
            }
        }
Esempio n. 5
0
        private TreeNode FindNode(TreeNode node, IControl control)
        {
            if (node.Control == control)
            {
                return node;
            }
            else
            {
                foreach (var child in node.Children)
                {
                    var result = FindNode(child, control);

                    if (result != null)
                    {
                        return result;
                    }
                }
            }

            return null;
        }
Esempio n. 6
0
 public LogicalTreeNode(ILogical logical, TreeNode parent)
     : base((Control)logical, parent)
 {
     Children = logical.LogicalChildren.CreateDerivedCollection(x => new LogicalTreeNode(x, this));
 }