benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.71k stars 143 forks source link

Fix exception thrown when changing themes when application uses relative and absolute URIs #40

Closed Mgamerz closed 4 years ago

Mgamerz commented 4 years ago

I am using a slightly modified version of this library in my source code (as a source project), however I have not modified any of the loading code.

In my app's App.xaml I add a merged dictionary with some styles and converters I like to use all over:

image

I use relative paths, because it seems simpler to me to do it this way rather than the rather complicated absolute uri path.

When I call SetColorTheme(), the application crashes when it's trying to enumerate the resource dictionaries. ResourceLocator.SetColorScheme(Application.Current.Resources, Settings.DarkTheme ? ResourceLocator.DarkColorScheme : ResourceLocator.LightColorScheme);

Looking at the exception and the code involved, it is because it does not check if it is an absolute or relative URI before it tries to resolve an absolute URI.

image

This PR adds a check for this to prevent an exception. My code no longer throws an exception and everything works as it should.

benruehl commented 4 years ago

Looks good and makes totally sense. Thanks a lot :)