C# keyboard and word prediction - c#

I'm currently developing a C# desktop application which is a simple virtual keyboard with word prediction facility.
The prediction process will start after typing the first three letters of the word, then provide the suggestions. I need to track the caret while typing, and I tried to use richTextBox events such as SelectionChanged but it requires regular expression check and position tracking manually ( declaring variables ... ).
My questions: is there any suggestions that can help me in doing this task ? What about Listeners? are they helpful?
Note: I have no long experience with .NET framework and I didn't use Listeners before.
Also note that the input method is eye gaze ! which means non of key- events will work !
Thank you.

Will this be in WPF or WinForms? I would tackle this problem as follows. Maybe not the fastest way but worth to try until you have something else.
OnKeyDown event of your RTB check if the last char was a space. If not get whole word from last space and check against list of words and update the list on screen.
to check where the cursor is at the time in your word just do the same as above and try to get the current word and than the indexof specific key.

Related

Free Text Box width limit/wrapping

Hi I use the Free Text Box in my .net application.
I was wondering if there was a way to prevent someone typing one single huge line of text.
Can you set a wrap boundary on it?
I had a short read of the documentation, and I don't think you'll find a native way to do so.
I guess you could use the FreeTextBox.TextChanged event, and check every line in the FreeTextBox.Text property. Mind the fact that it is HTML, and you will probably have to parse it with another third party tool (doing it manually will only give you headaches).
If any of these lines has more characters than an arbitrary length you'll set, create a new line of text with the surplus character, and move the caret to this line.

how to mirror the richtextbox control in two screens [Edited]

i'm trying to mirror my Richtextbox to another screen in Pictuerbox. actually i did that but my issue is (Lets to make my question clear say that we have 2 screens (Screen A and Screen B).
I want to show the Richtextbox in Screen B. As when i open a start menu in screen A it mustn't be shown in screen B. All i want in my program is to mirror the richtextbox as a control not the whole screen.
is that possible?
I dont know if it works and i dont have time to try it but i think you need to create 2 controls. By the 1st one you check the .textChanged() and when it is triggered you update the second textbox.
Example (pseudo code):
TextboxA;
TextboxB;
If TextboxA.TextChanged()
{
TextboxB.Text() = TextboxA.Text();
}
Maybe there is an better way, but this is the way i should try when i make it for my self. Hope it helps you.
What you describe sound like two over network connected applications. I would suggest to look for a chat network app. There are lots of examples in the net. On one side you will have a server and on the other side a client. Then you transfer your text char by char or word by word over the network.

Tangram puzzle application

I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.

Highlight/bold one char in label

I'm programming IDE/interpreter/debugger for various esoteric languages. I would like to be able to bold one character at a time, in varying places (depending on code flow), for the debugger. I'm using WinForms for that. So in short, I would need to be able to bold one character of the text and send it to label. Thanks in advance.
You should have to paint/draw text using GDI API - handle paint event or override onPaint().

opentk / C# keyboard state

Using OpenTK, I'm having issues with the Keyboard State. I'm trying to use Keyboard.GetState() but it fails.
Basically what I'm trying to achieve is a single 'click'. Because the state-check is in UpdateFrames, the checks are milliseconds apart, meaning a single keypress will trigger the event multiple times.
I dont want to use KeyRepeat.False because I still want keys like W, S, A, and D to update per frame. I just want some of the keys to be single-checked
for now I switched to XNA to handle input, as I dont think th OpenTK input is fully developed yet. much easier on that side, just set up a KeyboardState and test the state of the last from with the current one. if they aren't the same, the button was just pushed.

Categories

Resources