I do not own C # and I am also new to this forum. However, it seems to me that if you should supplement the rene code sent by a function that queries your translation table and returns the translation text, you would get this (forgive my fight with pseudo-code - I am very fluent in vb. Net, learn the syntax soon WITH#):
Private String TranslatedWord(ByVal SelectedWord String) {
}
Then change the last part of Reneβs code ("// Show the result") as follows (suitable for my terrible problem with C #!):
private void richTextBox1_MouseMove(object sender, MouseEventArgs e) { // whitespace definition char[] whitespace = new char[] { ' ', '\r', '\n', '\t' }; int charPosition = this.richTextBox1.GetCharIndexFromPosition(e.Location); string fullText = this.richTextBox1.Text; // if we are on whitespace, exit if (whitespace.Contains(fullText[charPosition])) { return; } // find a whitespace towards the start of the text int firstWhiteSpace = charPosition; while (firstWhiteSpace > 0 && firstWhiteSpace < fullText.Length && !whitespace.Contains(fullText[firstWhiteSpace])) { firstWhiteSpace--; } if (firstWhiteSpace!=0) firstWhiteSpace++; // find the next whitespace int lastWhiteSpace = fullText.IndexOfAny(whitespace, charPosition); if (lastWhiteSpace == -1) lastWhiteSpace = fullText.Length; // substring the word out of the flat text string word = fullText.Substring( firstWhiteSpace, lastWhiteSpace - firstWhiteSpace); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //My CHanges start here, and will likely require // some tweaking . . . //Use the function I have poorly described above to retreive the //translation(s) for the current Word: string TRANSLATION = TranslatedWord(word); // show the result //Since there are so many minor but important differences between C
If this were useful, I could quickly output the vb.net code for this fast enough, but I was not going to do this if it did not help.
Hope this is helpful. I need to work a bit on learning C # and improve my understanding of posting on this forum! Getting the code to work correctly proves the complexity.,.
source share