Introduction
This is a kind of textbox with multilingual support and it is Unicode compliant. In order to display text in different languages, we must have language.xml files in the bin\language directory for each language, which is kind of the key mapping and it is very easy to prepare the XML files.
Background
In my project, I was in the need of a textbox in which we can have text of different languages with out setting the font each time?
Using the code
In the languageTextBox
class file, there is a method ProcessDialogKey(Keys keyData)
, I am overriding that method in order to trap the keyboard interrupt and to modify the display of the interrupt.
protected override bool ProcessDialogKey(Keys keyData)
{
..
..
..
_reader=new XmlTextReader("..\\language\\"+lan_name+".xml");
while(_reader.Read())
{
if(_reader.Name ==keyData.ToString().Replace(",","").Replace(" ",""))
{
valid=true;
break;
}
_reader.Read();
}
..
..
In order to map the keys, I am reading configuration data from an XML file. If it does not find the particular language.xml in its bin\language directory, it works for English as default. <_reader>
is the variable to read from the XML file: _reader = new XmlTextReader("..\\language\\"+lan_name+".xml")
.
Points of Interest
During the coding of this function I realized that we could trap any interrupt generated by the keyboard. An interesting feature of this is it just needs to compile once. That is for different languages, we just need to provide the XML of that language and it works for that language. All the glyphs related matter is taken care of by the Unicode font. In this control, I have used Arial Unicode MS true type.