Code Monkey home page Code Monkey logo

Comments (12)

jekelly avatar jekelly commented on June 14, 2024

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.

Giorgi avatar Giorgi commented on June 14, 2024

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:

image

When the theme is set to Light or Blue it is rendered with white background:

image

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.

Giorgi avatar Giorgi commented on June 14, 2024

As you can see when VS is in Light mode JavaScript still reports dark mode when Windows is configured to use Dark mode:

image

from vsextensibility.

Giorgi avatar Giorgi commented on June 14, 2024

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.

Giorgi avatar Giorgi commented on June 14, 2024

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

image

image

from vsextensibility.

Newrad0603 avatar Newrad0603 commented on June 14, 2024

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.

Giorgi avatar Giorgi commented on June 14, 2024

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.

Giorgi avatar Giorgi commented on June 14, 2024

The IEnumerable Visualizer has the same color:

image

from vsextensibility.

Newrad0603 avatar Newrad0603 commented on June 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.