Detect dark mode

Detect dark mode

FRFR1426
Collaborator Collaborator
239 Views
3 Replies
Message 1 of 4

Detect dark mode

FRFR1426
Collaborator
Collaborator

Is there a way with the API to detect that the UI is in dark mode?

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Accepted solutions (1)
240 Views
3 Replies
Replies (3)
Message 2 of 4

FRFR1426
Collaborator
Collaborator

I can read /Categories/Category/Property/CurrentSkin/Value (1: Dark, 2:Light) in %AppData%\Autodesk\Autodesk Vault Professional 2023\ApplicationPreferences.xml. But I'll only be able to switch the colors on the next restart.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 3 of 4

Markus.Koechl
Autodesk
Autodesk
Accepted solution

You can read the current theme on startup and establish an event handler to react whenever the user changed it.

 

void IExplorerExtension.OnStartup(IApplication application)
{
    mApplication = application;

    mCurrentTheme = VDF.Forms.Library.CurrentTheme.ToString();
    VDF.Forms.Library.ThemeChanged += ThemeChanged;
.....
}

        private void ThemeChanged(object? sender, Library.UITheme e)
        {
            mCurrentTheme = VDF.Forms.Library.CurrentTheme.ToString().ToLower();
        }

 

 Extend the ThemChanged with your needs, like updating icons, etc..



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 4 of 4

FRFR1426
Collaborator
Collaborator

Note that this property (CurrentTheme) and this event (ThemeChanged) have been added in the 2024 version of the API. I'm on 2023...

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes