a
VERY!HARD _Question:_
It will take a while to explain it!
I am making a dictionary eng-rus (English-Russian).
I made 2 textboxes, one for writing words in eng, and another to write in rus.
the engTOrus textbox is quite simple...
When a eng char from array(literaEng) is typed in textEng(textbox), quickly is converted in the rus kind of char from literaRus array and is put inside textrus(textbox).
And for special combinations is working pretty well too(like ie,io,etc)
here is the
simple code:
string[] literaRus = new string[33] { "е", "ё","ц", "ч","ш", "щ", "ы","ю", "я", "а", "б", "в", "г", "д", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ъ", "ь", "э" };
string[] literaEng = new string[33] { "ie", "io", "tz", "ce", "sh", "ci", "ii", "iu", "ia", "a", "b", "v", "g", "d", "j", "z", "i", "y", "c", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "~", "`", "e" };
bool engisActive = false, rusIsActive = false;
private void textEng_Click(object sender, EventArgs e)
{
engisActive = true; rusIsActive = false;
}
private void textEng_TextChanged(object sender, EventArgs e)
{
if (engisActive)
{
textrus.Text = textEng.Text;
for (int i = 0; i < literaEng.Length; i++)
{
if (textrus.Text.Contains(literaEng[i]))
textrus.Text = textrus.Text.Replace(literaEng[i], literaRus[i]);
if (textrus.Text.Contains(literaEng[i].ToUpper()))
textrus.Text = textrus.Text.Replace(literaEng[i].ToUpper(), literaRus[i].ToUpper());
}
}
}
Now I have to make the same thing but backwards.
What the next code do(and should but it does not):
When I type inside textrus(textbox), I type with regular characters (English ones). Now, when this textrus see a normal char, it rapidly convert it into it's rus form of char, right? Once the text inside it is converted, I can copy to textEng only the rus converted chars.
And here is the question:
How can I copy the normal characters (and the whole text in eng), from textrus(textbox) into the textEng(textbox), after that, let it convert to rus chars, and when I must type the next char in textrus, he must allow me to see both its past converted chars(rus ones) and in the same time the new eng char(converting them as I am typing), then converting them again in eng for the textEng, and re convert to rus.
Right now, the next code transforms
only the rus chars i can put there into eng chars.(into textEng(textbox)) --- but when I write eng chars inside textrus, it is not converting anything in rus chars. How to do that?
PFFFFFFFFFFF.... its very hard to explain, though I have it very clear in my mind what i should do. Thanks and I hope I was "clear" enough. :)
here is the
HARD code:
string[] literaRus = new string[33] { "е", "ё","ц", "ч","ш", "щ", "ы","ю", "я", "а", "б", "в", "г", "д", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ъ", "ь", "э" };
string[] literaEng = new string[33] { "ie", "io", "tz", "ce", "sh", "ci", "ii", "iu", "ia", "a", "b", "v", "g", "d", "j", "z", "i", "y", "c", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "~", "`", "e" };
private void textrus_Click(object sender, EventArgs e)
{
rusIsActive = true; engisActive = false;
}
private void textrus_TextChanged(object sender, EventArgs e)
{
if (rusIsActive)
{
textEng.Text = textrus.Text;
for (int i = 0; i < literaRus.Length; i++)
{
if (textEng.Text.Contains(literaRus[i]))
textEng.Text = textEng.Text.Replace(literaRus[i], literaEng[i]);
if (textEng.Text.Contains(literaRus[i].ToUpper()))
textEng.Text = textEng.Text.Replace(literaRus[i].ToUpper(), literaEng[i].ToUpper());
}
}
}
I have an idea but im not so sure of it....using some kind of list/array algorithm, but im not so certain of its validity.