From c9cca6b8d4f8d238fa3dc5a7deec12f63862959d Mon Sep 17 00:00:00 2001 From: Dean Chalk Date: Sat, 4 Apr 2020 11:41:07 +0100 Subject: [PATCH] #3210 Add GazeInput.SetCursorBrush method to change the default GazeCursor color --- .../GazeInteraction/GazeInteractionPage.xaml | 427 ++++++++++++++---- .../GazeInteractionPage.xaml.cs | 37 +- 2 files changed, 366 insertions(+), 98 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml index 799645233ae..695b5a69b95 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml @@ -1,143 +1,376 @@ - + - + - - + + + - + + + + + + + + + + + + + + - + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - + + - + - - - - + + + + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml.cs index 4f4cc0d6f40..cdb97f17f15 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml.cs @@ -3,11 +3,15 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections; +using System.Collections.Generic; using Microsoft.Toolkit.Uwp.Input.GazeInteraction; using Microsoft.Toolkit.Uwp.UI.Extensions; +using Windows.UI; using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Shapes; namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages @@ -55,10 +59,41 @@ public void OnXamlRendered(FrameworkElement control) } gazePointer = GazeInput.GetGazePointer(null); - + ResetGazeCursor(); CoreWindow.GetForCurrentThread().KeyDown += (CoreWindow sender, KeyEventArgs args) => gazePointer.Click(); } + private void ResetGazeCursor() + { + var size = GazeInput.GetCursorRadius(gazePointer.CursorElement); + gazePointer.CursorElement = new Ellipse + { + Fill = new SolidColorBrush(SelectedColor), + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top, + Width = 2 * size, + Height = 2 * size, + Margin = new Thickness(-size, -size, 0, 0), + IsHitTestVisible = false + }; + } + + private Color _selectedColor = Colors.MediumVioletRed; + + public Color SelectedColor + { + get + { + return _selectedColor; + } + + set + { + _selectedColor = value; + ResetGazeCursor(); + } + } + private void GazeInput_IsDeviceAvailableChanged(object sender, object e) { WarnUserToPlugInDevice();