Comments (12)
What do you want to do with the answer? The exact set or identity of themes we ship is not guaranteed to be stable across versions, so this type of code can be very fragile. Depending on your goal, we may have a suggestion for a more robust way to accomplish your goal.
from vsextensibility.
In the EFCore.Visualizer debugger visualizer I use WebView2 to display the query plan. When VS theme is set to Dark, the WebView2 background is rendered like this making the text hard to read:
When the theme is set to Light or Blue it is rendered with white background:
To fix the issue with Dark theme I tried to use CSS media feature to apply the corresponding style. However, I discovered that while the WebView2 background color depends on VS theme, the CSS media as reported by WebView2 inside the visualizer depends on the Windows color mode. So if someone has Dark mode in Windows settings but a light theme in VS or light mode in Windows but a dark theme in VS, I will still load the wrong CSS.
To workaround this issue my idea was to get the VS theme and apply the corresponding CSS. I know that it will not work if the user has a custom theme with a dark background but at least it will work for those who are using Dark theme in VS.
from vsextensibility.
As you can see when VS is in Light mode JavaScript still reports dark mode when Windows is configured to use Dark mode:
from vsextensibility.
I'm also considering VSColorTheme.GetThemedColor
and determining text color based on it but I'm not sure which value I should pass as a parameter.
from vsextensibility.
I worked around this by using VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey)
and determining whether the color is dark or not. There is a little problem with this approach: VSColorTheme.GetThemedColor
doesn't return the color of the visualizer dialog for none of the EnvironmentColors
properties.
In the case of dark theme VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey)
returns 1f1f1f
while the dialog color is 242424
from vsextensibility.
VSColorTheme.GetThemedColor is a supported way of getting color values if you cannot consume the tokens directly in your UI like you can with WPF (DynamicResource and point it at the brush key you want).
No color token in normal VS should be 242424 in the Dark theme. The editor, tool window, and window background color should be 1E1E1E. So your UI should be using that color as well. For dialogs I'd recommend EnvironmentColors.WindowColorKey (or BrushKey depending on what kind of UI the dialog is). There's also WindowTextColorKey so you don't even have to worry about knowing the theme. You'd just request those colors and pass them to your UI and they'll always work together.
Given the WPF debug adornment is present in your dialog I'd assume it's WPF, so what color token are you giving it that's resulting in 242424?
from vsextensibility.
I can't use tokens directly because I need those colors inside the HTML that I'm showing in WebView2.
I'm not giving any color token to the dialog, in fact, the dialog is shown by VS, I just return a UserControl that the dialog hosts: https://github.com/Giorgi/EFCore.Visualizer/blob/main/src/EFCore.Visualizer/EFCoreQueryableDebuggerVisualizerProvider.cs#L41
from vsextensibility.
The IEnumerable Visualizer has the same color:
from vsextensibility.
@Giorgi What's the exact type of the dialog your content is hosted in? I should be able to track down the token usage if I know the dialog type. Snoop can be used to find the control type, or even the WPF diagnostic tools in VS.
from vsextensibility.
Related Issues (20)
- Will VSIX creation be supported on Linux/macOS? HOT 2
- When using QuerySolutionAsync and Get all projects with parameter ProjectReferences it will not returns all the projects HOT 6
- [Question] Is Using .NET (Core) Class Library Projects Supported HOT 4
- Out of process debugger visualizer should allow the visualizer to be written in .net core HOT 4
- How do you get the all projects in the solution in new SDK style extension project?
- Assembly resolution fails when I add a reference to another project and try to debug HOT 2
- When using custom object sources, the `DebuggerVisualizerProviderConfiguration` property must not have a backing store. HOT 1
- Documentation for the overall Architecture for custom language. HOT 1
- Could not load file or assembly 'netstandard, Version=2.1.0.0 HOT 1
- Wizards 🧙 HOT 1
- When is 'inproc' project needed HOT 26
- Handling long running operation in VisualizerObjectSource HOT 2
- Sample request HOT 2
- DTE.ExecuteCommand and in-proc extension HOT 1
- ModifierKey / Key incompatible with VS HOT 6
- ActivationConstraint.UIContext is poorly documented and difficult to use with existing known UIContext HOT 2
- The where method can not use the debug visualizer HOT 1
- Debugger visualizer for object HOT 3
- Unable to reference Microsoft.AspNetCore.App HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vsextensibility.