Home Forums Software Development Windows Form c# with 4c

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9098
    Val
    Participant

    I am having a problem with the windows form application. I implemented interactors (User Control1 and UserControl2) and routines based on ongaze events. now I also want to add the userpresence part. When I add that to my Form the UserControls stop working or should I say, stop being gaze aware.

    namespace WindowsFormsApp4
    {
    partial class Form1 : Form
    {
    private readonly FormsEyeXHost _eyeXHost;
    //Create the timer
    System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();

    public Form1()
    {
    InitializeComponent();
    Program.EyeXHost.Connect(behaviorMap1);
    _eyeXHost = new FormsEyeXHost();
    }

    protected override void OnLoad(EventArgs e)
    {
    Dispose(bool) method.
    _eyeXHost.UserPresenceChanged += EyeXHost_UserPresenceChanged;
    _eyeXHost.GazeTrackingChanged += EyeXHost_GazeTrackingChanged;

    _eyeXHost.Start();

    if (_eyeXHost.WaitUntilConnected(TimeSpan.FromSeconds(5)))
    {
    var engineVersion = _eyeXHost.GetEngineVersion().Result;
    if (engineVersion.Major != 1 || engineVersion.Major == 1 && engineVersion.Minor < 4)
    {
    _labelHasGazeTracking.ForeColor = Color.Red;
    _labelHasGazeTracking.Text = “Requires EyeX Engine 1.4”;
    }
    }
    else
    {
    MessageBox.Show(“Could not connect to EyeX engine.”);
    }
    }
    private void EyeXHost_GazeTrackingChanged(object sender, EngineStateValue<GazeTracking> e)
    {

    if (Created)
    {
    BeginInvoke(new Action(() =>
    {
    if (e.IsValid && e.Value == GazeTracking.GazeTracked)
    {
    _labelHasGazeTracking.Text = “Yes”;
    }
    else
    {
    _labelHasGazeTracking.Text = “No”;
    }
    }));
    }
    }

    private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue<UserPresence> e)
    {
    if (Created)
    {
    BeginInvoke(new Action(() => UpdateUserPresence(e)));
    }
    }

    private void UpdateUserPresence(EngineStateValue<UserPresence> value)
    {
    if (value.IsValid &&
    value.Value == UserPresence.Present)
    {

    _labelHasUserPresence.Text = “Yes”;
    }
    else
    {

    _labelHasUserPresence.Text = “No”;
    }
    }

    #9104
    Grant [Tobii]
    Keymaster

    Hi @frezval, thanks for your query. Can you kindly confirm which SDK you operating as the syntax of your code implies using the older EyeX SDK which has since been deprecated and replaced with the Tobii Core SDK. For getting started with implementing eye tracking in Windows Forms using the Core SDK, we would recommend running the WPF samples applications we include online @ https://github.com/Tobii/CoreSDK -> Interaction_Wpf_101

    If you are just getting started with the application, then we would recommend using Core SDK unless there is a reason you need to keep with the older EyeX SDK?

    That being the case, it would be beneficial if you could kindly share the project for this application that we could try and run it directly if possible. Hopefully in either case, we can get you up and running soon!

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