コード例 #1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Register for the viewstatechanged event
            // Register for the window resize event


            Window.Current.SizeChanged += WindowSizeChanged;     
            
            if (CreateGameMode)
            {
                _viewModel = new CanvasPageViewModel();
                CreateGamePanel.Visibility = Visibility.Visible;
                _viewModel.GameSpotsList = new GameHotSpots();
                _viewModel.CurrentPaintingSpots = new PaintingHotSpots();
            }
            else
            {
                _viewModel = new CanvasPageViewModel(true);
                CreateGamePanel.Visibility = Visibility.Collapsed;
                LoadBackGroundMusic();
               
            }

            GoToState("MainMenuState");

        }
コード例 #2
0
 private void GoToState(string state)
 {
     switch (state)
     {
         case "MainMenuState":
             _states = state;
             ResetCanvas();
             _viewModel.HintsLeft = 3;
             AutomationProperties.SetName(hintButton, "Hints" + " (" + _viewModel.HintsLeft + " Left)");
             if (CreateGameMode)
             {
                 _viewModel = new CanvasPageViewModel();                       
             }
             else
             {
                 _viewModel = new CanvasPageViewModel(true);
             }
             bottomAppBar.IsOpen = false;
             bottomAppBar.IsSticky = false;
             ChangePaintings(_viewModel.PaintingNumbers[0]);
             CheckScreenState();
             ShowHideAppBarButtons(true);
             break;
         case "PlayingState":
             _states = state;
             ShowHideAppBarButtons(false);
             bottomAppBar.IsOpen = true;
             bottomAppBar.IsSticky = true;
             CheckScreenState();
             break;
         case "FinishState":
             _states = state;
             ShowHideAppBarButtons(true);
             bottomAppBar.IsOpen = false;
             bottomAppBar.IsSticky = false;
             CheckScreenState();
             break;
     }
     VisualStateManager.GoToState(this, state, true);
 }