示例#1
0
 private void setDwellAllButtons(object uiElement, int dwellMillis)
 {
     if (uiElement is Button)
     {
         GazeInput.SetDwellDuration((Button)uiElement, new TimeSpan(0, 0, 0, 0, dwellMillis));
     }
     else if (uiElement is Panel)
     {
         var uiElementAsCollection = (Panel)uiElement;
         foreach (var element in uiElementAsCollection.Children)
         {
             setDwellAllButtons(element, dwellMillis);
         }
     }
     else if (uiElement is UserControl)
     {
         var uiElementAsUserControl = (UserControl)uiElement;
         setDwellAllButtons(uiElementAsUserControl.Content, dwellMillis);
     }
     else if (uiElement is ContentControl)
     {
         var uiElementAsContentControl = (ContentControl)uiElement;
         setDwellAllButtons(uiElementAsContentControl.Content, dwellMillis);
     }
 }
示例#2
0
        private void OnPause(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (_interactionPaused)
            {
                PauseButtonText.Text         = "\uE769";
                PauseButtonBorder.Background = _toolButtonBrush;
                GazeInput.SetInteraction(MazeGrid, Interaction.Enabled);
                GazeInput.SetInteraction(SolveButton, Interaction.Enabled);

                _interactionPaused = false;
                if (_isMazeSolved)
                {
                    ResetMaze();
                }
            }
            else
            {
                PauseButtonText.Text         = "\uE768";
                PauseButtonBorder.Background = _pausedButtonBrush;
                GazeInput.SetInteraction(MazeGrid, Interaction.Disabled);
                GazeInput.SetInteraction(SolveButton, Interaction.Disabled);

                _interactionPaused = true;
            }
        }
示例#3
0
        private void FlipBatchAnimation_Completed(object sender, CompositionBatchCompletedEventArgs args)
        {
            _animationActive = false;

            if (_secondButton == null)
            {
                return;
            }

            if (_secondButton.Tag.ToString() != _firstButton.Tag.ToString())
            {
                GazeInput.SetInteraction(buttonMatrix, Interaction.Disabled);
                _flashTimer.Start();
            }
            else
            {
                //Do Match confirmation animation

                PulseButton(_firstButton);
                PulseButton(_secondButton);


                _firstButton  = null;
                _secondButton = null;
                _remaining   -= 2;

                CheckGameCompletion();
            }
        }
示例#4
0
    //1.Normalize health and scale. as health decreases, the scale should also decreases
    //2.Create money for asteroid based on scale, money is fixed for small,medium and large asteroids
    #endregion

    void Start()
    {
        gameObject.tag             = "Asteroid";
        asteroidMesh               = asteroidObj.GetComponent <MeshRenderer>();
        asteroidTransform          = GetComponent <Transform>();
        gazeInput                  = GetComponent <GazeInput>();
        asteroidCanvas.worldCamera = ScreenManager.instance.uiCamera;

        //set random scale
        float randomScaleX = Random.Range(0.5f, 3);
        float randomScaleZ = Random.Range(0.5f, 3);
        float randomScaleY = Random.Range(randomScaleX, randomScaleZ);

        asteroidTransform.localScale = new Vector3(randomScaleX, randomScaleY, randomScaleZ);

        health = Random.Range(50, 100);
        if (movementSpeed != 0)
        {
            movementSpeed = Random.Range(60, 120);
        }
        if (HealthSet != null)
        {
            HealthSet.Invoke();
        }
        healthSteps = health / gazeInput.gazeTime;

        gazeInput.PointerEnter.AddListener(DecreaseHealth);
        gazeInput.PointerExit.AddListener(HideHealthBar);

        //set laser
        laser = LaserController.instance;

        //hide health
        healthBar.enabled = false;
    }
示例#5
0
        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();
        }
示例#6
0
 public async Task Cleanup()
 {
     await App.Dispatcher.EnqueueAsync(() =>
     {
         GazeInput.SetInteraction(_grid, Interaction.Disabled);
     });
 }
示例#7
0
        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 MainPage()
        {
            InitializeComponent();
            Loaded += MainPage_Loaded;

            MasterViewModel = new ViewModel();

            var sharedSettings = new ValueSet();

            GazeSettingsHelper.RetrieveSharedSettings(sharedSettings).Completed = new AsyncActionCompletedHandler((asyncInfo, asyncStatus) =>
            {
                var gazePointer = GazeInput.GetGazePointer(this);
                gazePointer.LoadSettings(sharedSettings);
            });

            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;

            SetPageMode(PageMode.Run);
            _speechSynthesizer  = new SpeechSynthesizer();
            _mediaElement       = new MediaElement();
            _backgroundBrush    = new SolidColorBrush(Colors.Gray);
            _foregroundBrush    = new SolidColorBrush(Colors.Blue);
            _transparentBrush   = new SolidColorBrush(Colors.Transparent);
            _dwellProgressBrush = (SolidColorBrush)GazeInput.DwellFeedbackProgressBrush;

            gazePointer = GazeInput.GetGazePointer(null);

            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
        }
 public async Task Cleanup()
 {
     await App.Dispatcher.ExecuteOnUIThreadAsync(() =>
     {
         GazeInput.SetInteraction(_grid, Interaction.Disabled);
     });
 }
 private void ShowCursor_Toggle(object sender, RoutedEventArgs e)
 {
     if (ShowCursor.IsChecked.HasValue)
     {
         GazeInput.SetIsCursorVisible(this, ShowCursor.IsChecked.Value);
     }
 }
示例#11
0
        private void OnFlashTimerTick(object sender, object e)
        {
            _reverseAnimationActive = true;

            //Flip button visual
            var btn1Visual = ElementCompositionPreview.GetElementVisual(_firstButton);
            var btn2Visual = ElementCompositionPreview.GetElementVisual(_secondButton);
            var compositor = btn1Visual.Compositor;

            //Get a visual for the content
            var btn1Content       = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(_firstButton, 0), 0);
            var btn1ContentVisual = ElementCompositionPreview.GetElementVisual(btn1Content as FrameworkElement);
            var btn2Content       = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(_secondButton, 0), 0);
            var btn2ContentVisual = ElementCompositionPreview.GetElementVisual(btn2Content as FrameworkElement);

            var easing = compositor.CreateLinearEasingFunction();

            if (_reverseFlipBatchAnimation != null)
            {
                _reverseFlipBatchAnimation.Completed -= ReverseFlipBatchAnimation_Completed;
                _reverseFlipBatchAnimation.Dispose();
            }

            _reverseFlipBatchAnimation            = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
            _reverseFlipBatchAnimation.Completed += ReverseFlipBatchAnimation_Completed;

            ScalarKeyFrameAnimation flipAnimation = compositor.CreateScalarKeyFrameAnimation();

            flipAnimation.InsertKeyFrame(0.000001f, 0);
            flipAnimation.InsertKeyFrame(0.999999f, -180, easing);
            flipAnimation.InsertKeyFrame(1f, 0);
            flipAnimation.Duration          = TimeSpan.FromMilliseconds(400);
            flipAnimation.IterationBehavior = AnimationIterationBehavior.Count;
            flipAnimation.IterationCount    = 1;
            btn1Visual.CenterPoint          = new Vector3((float)(0.5 * _firstButton.ActualWidth), (float)(0.5f * _firstButton.ActualHeight), 0f);
            btn1Visual.RotationAxis         = new Vector3(0.0f, 1f, 0f);
            btn2Visual.CenterPoint          = new Vector3((float)(0.5 * _secondButton.ActualWidth), (float)(0.5f * _secondButton.ActualHeight), 0f);
            btn2Visual.RotationAxis         = new Vector3(0.0f, 1f, 0f);

            ScalarKeyFrameAnimation appearAnimation = compositor.CreateScalarKeyFrameAnimation();

            appearAnimation.InsertKeyFrame(0.0f, 1);
            appearAnimation.InsertKeyFrame(0.399999f, 1);
            appearAnimation.InsertKeyFrame(0.4f, 0);
            appearAnimation.InsertKeyFrame(1f, 0);
            appearAnimation.Duration          = TimeSpan.FromMilliseconds(400);
            appearAnimation.IterationBehavior = AnimationIterationBehavior.Count;
            appearAnimation.IterationCount    = 1;

            btn1Visual.StartAnimation(nameof(btn1Visual.RotationAngleInDegrees), flipAnimation);
            btn2Visual.StartAnimation(nameof(btn2Visual.RotationAngleInDegrees), flipAnimation);
            btn1ContentVisual.StartAnimation(nameof(btn1ContentVisual.Opacity), appearAnimation);
            btn2ContentVisual.StartAnimation(nameof(btn2ContentVisual.Opacity), appearAnimation);
            _reverseFlipBatchAnimation.End();

            _flashTimer.Stop();
            GazeInput.SetInteraction(buttonMatrix, Interaction.Enabled);
        }
示例#12
0
 /// <summary>
 /// Creates a new PianoPage (home page for playing music)
 /// </summary>
 public PianoPage()
 {
     InitializeComponent();
     GazeInput.SetIsCursorVisible(this, true);
     this.CurrentMode = PianoMode.SingleNote;
     LoadNotesAndChords();
     this.Octave             = 3;
     this.CurrentOctave.Text = "Octave " + this.Octave;
 }
示例#13
0
    void Awake()
    {
        if (gazeInput == null)
        {
            gazeInput = FindObjectOfType(typeof(GazeInput)) as GazeInput;
        }

        D.Assert(gazePointer, "Please set the gaze pointer");
    }
示例#14
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     GazeInput.SetIsCursorVisible(this, false);
     GazeInput.SetCursorRadius(this, 40);
     GazeInput.DwellStrokeThickness       = 6;
     GazeInput.DwellFeedbackEnterBrush    = new SolidColorBrush(Colors.DarkGray);
     GazeInput.DwellFeedbackProgressBrush = new SolidColorBrush(Colors.LightGray);
     GazeInput.DwellFeedbackCompleteBrush = new SolidColorBrush(Colors.White);
 }
        public MainPage()
        {
            this.InitializeComponent();

            ShowCursor.IsChecked = GazeInput.GetIsCursorVisible(this);

            GazeInput.IsDeviceAvailableChanged += GazeInput_IsDeviceAvailableChanged;
            GazeInput_IsDeviceAvailableChanged(null, null);
        }
示例#16
0
        public MainPage()
        {
            this.InitializeComponent();
            _numRows = MIN_ROWS;

            _mazeRunner = new Image
            {
                Source            = new BitmapImage(new Uri(this.BaseUri, "/Assets/luna.png")),
                VerticalAlignment = VerticalAlignment.Center
            };

            _mazeEnd = new Image
            {
                Source            = new BitmapImage(new Uri(this.BaseUri, "/Assets/doghouse.png")),
                VerticalAlignment = VerticalAlignment.Center
            };

            _mazeComplete = new Image
            {
                Source            = new BitmapImage(new Uri(this.BaseUri, "/Assets/dogInHouse.png")),
                VerticalAlignment = VerticalAlignment.Center
            };

            _newSolidBorderThickness = new Thickness(_borderThickness);
            _newButtonStyle          = (Style)this.Resources["MazeCellStyle"];

            _mazeCreator = Creator.GetCreator();

            _solutionTimer          = new DispatcherTimer();
            _solutionTimer.Interval = TimeSpan.FromSeconds(0.1);
            _solutionTimer.Tick    += OnSolutionTimerTick;

            _cellCreationTimer          = new DispatcherTimer();
            _cellCreationTimer.Interval = TimeSpan.FromMilliseconds(50);
            _cellCreationTimer.Tick    += OnCellCreationTimer_Tick;

            _openCellTimer          = new DispatcherTimer();
            _openCellTimer.Interval = TimeSpan.FromMilliseconds(50);
            _openCellTimer.Tick    += OnOpenCellTimer_Tick;

            _mazeCells   = new List <Point>();
            _breadCrumbs = new List <Point>();

            Loaded += MainPage_Loaded;

            CoreWindow.GetForCurrentThread().KeyDown += new Windows.Foundation.TypedEventHandler <CoreWindow, KeyEventArgs>(delegate(CoreWindow sender, KeyEventArgs args) {
                GazeInput.GetGazePointer(this).Click();
            });

            var sharedSettings = new ValueSet();

            GazeSettingsHelper.RetrieveSharedSettings(sharedSettings).Completed = new AsyncActionCompletedHandler((asyncInfo, asyncStatus) =>
            {
                GazeInput.LoadSettings(sharedSettings);
            });
        }
示例#17
0
        async void ResetBoard()
        {
            PlayAgainText.Visibility = Visibility.Collapsed;
            _gameOver               = false;
            _firstButton            = null;
            _secondButton           = null;
            _numMoves               = 0;
            MoveCountTextBlock.Text = _numMoves.ToString();
            _remaining              = _boardRows * _boardColumns;
            var pairs = (_boardRows * _boardColumns) / 2;

            List <string> listContent;

            if (_usePictures)
            {
                try
                {
                    listContent = await GetPicturesContent(pairs);
                }
                catch
                {
                    listContent  = GetSymbolContent(pairs);
                    _usePictures = false;
                }
            }
            else
            {
                listContent = GetSymbolContent(pairs);
            }

            List <Button> listButtons = ShuffleList(GetButtonList());

            var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            if (_resetBatchAnimation != null)
            {
                _resetBatchAnimation.Completed -= ResetBatchAnimation_Completed;
                _resetBatchAnimation.Dispose();
            }

            _resetBatchAnimation            = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
            _resetBatchAnimation.Completed += ResetBatchAnimation_Completed;;

            foreach (Button button in listButtons)
            {
                FlipCardFaceDown(button);
                GazeInput.SetInteraction(button, Interaction.Inherited);
            }
            _resetBatchAnimation.End();

            for (int i = 0; i < _boardRows * _boardColumns; i += 2)
            {
                listButtons[i].Tag     = listContent[i / 2];
                listButtons[i + 1].Tag = listContent[i / 2];
            }
        }
 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());
示例#19
0
 private void SlideBatchAnimation_Completed(object sender, CompositionBatchCompletedEventArgs args)
 {
     CheckCompletionAsync();
     if (!_gameOver)
     {
         _animationActive = false;
         GazeInput.SetInteraction(GameGrid, Interaction.Enabled);
         GazeInput.DwellFeedbackProgressBrush = new SolidColorBrush(Colors.White);
     }
 }
        public GamePage()
        {
            InitializeComponent();

            var sharedSettings = new ValueSet();

            GazeSettingsHelper.RetrieveSharedSettings(sharedSettings).Completed = new AsyncActionCompletedHandler((asyncInfo, asyncStatus) => {
                var gazePointer = GazeInput.GetGazePointer(this);
                gazePointer.LoadSettings(sharedSettings);
            });

            Loaded += GamePage_Loaded;
        }
示例#21
0
        private void PauseButton_Click(object sender, RoutedEventArgs e)
        {
            isPaused = !isPaused;
            if (isPaused)
            {
                PauseButton.Content           = "\uE768";
                BacktoStartButton.IsEnabled   = false;
                ShowSolutionButton.IsEnabled  = false;
                _ConfirmGuessButton.IsEnabled = false;

                GazeInput.SetInteraction(PaletteGrid, Interaction.Disabled);
                GazeInput.SetInteraction(CircleGrid, Interaction.Disabled);
                foreach (var child in CircleGrid.Children)
                {
                    Button b = child as Button;
                    if (b != null)
                    {
                        b.IsEnabled = false;
                    }
                }
                foreach (var child in PaletteGrid.Children)
                {
                    Button b = child as Button;
                    b.IsEnabled = false;
                }
            }
            else
            {
                PauseButton.Content           = "\uE769";
                BacktoStartButton.IsEnabled   = true;
                ShowSolutionButton.IsEnabled  = true;
                _ConfirmGuessButton.IsEnabled = true;

                GazeInput.SetInteraction(PaletteGrid, Interaction.Enabled);
                GazeInput.SetInteraction(CircleGrid, Interaction.Enabled);
                foreach (var child in CircleGrid.Children)
                {
                    Button b = child as Button;
                    if (b != null)
                    {
                        b.IsEnabled = true;
                    }
                }
                foreach (var child in PaletteGrid.Children)
                {
                    Button b = child as Button;
                    b.IsEnabled = true;
                }
            }
        }
示例#22
0
        private void OnMouseLeftClick(object sender, EventArgs e)
        {
            if (!_targetting)
            {
                _targetting        = true;
                _sampleCount       = 0;
                _sampleTail        = 0;
                _isArmed           = false;
                GazeInput.HitTest += OnHitTest;

                //var cursor = new Canvas();
                //cursor.Children.Add(new Ellipse
                //{
                //    Width = 50,
                //    Height = 50,
                //    Margin = new Thickness(-25),
                //    Stroke = Brushes.Green
                //});
                //cursor.Children.Add(new Line
                //{
                //    X1 = -25,
                //    X2 = 25,
                //    Y1 = 0,
                //    Y2 = 0,
                //    Stroke = Brushes.Green
                //});
                //cursor.Children.Add(new Line
                //{
                //    X1 = 0,
                //    X2 = 0,
                //    Y1 = -25,
                //    Y2 = 25,
                //    Stroke = Brushes.Green
                //});

                //var cursor = new Ellipse
                //{
                //    Fill = new SolidColorBrush(Colors.Blue),
                //    VerticalAlignment = VerticalAlignment.Top,
                //    HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                //    Width = 2 * 50,
                //    Height = 2 * 50,
                //    Margin = new Thickness(-50, -50, 0, 0),
                //    IsHitTestVisible = false
                //};

                GazeInput.SetCustomCursor(null /*cursor*/);
            }
        }
示例#23
0
        void ResetBoard()
        {
            PlayAgainText.Visibility = Visibility.Collapsed;
            _gameOver = false;
            _numMoves = 0;
            MoveCountTextBlock.Text = _numMoves.ToString();
            for (int i = 0; i < _boardSize; i++)
            {
                for (int j = 0; j < _boardSize; j++)
                {
                    _buttons[i, j].Content = ((i * _boardSize) + j + 1).ToString();
                }
            }

            _buttons[_boardSize - 1, _boardSize - 1].Content = "";
            _blankRow = _boardSize - 1;
            _blankCol = _boardSize - 1;

            int    shuffleCount = 500;
            Random rnd          = new Random();

            while (shuffleCount > 0)
            {
                bool changeRow = rnd.Next(0, 2) == 0;
                bool decrement = rnd.Next(0, 2) == 0;

                int row = _blankRow;
                int col = _blankCol;
                if (changeRow)
                {
                    row = decrement ? row - 1 : row + 1;
                }
                else
                {
                    col = decrement ? col - 1 : col + 1;
                }

                if ((row < 0) || (row >= _boardSize) || (col < 0) || (col >= _boardSize))
                {
                    continue;
                }

                if (SwapBlank(row, col))
                {
                    shuffleCount--;
                }
            }
            GazeInput.SetInteraction(GameGrid, Interaction.Enabled);
        }
示例#24
0
    protected override void DoGazeExit(GazeHit hit)
    {
        iTween.MoveTo(gameObject, iTween.Hash(
                          "position", startPos,
                          "speed", speed,
                          "space", Space.World
                          ));

        gazeInput = null;

        if (boxCollider != null)
        {
            boxCollider.size = boxColliderStartSize;
        }
    }
        public MainPage()
        {
            InitializeComponent();

            CoreWindow.GetForCurrentThread().KeyDown += new Windows.Foundation.TypedEventHandler <CoreWindow, KeyEventArgs>(delegate(CoreWindow sender, KeyEventArgs args) {
                GazeInput.GetGazePointer(this).Click();
            });

            var sharedSettings = new ValueSet();

            GazeSettingsHelper.RetrieveSharedSettings(sharedSettings).Completed = new AsyncActionCompletedHandler((asyncInfo, asyncStatus) =>
            {
                GazeInput.LoadSettings(sharedSettings);
            });
        }
示例#26
0
    /**
     * Find a point in the center of the prop that is under the gaze ray.
     */
    public Vector3 GetPickPoint( GazeInput gazeInput )
    {
        // The horizontal plane that goes through the center of the prop.
        var propPlane = new Plane( transform.up, propBounds.center );

        var gazeRay = new Ray( gazeInput.GazeTransform.position, gazeInput.GazeTransform.forward );

        float rayDistance;
        Vector3 pickPoint = Vector3.zero;
        if ( propPlane.Raycast( gazeRay, out rayDistance ) ) {
            pickPoint = gazeRay.GetPoint( rayDistance );
        }

        return pickPoint;
    }
 private void OnExitSettings(object sender, RoutedEventArgs e)
 {
     MasterViewModel.Settings.Save();
     grdvwPhrases.FontSize   = MasterViewModel.Settings.FontSize;
     SettingsGrid.Visibility = Visibility.Collapsed;
     AdjustTileSize();
     SetToolsToolbarVisible(false);
     if (MasterViewModel.Settings.GazePlusClickMode)
     {
         GazeInput.SetIsSwitchEnabled(this, true);
     }
     else
     {
         GazeInput.SetIsSwitchEnabled(this, false);
     }
 }
示例#28
0
        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);
        }
示例#29
0
        public MainPage()
        {
            InitializeComponent();

            var localSettings = new ValueSet();

            GazeSettings.ValueSetFromLocalSettings(localSettings);

            var gazePointer = GazeInput.GetGazePointer(this);

            gazePointer.LoadSettings(localSettings);

            CoreWindow.GetForCurrentThread().KeyDown += new Windows.Foundation.TypedEventHandler <CoreWindow, KeyEventArgs>(delegate(CoreWindow sender, KeyEventArgs args) {
                gazePointer.Click();
            });
        }
        private void FlipBatchAnimation_Completed(object sender, CompositionBatchCompletedEventArgs args)
        {
            _animationActive = false;

            if (_secondButton == null)
            {
                return;
            }

            if (_secondButton.Tag.ToString() != _firstButton.Tag.ToString())
            {
                GazeInput.SetInteraction(buttonMatrix, Interaction.Disabled);
                _flashTimer.Start();
            }
            else
            {
                //Do Match confirmation animation

                //Flip button visual
                var btn1Visual  = ElementCompositionPreview.GetElementVisual(_firstButton);
                var btn2Visual  = ElementCompositionPreview.GetElementVisual(_secondButton);
                var compositor  = btn1Visual.Compositor;
                var springSpeed = 50;

                GazeInput.SetInteraction(_firstButton, Interaction.Disabled);
                GazeInput.SetInteraction(_secondButton, Interaction.Disabled);

                btn1Visual.CenterPoint = new System.Numerics.Vector3((float)_firstButton.ActualWidth / 2, (float)_firstButton.ActualHeight / 2, 0f);
                btn2Visual.CenterPoint = new System.Numerics.Vector3((float)_secondButton.ActualWidth / 2, (float)_secondButton.ActualHeight / 2, 0f);

                var scaleAnimation = compositor.CreateSpringVector3Animation();
                scaleAnimation.InitialValue = new System.Numerics.Vector3(0.9f, 0.9f, 0f);
                scaleAnimation.FinalValue   = new System.Numerics.Vector3(1.0f, 1.0f, 0f);

                scaleAnimation.DampingRatio = 0.4f;
                scaleAnimation.Period       = TimeSpan.FromMilliseconds(springSpeed);

                btn1Visual.StartAnimation(nameof(btn1Visual.Scale), scaleAnimation);
                btn2Visual.StartAnimation(nameof(btn2Visual.Scale), scaleAnimation);

                _firstButton  = null;
                _secondButton = null;
                _remaining   -= 2;

                CheckGameCompletion();
            }
        }
示例#31
0
        void InitializeButtonArray()
        {
            GazeInput.SetInteraction(GameGrid, Interaction.Disabled);

            GameGrid.Children.Clear();
            GameGrid.RowDefinitions.Clear();
            GameGrid.ColumnDefinitions.Clear();

            for (int row = 0; row < _boardSize; row++)
            {
                GameGrid.RowDefinitions.Add(new RowDefinition());
                GameGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            _buttons = new Button[_boardSize, _boardSize];

            for (int row = 0; row < _boardSize; row++)
            {
                for (int col = 0; col < _boardSize; col++)
                {
                    var button = new Button();
                    button.Background = _solidTileBrush;
                    button.Name       = "button" + "_" + col + "_" + row;
                    if (!(row == _boardSize - 1 && col == _boardSize - 1))
                    {
                        button.Content = ((row * _boardSize) + col + 1).ToString();
                    }
                    else
                    {
                        button.Content    = "";
                        button.Background = _blankTileBrush;
                    }
                    button.Tag    = (row * _boardSize) + col;
                    button.Click += OnButtonClick;
                    button.Style  = Resources["ButtonStyle"] as Style;

                    _buttons[row, col] = button;;

                    Grid.SetRow(button, row);
                    Grid.SetColumn(button, col);
                    GameGrid.Children.Add(button);
                }
            }

            GameGrid.UpdateLayout();
        }