Example #1
0
        public TreeViewControl(ParserRuleContext root, LittleBigCParser parser)
        {
            InitializeComponent();

            var rootViewModel = new NodeViewModel(root, null, parser);

            _treeViewModel = new TreeViewModel(rootViewModel);

            base.DataContext = _treeViewModel;
        }
Example #2
0
        public NodeViewModel(ParserRuleContext node, NodeViewModel parent, LittleBigCParser parser)
        {
            _parent = parent;
            _text = parser.RuleNames[node.RuleIndex];

            var children = new List<NodeViewModel>();

            if (node.children != null)
            {
                foreach (var child in node.children)
                {
                    NodeViewModel childItem;

                    if (child is ParserRuleContext)
                    {
                        childItem = new NodeViewModel((ParserRuleContext)child, this, parser);

                        children.Add(childItem);
                    }
                    else
                    {
                        var vocubalary = LittleBigCLexer.DefaultVocabulary;

                        childItem = new NodeViewModel(String.Format("{0}: {1}", vocubalary.GetSymbolicName(((TerminalNodeImpl)child).Symbol.Type), child.ToStringTree(parser)), this);

                        children.Add(childItem);
                    }
                }
            }

            /*
            for (int i = 0; i < node.ChildCount; i++)
            {
                if (node.GetChild<ParserRuleContext>(i) != null)
                {
                    var child = new NodeViewModel(node.GetChild<ParserRuleContext>(i), this, parser);

                    children.Add(child);
                }
                else
                {
                    var child = new NodeViewModel(node.GetChild(i).ToStringTree(parser), this);

                    children.Add(child);
                }
            }
             * */

            _children = new ReadOnlyCollection<NodeViewModel>(children);
        }
Example #3
0
 public TreeViewModel(NodeViewModel root)
 {
     _root = root;
     _rootChildren = new ReadOnlyCollection<NodeViewModel>(new List<NodeViewModel> { _root });
 }
Example #4
0
 public NodeViewModel(String text, NodeViewModel parent)
 {
     _text = text;
     _parent = parent;
 }