private bool ComboBoxFilter(IEditorNavigationType navigationType, EditorNavigationComboBox comboBox, IEditorNavigationTarget target) { if (navigationType == null || comboBox == null || target == null) { return(true); } if (!navigationType.Definition.EnclosingTypes.Any()) { return(true); } IEditorNavigationTarget owner; if (!_owners.TryGetValue(target, out owner)) { return(true); } return(_navigationControls.Select(i => i.Item2.SelectedItem).OfType <IEditorNavigationTarget>().Contains(owner)); }
public EditorNavigationMargin([NotNull] IWpfTextView wpfTextView, [NotNull] IEnumerable <IEditorNavigationSource> sources, [NotNull] IEditorNavigationTypeRegistryService editorNavigationTypeRegistryService) { Requires.NotNull(wpfTextView, nameof(wpfTextView)); Requires.NotNull(sources, nameof(sources)); Requires.NotNull(editorNavigationTypeRegistryService, nameof(editorNavigationTypeRegistryService)); this._wpfTextView = wpfTextView; this._sources = sources; this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService; _navigationControls = this._sources .SelectMany(source => source.GetNavigationTypes()) .Distinct() //.OrderBy(...) .Select(type => Tuple.Create(type, default(EditorNavigationComboBox))) .ToArray(); if (this._navigationControls.Length == 0) { this._container = new UniformGrid() { Visibility = Visibility.Collapsed }; return; } this._container = new UniformGrid() { Columns = _navigationControls.Length, Rows = 1 }; _navigationControls = Array.ConvertAll(_navigationControls, pair => { EditorNavigationComboBox comboBox = new EditorNavigationComboBox() { Cursor = Cursors.Arrow, ToolTip = new ToolTip() { Content = pair.Item1.Definition.DisplayName } }; comboBox.DropDownOpened += OnDropDownOpened; comboBox.SelectionChanged += OnSelectionChanged; return(Tuple.Create(pair.Item1, comboBox)); }); foreach (var controlPair in _navigationControls) { this._container.Children.Add(controlPair.Item2); } this._wpfTextView.Caret.PositionChanged += OnCaretPositionChanged; foreach (var source in this._sources) { source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh); UpdateNavigationTargets(source); } }