1

I am making a Windows CE application in which the user can change the GUI language at runtime. I have implemented my own translation logic in the Load event of the form.

Now, I would like to update all open forms when the user changes the language. Is there a way (in Compact Framework!!) to retrieve all open forms of the application?

tshepang
  • 12,111
  • 21
  • 91
  • 136
jdetaeye
  • 183
  • 1
  • 13
  • Possible duplicate of http://stackoverflow.com/q/3202000/108847 but maybe this will help http://dandohotaru.blogspot.co.uk/2007/11/caching-opened-forms-in-net-compact.html. As a side note why are you rolling your own translation instead of using globalisation and resource files? – Fishcake Apr 23 '12 at 10:30
  • The second link looks interesting, thanks. – jdetaeye Apr 23 '12 at 11:07
  • The reason that I don't want to use the default globalization is because I want to use my own application language setting, not using the language setting from the OS. I believe that in Compact Framework the form localizable and language settings can only be used in combination with the OS language setting. – jdetaeye Apr 23 '12 at 11:20
  • @jdetaeye check http://stackoverflow.com/questions/10224740/c-sharp-windows-ce-form-translation-independent-of-os-culture-settings/10227093#10227093 on how to use a different CultureInfo than what is set in the OS. – Fredrik Ljung Apr 23 '12 at 16:13
  • Thanks for your comment. Unfortunately the possibility to change the culture in windows ce is dependent of the device's manufacturer. That is why I have my own translation logic. – jdetaeye Apr 24 '12 at 06:50

1 Answers1

3

You can create a FormManager class that you use to instantiate all of your forms. This would give the manager the opportunity to track the lifespan of those forms by listening for their Close event, and to call methods on them en masse if they utilize a common interface (say one with a OnUiLanguageChanged method).

Alternatively, you can create an object in your application that exposes an event that each Form can subscribe to. In that way, you don't need to know which forms are open. Intsead all open forms are listening for a UiLanguageChanged event as long as they aer open, and if they recieve it they can update themselves appropriately.

tcarvin
  • 10,715
  • 3
  • 31
  • 52