Home Forums Software Development Finding Screen Size and units Reply To: Finding Screen Size and units

Robert [Tobii]

Hi Thomas,

I was not sure this value was exposed through the API, but there is a way (although a bit cumbersome)

1) In the EyeXHost class, add a connection changed listener (to make sure you are connected). In there, call GetSettingsAsync method on the Interaction Context:

            _context.ConnectionStateChanged += (sender, e) => 
                if (e.State == ConnectionState.Connected)
                    _context.GetSettingsAsync(SettingsPaths.EyeTracking, OnDisplaySizeSettingEvent);

2) Use this code to extract the width and height in millimeters

    private void OnDisplaySizeSettingEvent(SettingsBag settings)
        Size2 displaySize;       
        PropertyBag data = (PropertyBag)settings.Data;
        InteractionProperty eyetrackingProperty;
        data.TryGetProperty(SettingsPaths.EyeTracking, out eyetrackingProperty);
        InteractionProperty displaySizeProperty;
        ((PropertyBag)eyetrackingProperty.Value).TryGetProperty(SettingsPaths.DisplaySize, out displaySizeProperty);
        displaySize = (Size2)displaySizeProperty.GetValueAs(typeof(Size2));
        print("Display size: " + displaySize.Width + " x " + displaySize.Height + " mm");

Not the easiest way as I said, but it works for me