private void ActivateEntries(int position) { if (_entries == null) { return; } int currentModuleIndex; _dropDownBar.GetCurrentSelection(ModuleComboBoxId, out currentModuleIndex); ModuleEntry newModule = _entries.LocateModule(position); Debug.Assert(newModule != null); MethodEntry newMethod = newModule.LocateMethod(position); int newMethodIndex = newMethod != null ? newMethod.Index : -1; if (newModule.Index != currentModuleIndex) { _dropDownBar.SetCurrentSelection(ModuleComboBoxId, newModule.Index); _dropDownBar.RefreshCombo(MethodComboBoxId, newMethodIndex); } else { int currentMethodIndex; _dropDownBar.GetCurrentSelection(MethodComboBoxId, out currentMethodIndex); if (newMethodIndex != currentMethodIndex) { _dropDownBar.SetCurrentSelection(MethodComboBoxId, newMethodIndex); } } }
/// <summary> /// Wired to parser event for when the parser has completed parsing a new tree and we need /// to update the navigation bar with the new data. /// </summary> private void ParserOnNewParseTree(object sender, EventArgs e) { if (_dropDownBar != null) { Action callback = () => { BuildModel(); int position = _textView.Caret.Position.BufferPosition.Position; ModuleEntry newModule = _entries.LocateModule(position); MethodEntry newMethod = newModule.LocateMethod(position); _dropDownBar.RefreshCombo(ModuleComboBoxId, newModule.Index); _dropDownBar.RefreshCombo(MethodComboBoxId, newMethod != null ? newMethod.Index : -1); }; _dispatcher.BeginInvoke(callback, DispatcherPriority.Background); } }