I'm creating my own IntelliSense Presenter, since Visual Studio2012 support change theme, so I want my background color of the presenter can be auto-changed when the theme been changed. Is there a way to track the theme changes event, or get the current color theme of the Visual Studio?
相关问题
- Resharper 7 on VS2012 ignores assembly redirect in
- Error installing MVVMCross from nuget into a PCL
- Why can't I bind to winproc?
- Getting Sum of an SQL table column until the sum r
- How to handle pressing any keys in the user contro
相关文章
- Visual Studio Hangs on Loading UI Library
- Visual Studio 2015 JSX/ES2015 syntax highlighting
- “Csc.exe” exited with code -1073741819
- Code completion is not working for OpenCV and Pyth
- Add Fakes Assembly option missing
- Resetting Experimental instance of Visual Studio
- Is there a way within Visual Studio to easily get
- How to get intellisense for custom created classes
Just wanted to put an update just in case anyone else comes along.. @Matze and @Frank are totally right.. However in VS 2015.. they added a easy way to detect the theme change. So you need to include PlatformUI an dyou get a super easy event
You should make sure your control is disposable so you can unsubscribe from the event...
BONUS!
It also give you easy access to the colors.. even if the user has changed them from the default .. so you can do stuff like this in when set your colors
For VS 2015 this has changed, the solution @Matze has still works but you need to update the GetThemeId() function to check for the version and if it's 14.0 (VS2015) look in a different place in the registry. The way the value is stored has changed also, it's still a string but now contains other values seperated by a '*'. The theme guid is the last value in the list.
Yes, this is possible. I had to solve a similiar issue with one of my extensions... The current theme is stored in the Windows Registry; so I implemented the following utility class.
Okay; this just helps to figur out the current settings... listening for the theme changed notification is a bit trickier. After your package is loaded, you must obtain an IVsShell instance via the DTE; once you have this object you can utilize the AdviceBroadcastMessages method to subscribe for event notifications. You have to provide an object whose type implements the IVsBroadcastMessageEvents interface...
I don´t want to post the whole implementation, but the following lines might illustrate the key scenario...
Consider implementing IDisposable on that type as well, in order to be able to unsubscribe from the event source, when the package gets unloaded.
This is how I subscribe for event notifications...
Keep the value of the cookie parameter; you´ll need it to successfully unsubscribe.
Hope that helps (-: