I am writing a Visual Studio 2012/2013 Extension and for performance reasons, all the configuration values are cached.

To make changes in "Fonts and Colors" visible in real-time i need to know, when the options where changed by the user.

Is there a way to be notified if any option settings were changed by the user?

At the moment I have a workaround and use the Windows.WindowCreated event in my Initialize method:

Dispatcher.CurrentDispatcher.BeginInvoke(
    new Action( () => {
        DTE.Events.WindowEvents.WindowCreated += WindowEvents_WindowCreated;
    } ), DispatcherPriority.ApplicationIdle, null );
有帮助吗?

解决方案 3

Thanks for all the input. I think I found something useful. I have a IWpfTextViewCreationListener. I added following code lines:

[Import]
public IEditorFormatMapService FormatMapService = null; // MEF

public void TextViewCreated( IWpfTextView textView ) {
    IEditorFormatMap editorFormatMap = FormatMapService.GetEditorFormatMap( textView );
    editorFormatMap.FormatMappingChanged += FormatMapChanged;
}

void FormatMapChanged( object sender, FormatItemsEventArgs e ) {
    /* do something */
}

The FormatItemsEventArgs include all the changed fonts and colors. That is exactly what I needed.

其他提示

The event you are looking for is IEditorFormatMap::FormatMappingChanged. This will fire when a value in the "Fonts and Colors" section is changed. This interface is specific to a particular ITextView instance but you could easily aggregate it over all ITextView instances that are created.

To get this interface you will need to import IEditorFormatMapFactoryService. This service provides a mapping from ITextView -> IEditorFormatMap

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top