internal static bool RemoveCommandFilter(IWpfTextView textView, TranslationCommandFilter commandFilter) { if (commandFilter == null) { return(false); } if (commandFilter.m_added) { var vsEditorAdaptersFactoryService = ServicesHelper.GetServiceFromComponentModel <IVsEditorAdaptersFactoryService>(false); //get the view adapter from the editor factory if (vsEditorAdaptersFactoryService != null) { var view = vsEditorAdaptersFactoryService.GetViewAdapter(textView); var hr = view.RemoveCommandFilter(commandFilter); if (hr == VSConstants.S_OK) { commandFilter.m_added = false; } return(true); } } return(false); }
internal static bool AddCommandFilter(IWpfTextView textView, TranslationCommandFilter commandFilter) { if (commandFilter == null) { return(false); } if (commandFilter.m_added == false) { var vsEditorAdaptersFactoryService = ServicesHelper.GetServiceFromComponentModel <IVsEditorAdaptersFactoryService>(false); //get the view adapter from the editor factory if (vsEditorAdaptersFactoryService != null) { var view = vsEditorAdaptersFactoryService.GetViewAdapter(textView); IOleCommandTarget next; var hr = view.AddCommandFilter(commandFilter, out next); if (hr == VSConstants.S_OK) { commandFilter.m_added = true; //you'll need the next target for Exec and QueryStatus if (next != null) { commandFilter.m_nextTarget = next; } } return(true); } } return(false); }
private void InvalidateState() { m_adorned = Translations != null && Translations.Any(); if (!m_adorned && TranslationCommandFilter != null) { TranslationCommandFilter.RemoveCommandFilter(_view, TranslationCommandFilter); TranslationCommandFilter = null; return; } if (m_adorned && TranslationCommandFilter == null) { TranslationCommandFilter = new TranslationCommandFilter(_view); TranslationCommandFilter.AddCommandFilter(_view, TranslationCommandFilter); } }
internal static bool RemoveCommandFilter(IWpfTextView textView, TranslationCommandFilter commandFilter) { if (commandFilter == null) return false; if (commandFilter.m_added) { var vsEditorAdaptersFactoryService = ServicesHelper.GetServiceFromComponentModel<IVsEditorAdaptersFactoryService>(false); //get the view adapter from the editor factory if (vsEditorAdaptersFactoryService != null) { var view = vsEditorAdaptersFactoryService.GetViewAdapter(textView); var hr = view.RemoveCommandFilter(commandFilter); if (hr == VSConstants.S_OK) { commandFilter.m_added = false; } return true; } } return false; }
internal static bool AddCommandFilter(IWpfTextView textView, TranslationCommandFilter commandFilter) { if (commandFilter == null) return false; if (commandFilter.m_added == false) { var vsEditorAdaptersFactoryService = ServicesHelper.GetServiceFromComponentModel<IVsEditorAdaptersFactoryService>(false); //get the view adapter from the editor factory if (vsEditorAdaptersFactoryService != null) { var view = vsEditorAdaptersFactoryService.GetViewAdapter(textView); IOleCommandTarget next; var hr = view.AddCommandFilter(commandFilter, out next); if (hr == VSConstants.S_OK) { commandFilter.m_added = true; //you'll need the next target for Exec and QueryStatus if (next != null) commandFilter.m_nextTarget = next; } return true; } } return false; }