Home › Forums › Software Development › Use fixation to 'select' an element in WPF
- This topic has 3 replies, 2 voices, and was last updated 7 years ago by Grant [Tobii].
- AuthorPosts
- 16/11/2017 at 16:11 #7597Miles BardonParticipant
Hi, I am new to developing with the 4C. I have run through the sample code and whilst it has been helpful in understanding the streams, I am struggling to work out how to use fixation on an element, such as a button or shape, which then links to a C# method.
For example: Hold gaze on one shape for X seconds, and a counter within the form increments.Thanks in advance,
Miles
19/11/2017 at 13:17 #7609Grant [Tobii]KeymasterHi @milesb, in addition to the basic samples included with the Core SDK available @ https://github.com/Tobii/CoreSDK
We have also created a series of samples to show developers how to use our Interaction API to build interactive eye tracking enabled games and applications. You can find these @ https://github.com/Tobii/interaction-samples
Here is included several methods of using fixations and gaze to select components on WPF forms amongst other things, so hopefully this should be exactly what you are looking for!
Please let us know if we can be of any further assistance.
19/11/2017 at 17:42 #7614Miles BardonParticipantHi Grant,
Thanks so much for that code, it really helped.
I have made adjustments to the WinForms GazeAwareForm to suit my purpose. Essentially I have set up a 2s timer which activates or deactivates based on whether an element has the gaze for that period.private void OnGaze(object sender, GazeAwareEventArgs e) { var panel = sender as Panel; if (panel != null) { if (e.HasGaze) { panel.BorderStyle = BorderStyle.FixedSingle; timer.Enabled = true; } else { panel.BorderStyle = BorderStyle.None; timer.Enabled = false; } } }
And to demonstrate I update a counter on the form.
private void OnTimedEvent(object source, ElapsedEventArgs e) { UpdateCounter(); } private void UpdateCounter() { if (clickCount.InvokeRequired) clickCount.Invoke((MethodInvoker)delegate { clickCount.Value++; }); else clickCount.Value++; }
This makes it possible to ‘click’ on an object completely hands-free.
What do you think of this implementation? It works in practice but is there perhaps a more elegant way you know?Many thanks again
20/11/2017 at 21:20 #7622Grant [Tobii]KeymasterHi @milesb, great job! I personally am not aware of a more elegant means of implementing the feature you seek, but what you have looks good to me 🙂
- AuthorPosts
- You must be logged in to reply to this topic.