コード例 #1
0
        protected override async void OnNavigatedTo(NavigationEventArgs args)
        {
            await this.Authenticate();

            mobileServiceClient = new TicTacToeLibraryCSharp.TicTacToeMobileServiceClient(App.mobileClient,
                                                                                          TicTacToeMobile1000Push.Channel, mobileServiceUser);
            processor                = new TicTacToeLibraryCSharp.GameProcessor(mobileServiceClient);
            DataContext              = processor;
            processor.OnProcessTurn += this.UpdateBadge;
        }
コード例 #2
0
 protected override async void OnNavigatedTo(NavigationEventArgs args)
 {
     await this.Authenticate();
     mobileServiceClient = new TicTacToeLibraryCSharp.TicTacToeMobileServiceClient(App.mobileClient, 
         TicTacToeMobile1000Push.Channel, mobileServiceUser);
     processor = new TicTacToeLibraryCSharp.GameProcessor(mobileServiceClient);
     DataContext = processor;
     processor.OnProcessTurn += this.UpdateBadge;
 }
コード例 #3
0
        /// <summary>
        /// Constructor, called just once per invocation of the app.
        /// </summary>
        /// <param name="mobileServiceClientIn"></param>
        public GameProcessor(TicTacToeMobileServiceClient mobileServiceClientIn)
        {
            mobileServiceClient = mobileServiceClientIn;

            m_cells = new ObservableCollection<Cell>();
            isGameInProgress = false;
            playerOptions = new ObservableCollection<String>();
            defaultButtonForegroundBrush = new SolidColorBrush(Colors.White);
            winningPathButtonForegroundBrush = new SolidColorBrush(Colors.Red);
        
            for (int i = 0; i < 9; i++)
            {
                m_cells.Add(new Cell(i, defaultButtonForegroundBrush, this));
            }

            foreach (Cell cell in m_cells)
            {
                cell.CellSelected += new CellSelectedHandler(this.CellSelected);
            }

            m_newGameCommand = new DelegateCommand(new ExecuteDelegate(this.CreateNewGame), new CanExecuteDelegate(this.CanSelectNewGame));
            signInCommand = new DelegateCommand(new ExecuteDelegate(this.RegisterOrSignInOrOut), new CanExecuteDelegate(this.CanRegisterOrSignInOrOut));
            searchCommand = new DelegateCommand(new ExecuteDelegate(this.SearchUsers), new CanExecuteDelegate(this.CanSearch));
            addFriendCommand = new DelegateCommand(new ExecuteDelegate(this.AddFriend), new CanExecuteDelegate(this.CanAddFriend));
            submitMoveCommand = new DelegateCommand(new ExecuteDelegate(this.SubmitMove), new CanExecuteDelegate(this.CanSubmitMoveCommand));
            // This sections helps the user log in if they have logged in previously by attempting to
            // retrieve credentials from the Password Vault.
            // If no cached credentials exist in the Password Vault, provide a Register button.

            //Task<bool> checkRegistration = mobileServiceClient.IsKnownUser();
            //checkRegistration.Wait();
            //isRegistered = checkRegistration.Result;
            //UserNameText = mobileServiceClient.GetUserName();

            // How do we set "isRegistered" ?
            // How do we set "isSignedIn" ?

            /*Task task = FinalizeRegistration();
            task.Wait();

            if (CanRegisterOrSignInOrOut(null))
            {
                RegisterOrSignInOrOut(null);
            }
            */

            FinalizeSignIn();
        }