Home Forums Software Development Use fixation to 'select' an element in WPF

Tagged: , , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7597
    Miles Bardon
    Participant

    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

    #7609
    Grant [Tobii]
    Keymaster

    Hi @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.

    #7614
    Miles Bardon
    Participant

    Hi 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

    #7622
    Grant [Tobii]
    Keymaster

    Hi @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 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.