/// <summary> /// Initializes a new instance of the <see cref="FileStructureToolWindow"/> class. /// </summary> public FileStructureToolWindow() : base(null) { // very important! otherwise XAML will not load, reporting assembly load failure Assembly.Load("FSharpFileAst"); this.astmgr = AstManager.Instance; this.Control = new FileStructureControl(); this.Control.SetModel(this.astmgr.Model); this.Control.OnNavigateToLine += this.OnNavigateToLine; // astmgr.codeanalysisreport += OnCodeAnalysisReport; // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. this.Content = this.Control; }
public void SelectNode(int lineNumber) { try { var n = FileStructureControl.FindNode(this.treeview.ItemsSource as IEnumerable <Node>, lineNumber); if (n != null) { n.IsSelected = true; } var c = this.treeview.ItemContainerGenerator.ContainerFromItem(n); } catch { } }
static Node FindNode(IEnumerable <Node> nodes, int line) { Node bestnode = null; foreach (var n in nodes) { var r = n.Astnode.Range; if (r.StartLine <= line) { bestnode = n; } else { break; } } if (bestnode == null) { return(null); } //Trace.WriteLine($"match node {bestnode.Astnode.Range}"); return(FileStructureControl.FindNode(bestnode.Children, line) ?? bestnode); }