public EditorNavigationMargin(IWpfTextView wpfTextView, IEnumerable<IEditorNavigationSource> sources, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService) { Contract.Requires<ArgumentNullException>(wpfTextView != null, "wpfTextView"); Contract.Requires<ArgumentNullException>(sources != null, "sources"); Contract.Requires<ArgumentNullException>(editorNavigationTypeRegistryService != null, "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); } }
public EditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, IEnumerable <IEditorNavigationSource> sources, IBufferGraphFactoryService bufferGraphFactoryService, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService) { Contract.Requires <ArgumentNullException>(codeWindow != null, "codeWindow"); Contract.Requires <ArgumentNullException>(editorAdaptersFactory != null, "editorAdaptersFactory"); Contract.Requires <ArgumentNullException>(sources != null, "sources"); Contract.Requires <ArgumentNullException>(bufferGraphFactoryService != null, "bufferGraphFactoryService"); Contract.Requires <ArgumentNullException>(editorNavigationTypeRegistryService != null, "editorNavigationTypeRegistryService"); this._codeWindow = codeWindow; this._editorAdaptersFactory = editorAdaptersFactory; this._sources = sources; this._bufferGraphFactoryService = bufferGraphFactoryService; this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService; this._currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView()); this._dispatcher = this._currentTextView.VisualElement.Dispatcher; this._imageList = new ImageList() { ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit }; _navigationControls = this._sources .SelectMany(source => source.GetNavigationTypes()) .Distinct() //.OrderBy(...) .Select(type => Tuple.Create(type, new List <IEditorNavigationTarget>())) .ToArray(); _selectedItem = new IEditorNavigationTarget[_navigationControls.Length]; if (this._navigationControls.Length == 0) { return; } IConnectionPointContainer connectionPointContainer = codeWindow as IConnectionPointContainer; if (connectionPointContainer != null) { Guid textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID; IConnectionPoint connectionPoint; connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint); if (connectionPoint != null) { connectionPoint.Advise(this, out _codeWindowEventsCookie); } } IVsTextView primaryView = codeWindow.GetPrimaryView(); if (primaryView != null) { ((IVsCodeWindowEvents)this).OnNewView(primaryView); } IVsTextView secondaryView = codeWindow.GetSecondaryView(); if (secondaryView != null) { ((IVsCodeWindowEvents)this).OnNewView(secondaryView); } foreach (var source in this._sources) { source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh); UpdateNavigationTargets(source); } _currentTextView.Caret.PositionChanged += OnCaretPositionChanged; }
public EditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, IEnumerable<IEditorNavigationSource> sources, IBufferGraphFactoryService bufferGraphFactoryService, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService) { Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow"); Contract.Requires<ArgumentNullException>(editorAdaptersFactory != null, "editorAdaptersFactory"); Contract.Requires<ArgumentNullException>(sources != null, "sources"); Contract.Requires<ArgumentNullException>(bufferGraphFactoryService != null, "bufferGraphFactoryService"); Contract.Requires<ArgumentNullException>(editorNavigationTypeRegistryService != null, "editorNavigationTypeRegistryService"); this._codeWindow = codeWindow; this._editorAdaptersFactory = editorAdaptersFactory; this._sources = sources; this._bufferGraphFactoryService = bufferGraphFactoryService; this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService; this._currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView()); this._dispatcher = this._currentTextView.VisualElement.Dispatcher; this._imageList = new ImageList() { ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit }; _navigationControls = this._sources .SelectMany(source => source.GetNavigationTypes()) .Distinct() //.OrderBy(...) .Select(type => Tuple.Create(type, new List<IEditorNavigationTarget>())) .ToArray(); _selectedItem = new IEditorNavigationTarget[_navigationControls.Length]; if (this._navigationControls.Length == 0) { return; } IConnectionPointContainer connectionPointContainer = codeWindow as IConnectionPointContainer; if (connectionPointContainer != null) { Guid textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID; IConnectionPoint connectionPoint; connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint); if (connectionPoint != null) connectionPoint.Advise(this, out _codeWindowEventsCookie); } IVsTextView primaryView = codeWindow.GetPrimaryView(); if (primaryView != null) ((IVsCodeWindowEvents)this).OnNewView(primaryView); IVsTextView secondaryView = codeWindow.GetSecondaryView(); if (secondaryView != null) ((IVsCodeWindowEvents)this).OnNewView(secondaryView); foreach (var source in this._sources) { source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh); UpdateNavigationTargets(source); } _currentTextView.Caret.PositionChanged += OnCaretPositionChanged; }
public EditorNavigationMargin(IWpfTextView wpfTextView, IEnumerable <IEditorNavigationSource> sources, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService) { Contract.Requires <ArgumentNullException>(wpfTextView != null, "wpfTextView"); Contract.Requires <ArgumentNullException>(sources != null, "sources"); Contract.Requires <ArgumentNullException>(editorNavigationTypeRegistryService != null, "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); } }