WPF- How to set event Up, Down, Left, Right without using the Up, Down, Left and Right Arrow Key?
I am doing HCI (Human Computer Interaction) using face tracking. I am trying to control PC using face.
I have 3x3 2 dimensional grid of button. 1 2 3 4 5 6 7 8 9
Suppose, current focus on button 5. if I press up arrow then focus will be on 2, down arro开发者_C百科w focus will be on 8 , left arrow 4 and right arrow 6.
I want to implement functionality of Up,Down,Left and Right arrow functionality without using Up,Down,Left and Right arrow key. I have already done taking left,right, up and down decision. What eventhandling, setting up tabindex and further process need to be taken?
If you are asking about how to raise Key board press events then i think you can use SendKeys Class.
I assume you want to create a program that uses Face tracking to convert user movement in to UP DOWN etc Keypress events. Above class has a method Send() method that accepts an keycode and passes the Key to Active Application.
Like:
SendKeys.Send("{UP}");//For UP arrow key
As you have already created methods for shifting focus to respective Buttons in Grid you can just Send the respective key when the Event is raised.
However FaceDetection is a Research level task and you need to implement it yourself or find some good library for raising those events it.
There's an OpenCVDotNet library that can be used to do such thing. Its actually a .Net wrapper for OpenCV library. Head over to their website and see how you van use it.
Update
To generate Key press events in WPF you make look at this SO Answer.
How can I programmatically generate keypress events in C#?
精彩评论