2024 dark theme colouring addins

2024 dark theme colouring addins

russ.green
Advocate Advocate
3,769 Views
6 Replies
Message 1 of 7

2024 dark theme colouring addins

russ.green
Advocate
Advocate

I've noticed on my production workstation running 2024.2 in dark theme that some controls in addins are getting the dark theme.   It looks terrible and quite undesirable.  Particularly when labels and checkbox text turns light on a light background.   It does not happen to any of the addins (mine or others') on my development machine.   I also have a VM used for testing where this behaviour does not occur.

 

Can anyone help understand why this might be happening?  And why would it not be happening consistently?   

 

I don't particularly want to add styling to loads of WPF controls just to prevent it, but it bothers me I can't reproduce it.

Russ Green
0 Likes
Accepted solutions (1)
3,770 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni
Accepted solution

I am not experienced in this myself, so I looked for help elsewhere. I don't know whether you noticed, but in the past, I tried using ChatGPT once or twice to answer Revit API questions with little or next to no success. Now, I passed on your question to Google Gemini. It has the advantage over ChatGPT of being more up to date and having Internet access, afaik. Here is my prompt and its response:

 

Jeremy: I have implemented a C# .NET add-in for Revit 2024. I've noticed on my production workstation running 2024.2 in dark theme that some controls in addins are getting the dark theme. It looks terrible and quite undesirable. Particularly when labels and checkbox text turns light on a light background. It does not happen to any of the addins (mine or others') on my development machine. I also have a VM used for testing where this behaviour does not occur. Why might this be happening? Why is it not happening consistently?

   

Gemini: There are several potential reasons why your Revit 2024.2 add-in is experiencing inconsistent theme behavior on your production workstation:

 

  1. Theme Inheritance:
  • Revit offers the option to use the system theme or manually set a light or dark theme.
  • Scenario: If your development and testing environments have different theme settings than your production machine, it can explain the inconsistency.
  • Solution: Check the theme settings on all machines.
    • Production: Ensure the desired theme (likely light) is chosen.
    • Development & Testing: Consider setting the theme to match production for consistency.
  1. Resource Loading:
  • Your add-in might be referencing specific resource files (e.g., colors, styles) for its UI elements.
  • Scenario: These resource files might be missing on your production machine or loaded incorrectly, leading to default dark theme styles being applied.
  • Solution: Double-check the resource file paths in your code and ensure they are accessible on all machines. Consider using Revit's built-in resource system and avoiding hardcoded paths.
  1. Custom Themes:
  • Some users might install custom themes for Revit, potentially affecting add-in appearance.
  • Scenario: If you haven't encountered this on your development or testing machines, it could be happening on the production machine specifically.
  • Solution: While not ideal, you can check if any custom themes are installed and recommend users disable them for consistent add-in behavior.
  1. WPF Theme Management:
  • If your add-in uses WPF for its UI, it might inherit unwanted themes from other applications using WPF.
  • Scenario: This could explain why other add-ins are also affected.
  • Solution: Explore options for managing themes within your add-in using WPF's theme resources and overriding inherited styles.

Additional Tips:

   

  • Consider implementing logic within your add-in to detect the current theme and adjust its own UI styles accordingly.
  • Search online resources like the Revit API forums and blogs for specific solutions related to theme management in Revit add-ins.

By investigating these potential reasons and trying the suggested solutions, you should be able to identify the root cause of the inconsistent theme behavior in your add-in and ensure a consistent user experience across different environments.

 

// End of Gemini's answer.

   

I hope this helps. Please let me know whether it does, so I can better gauge the utility of Gemini. Thank you!

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 7

russ.green
Advocate
Advocate

I'd not even looked at Gemini before.  

 

Those answers were not particularly helpful.  Tried the same question myself and got different answers. Basically, long the lines of handle the theme setting myself.

 

Fine.  I guess I'll have to.

 

I'm hoping a knowledgeable WPF type might offer some insights into why it's not happening in my test environment.  Curious as to how widespread is.  Is there something off with my production environment perhaps or is everyone running in dark mode seeing a lot of add-ins with light window backgrounds and dark mode controls on them?  

 

 

Russ Green
0 Likes
Message 4 of 7

ricaun
Advisor
Advisor

What do you mean with 'some controls in addins are getting the dark theme', in the ribbon?

 

Could you share an image? 😀

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 7

russ.green
Advocate
Advocate

Attached some screenshots of what I'm seeing.  Including one of a DiRoots window.  

Russ Green
Message 6 of 7

jeremy_tammik
Alumni
Alumni

So, not particularly helpful for your specific use case and the answer you would like to hear... that may be.

 

I am more interested in whether the answer is accurate. Afaict, it is, and you arrived at the same conclusion using different means. If your conclusion matches the suggestions made by Gemini, I am pretty happy with this result. Thank you for your confirmation. 

 

My point is that numerous basic questions raised here may possibly be automatically answered by an LLM. That has been my impression for a long time, and I took a look at implementing Q4R4 to exploit this fact back in 2017, before the enormous success of the current LLM implementations:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 7 of 7

russ.green
Advocate
Advocate

I managed to track the problem down to another addin (not one of mine) that is using ActiproSoftware.Themes.Aero.Wpf.dll.  A quick search of the docs and it seems that can change the theme of all native controls in an app from one line of code.  I've messaged the developer to let them know it doesn't just change controls in their own addin....

 

Seems a simple amount of theme in a resource dictionary in my own addin is enough to prevent it occuring.  Just setting the control background colour is enough.  I was concerned I'd have to get into complicated WPF styles.  

 

I hadn't appreciated different addins could interact like this.

 

 

Russ Green