private void HandleAstTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeVisualizerViewModel viewModel = ViewModel;

            if (viewModel == null)
            {
                Highlight(SourceTextBox.Document, null);
                return;
            }

            TreeViewModel node = AstTreeView.SelectedItem as TreeViewModel;

            if (node == null)
            {
                Highlight(SourceTextBox.Document, null);
                return;
            }

            IToken a = viewModel.GetToken(node.Adaptor.GetTokenStartIndex(node.Tree));
            IToken b = viewModel.GetToken(node.Adaptor.GetTokenStopIndex(node.Tree));

            if (a == null || b == null)
            {
                Highlight(SourceTextBox.Document, null);
                return;
            }

            Highlight(SourceTextBox.Document, Interval.FromBounds(a.StartIndex, b.StopIndex + 1));
        }
Пример #2
0
        public BaseTreeVisualizerForm(ITreeAdaptor adaptor, object tree, ITokenStream tokenStream, string sourceText)
        {
            if (adaptor == null)
                throw new ArgumentNullException("adaptor");
            if (tree == null)
                throw new ArgumentNullException("tree");

            InitializeComponent();

            TreeVisualizerViewModel viewModel = new TreeVisualizerViewModel(adaptor, tree, tokenStream, sourceText);
            ((BaseTreeVisualizerViewControl)elementHost1.Child).ViewModel = viewModel;
        }
Пример #3
0
        public BaseTreeVisualizerForm(ITreeAdaptor adaptor, object tree, ITokenStream tokenStream, string sourceText)
        {
            if (adaptor == null)
            {
                throw new ArgumentNullException("adaptor");
            }
            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            InitializeComponent();

            TreeVisualizerViewModel viewModel = new TreeVisualizerViewModel(adaptor, tree, tokenStream, sourceText);

            ((BaseTreeVisualizerViewControl)elementHost1.Child).ViewModel = viewModel;
        }