public void OnXamlRendered(FrameworkElement control) { GazeInput.IsDeviceAvailableChanged += GazeInput_IsDeviceAvailableChanged; WarnUserToPlugInDevice(); var buttonControl = control.FindChild("TargetButton") as Button; if (buttonControl != null) { buttonControl.Click += TargetButton_Click; gazeButtonControl = GazeInput.GetGazeElement(buttonControl); if (gazeButtonControl == null) { gazeButtonControl = new GazeElement(); GazeInput.SetGazeElement(buttonControl, gazeButtonControl); } if (gazeButtonControl != null) { gazeButtonControl.DwellProgressFeedback += OnProgressFeedback; gazeButtonControl.Invoked += OnGazeInvoked; gazeButtonControl.StateChanged += GazeButtonControl_StateChanged; } } gazePointer = GazeInput.GetGazePointer(null); CoreWindow.GetForCurrentThread().KeyDown += (CoreWindow sender, KeyEventArgs args) => gazePointer.Click(); }
public void OnXamlRendered(FrameworkElement control) { GazeInput.IsDeviceAvailableChanged += GazeInput_IsDeviceAvailableChanged; WarnUserToPlugInDevice(); var buttonControl = control.FindChildByName("TargetButton") as Button; if (buttonControl != null) { gazeButtonControl = GazeInput.GetGazeElement(buttonControl); if (gazeButtonControl == null) { gazeButtonControl = new GazeElement(); GazeInput.SetGazeElement(buttonControl, gazeButtonControl); } if (gazeButtonControl != null) { gazeButtonControl.DwellProgressFeedback += OnProgressFeedback; gazeButtonControl.Invoked += OnGazeInvoked; gazeButtonControl.StateChanged += GazeButtonControl_StateChanged; } } }
public BlankPage1() { this.InitializeComponent(); gazePointer = GazeInput.GetGazePointer(null); gazeButtonControl = GazeInput.GetGazeElement(GazeBlock); gazeButtonControl = new GazeElement(); GazeInput.SetGazeElement(GazeBlock, gazeButtonControl); gazeButtonControl.StateChanged += GazeButtonControl_StateChanged; // Add the object to our dictionary along with a new stopwatch stopwatchesByObject.Add(gazeButtonControl, new Stopwatch());
private GazeElement GetGazeButtonControl(Control c) { GazeElement gazeButtonControl; // First try to get the control gazeButtonControl = GazeInput.GetGazeElement(c); if (gazeButtonControl != null) { return(gazeButtonControl); } // If it doesn't exist - make it gazeButtonControl = new GazeElement(); GazeInput.SetGazeElement(c, gazeButtonControl); return(gazeButtonControl); }
public async Task Init() { await App.Dispatcher.ExecuteOnUIThreadAsync(() => { var xamlItemsPanelTemplate = @"<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:g='using:Microsoft.Toolkit.Uwp.Input.GazeInteraction'> <Button HorizontalAlignment='Center' BorderBrush='#7FFFFFFF' g:GazeInput.ThresholdDuration='50' g:GazeInput.FixationDuration='350' g:GazeInput.DwellDuration='400' g:GazeInput.RepeatDelayDuration='400' g:GazeInput.DwellRepeatDuration='400' g:GazeInput.MaxDwellRepeatCount='0' Content='Gaze click here' Width='100' Height='100'/> </Grid>"; _grid = XamlReader.Load(xamlItemsPanelTemplate) as Grid; GazeInput.SetInteraction(_grid, Interaction.Enabled); GazeInput.SetIsCursorVisible(_grid, true); GazeInput.SetCursorRadius(_grid, 20); GazeInput.SetIsSwitchEnabled(_grid, false); _button = (Button)_grid.Children.First(); _button.Click += (sender, e) => { _button.Content = "Clicked"; }; var gazeButtonControl = GazeInput.GetGazeElement(_button); if (gazeButtonControl == null) { gazeButtonControl = new GazeElement(); GazeInput.SetGazeElement(_button, gazeButtonControl); } TestsPage.Instance.SetMainTestContent(_grid); }); }