KeysConverter Class

  • Thread starter Thread starter Rajkiran R.B.
  • Start date Start date
R

Rajkiran R.B.

Can Anyone say me how to use the keysconverter class provided in .net
Framework 3.0

I tried searching in MSDN but I couldn't figure out what is it exactly
meant for...
 
Can Anyone say me how to use the keysconverter class provided in .net
Framework 3.0

I tried searching in MSDN but I couldn't figure out what is it exactly
meant for...

It seems to me that the documentation for the class is reasonably clear:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.keysconverter.aspx

Was there something about the description or documentation that didn't
make sense to you? What are you trying to do? What problems are you
having?

Pete
 
Well Im trying to design an .NET application which is similar to notepad
except
for which it supports multiple languages..

The Application consists of a rich textbox and a combo box

The system will have multiple keyboard languages installed.. And the
application when loading searches for the installed keyboard languages and
shows it in a combo box..

InputLanguage[] lang = new
InputLanguage[InputLanguage.InstalledInputLanguages.Count];

private void Form1_Load(object sender, EventArgs e)
{
InputLanguage.InstalledInputLanguages.CopyTo(lang, 0);
foreach (InputLanguage l in lang)
{
comboBox1.Items.Add(l.Culture.EnglishName);
}
comboBox1.SelectedIndex =
comboBox1.Items.IndexOf(InputLanguage.DefaultInputLanguage.Culture.EnglishName);
comboBox1.SelectedItem =
InputLanguage.DefaultInputLanguage.Culture.EnglishName;
}


Whenever the user changes the language then the current language is also
changed through the following code,,
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
InputLanguage.CurrentInputLanguage =
lang[comboBox1.SelectedIndex];
richTextBox1.Focus();

}

Though the input language is changed the content of the rich text box
remains unaltered...

For Example

when the Input Language Is selected as English(United States) when I press
the keys 1,2,3,4,5,6
I get in the textbox as 123456

when the input language Is selected as French (France) when I press the keys
1,2,3,4,5,6
I get in the textbox as &é"'(-

What I need is that when I change the language from English(United States)
to French (France) the text should also change from 12346 to &é"'(-

Earlier someone said me it is not possible until I record the keystrokes
that are being entered into the richtextbox..

so I m in need of a code that could do the above thing..

Thanks
Rajkiran
 
[...]
when the Input Language Is selected as English(United States) when I
press
the keys 1,2,3,4,5,6
I get in the textbox as 123456

when the input language Is selected as French (France) when I press the
keys
1,2,3,4,5,6
I get in the textbox as &é"'(-

What I need is that when I change the language from English(United
States)
to French (France) the text should also change from 12346 to &é"'(-

If I understand correctly, the text that should change is the text
displayed in the text box itself.
Earlier someone said me it is not possible until I record the keystrokes
that are being entered into the richtextbox..

That sounds about right. Not only would you need to record the
keystrokes, presumably you'd need some way to send those keystrokes
through the input language-dependent code and rebuild the text box text
from the logged keystrokes. Of course, not all keystrokes create a
character in the text box, so you also may need some way of accounting for
those (unless you literally just want to play back the user's entire input
sequence every time you need to rebuild the text box's text).

Of course, assuming this is really supposed to be a text editor, then you
still have the problem of what to do with saving or loading a text file.
It's one thing to maintain all this meta-data about the inputed text
during your program's execution. But it's not like you can save that
meta-data with the text file.

It seems to me that for a variety of reasons, you might find it's more
productive to somehow come up with a mapping for characters generated with
the input in one language to those generated for the same input in another
language. Unfortunately, I expect that may be fraught with pitfalls as
well, given that keyboard input and text characters don't really have a
one-to-one mapping (in spite of their close relevance to each other).

In any case, the KeysConverter class is, according to the documentation,
mainly used for translating the _names_ of the Keys instances, not the
generated text itself. There might be some overlap there, but I doubt
it's actually going to do what you want here.

Pete
 
Thanks for the reply there.. Well can u please help in recording he
keystrokes...

and I tried the sendkeys method from the
Microsoft.VisualBasic.Devices.Keyword class.. However I ended up in getting
the same text again..

I would like to know how to capture the keystrokes and send it back as an
input to the richtext...

Assuming that all the text will be Entered manually and no pasting are
loading from file is implemented...

I used the following but I noticed that it captures only the character and
not the keystroke itself..

System.Collections.Queue keyobj = new System.Collections.Queue();


private void richTextBox1_KeyPress(object sender, KeyPressEventArgs
e)
{
keyobj.Enqueue(e.KeyChar);
}
 
Rajkiran R.B. said:
Thanks for the reply there.. Well can u please help in recording he
keystrokes...

and I tried the sendkeys method from the
Microsoft.VisualBasic.Devices.Keyword class.. However I ended up in getting
the same text again..

I'm not familiar with that class. The SendKeys that I refered to would be
Windows.Forms.SendKeys.
 
Thanks for the reply there.. Well can u please help in recording he
keystrokes...

Keep in mind that I basically know nothing about the things you're trying
to solve. All I can comment on is what I read in the documentation and
whether what someone else says _seems_ to make sense (I have no way to
know for sure it does or does not).
and I tried the sendkeys method from the
Microsoft.VisualBasic.Devices.Keyword class.. However I ended up in
getting the same text again..
[...]
I used the following but I noticed that it captures only the character
and not the keystroke itself..

Well, I don't know whether the difference between the SendKeys() you're
using and the SendKeys() in the Forms namespace is significant. However,
at the very least I would expect that you'd need to use the KeyDown event,
rather than the KeyPress. By the time the data gets to KeyPress, it's
already been translated into an actual character. You seem to be wanting
to tie the input to the actual key being pressed, and the KeyDown event is
what provides that information.

Whether you'll be able to use that data with any version of SendKeys() I
can't say.

Pete
 
Back
Top