private void MyTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { DeclarationView view = null; TabItem item = (TabItem)MyTabControl.SelectedItem; if (item == null) { return; } if (item.Content is DeclarationView) { view = (DeclarationView)item.Content; } if (view != null) { CodeElementInspector.parentOfLine = view.parentOfLine; } SetQuery(query); }
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { var transformer = DataContext as CodeTransformer; if (transformer == null || transformer.transformMap.Count == 0) { return; } ITypeDeclaration itd = transformer.transformMap.Values.First(); if (itd == null) { return; } MyDeclarationView.DataContext = itd; var attributes = transformer.Transform.Context.InputAttributes; MyTabControl.Items.Clear(); TabItem firstItem = new TabItem(); firstItem.Content = MyDeclarationView; MyTabControl.Items.Add(firstItem); MyTabControl.SelectedIndex = 0; // if the output has DebugInfo attributes attached, display these as alternate tabs in the TabControl var infos = attributes.GetAll <DebugInfo>(itd); foreach (var info in infos) { if (info.Transform != transformer.Transform) { continue; } TabItem item; if (!tabItems.TryGetValue(info, out item)) { item = new TabItem(); item.Header = info.Name; if (info.Value is ITypeDeclaration || info.Value is IStatement || info.Value is Func <SourceNode> ) { var view = new DeclarationView(); view.MyListView.SelectionChanged += SelectionChanged; view.DataContext = info.Value; item.Content = view; } tabItems[info] = item; } MyTabControl.Items.Add(item); } if (MyTabControl.Items.Count > 1) { firstItem.Header = "Output"; } CodeElementInspector.attributes = attributes; // MyDeclarationView will fill in this dictionary for the CodeElementInspector to use CodeElementInspector.parentOfLine = MyDeclarationView.parentOfLine; var errors = transformer.Transform.Context.Results.ErrorsAndWarnings; ErrorsTable.ItemsSource = errors; bool showErrors = errors.Count > 0; ErrorsSplitter.Visibility = showErrors ? Visibility.Visible: Visibility.Collapsed; ErrorsRow.Height = showErrors ? new GridLength(1, GridUnitType.Star) : new GridLength(0); }