Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe detection of current theme #108

Closed
GeertvanHorrik opened this issue Apr 27, 2020 · 6 comments · Fixed by #109
Closed

Safe detection of current theme #108

GeertvanHorrik opened this issue Apr 27, 2020 · 6 comments · Fixed by #109
Assignees
Milestone

Comments

@GeertvanHorrik
Copy link
Contributor

I am trying to move theme management in Orchestra to ControlzEx. However, when calling ChangeTheme, it is trying to detect the old theme. In this case, there is no old theme, but it still fails because of exceptions (failed to find resources).

Will figure out what's causing this. But even if this is a broken ResourceDictionary, shouldn't that be caught as exception and ignored?

@GeertvanHorrik
Copy link
Contributor Author

image

@GeertvanHorrik
Copy link
Contributor Author

And would it be interesting to cache the result for ResourceDictionary instances that have a source?

@batzen
Copy link
Member

batzen commented Apr 27, 2020

I could add code to prevent that exception there, but it would surface somewhere else pretty quickly i guess. But it would, at least, prevent people from blaming ControlzEx.

And would it be interesting to cache the result for ResourceDictionary instances that have a source?

What do you mean with that? Did you observe any performance issues?

@GeertvanHorrik
Copy link
Contributor Author

Not really noticed performance issues, but seeing the same sources multiple times. And since it goes through all keys, it could be "slow"?

@GeertvanHorrik
Copy link
Contributor Author

Without caching: [Orchestra.Theming.ThemeManager] [1] [METHODTIMER] ThemeManager.ChangeTheme took '96' ms

Let me fork and try with caching.

@GeertvanHorrik
Copy link
Contributor Author

Once a theme has been loaded, it makes no difference (since it can find the theme dictionary super fast). But at app startup, when no theme is loaded (at least in Orchestra, but I see callstacks from Fluent.Ribbon as well), it goes through all existing resource dictionaries (and it seems per library theme provider).

I've written some caching (which does get hit, so that's a win, just not sure about the "trade-off"). I am happy to add error checking here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants