Functions
Read texts at any time
A text is read with GetText.
string message = VisiWin.ApplicationFramework.ApplicationService.GetText("Messages.AppClose");
In the example shown, the text with the name AppClose from the text group UserText.Messages is written to the variable message.
Read texts on change
There are two main reasons why a text can be changed at runtime:
- Switching the language active in the project
- Change of a process variable value that was formatted into the text
The LocalisedText object contains the TextChanged event, in which the above-mentioned causes report a text change.
private void InitLocalizedTexts() { VisiWin.Language.ILanguageService languageService = VisiWin.ApplicationFramework.ApplicationService.GetService<VisiWin.Language.ILanguageService>(); VisiWin.Language.ILocalisedText defaultText = languageService.GetLocalizedText("WindowsControls", "TextBoxDefaultName"); defaultText.Changed += new EventHandler<VisiWin.Language.LocalisedTextChangedEventArgs>(defaultText_Changed); } private void defaultText_TextChange(object sender, VisiWin.LanguageSwitching.TextChangeEventArgs e) { textBoxName.Text = e.DisplayText; }
In the example shown above, the defaultText object is created and initialised so that it accesses the text TextBoxDefaultName from the WindowsControls user text group.
If the language changes, for example, the corresponding text is written to the TextBox control with the name textBoxName in the defaultText_TextChange event.