예제 #1
0
        public void Notify()
        {
            NotifyPropertyChanged("CurrentPointDescription");
            NotifyPropertyChanged("NamePlayer1");
            NotifyPropertyChanged("NamePlayer2");
            NotifyPropertyChanged("ScorePlayer1");
            NotifyPropertyChanged("ScorePlayer2");
            NotifyPropertyChanged("Server");
            NotifyPropertyChanged("Status");
            NotifyPropertyChanged("MatchType");
            NotifyPropertyChanged("Surface");
            NotifyPropertyChanged("Duration");
            NotifyPropertyChanged("Winner");
            NotifyPropertyChanged("InProgress");
            NotifyPropertyChanged("Completed");
            NotifyPropertyChanged("IsExtendPossible");
            NotifyPropertyChanged("Undo");
            NotifyPropertyChanged("Paused");
            NotifyPropertyChanged("Switch");
            NotifyPropertyChanged("TotalSets");
            NotifyPropertyChanged("CurrentSetScore");
            NotifyPropertyChanged("StatisticsCollection");
            //NotifyPropertyChanged("Stoppable");
            TotalSets.Notify();
            CurrentSetScore.Notify();
            StatisticsCollection.Notify();

            if (NewState != null)
            {
                NewState(this, EventArgs.Empty);
            }
        }
예제 #2
0
        /// <summary>
        /// Process the action/choice of the user
        /// </summary>
        /// <param name="Method"></param>
        public void ProcessAction(string CommandMethod)
        {
            try
            {
                switch (CommandMethod)
                {
                case "CommandTerminate":

                    Match.Terminate();

                    break;

                case "CommandEnd":

                    Match.End(TennisMatch.MatchStatus.Terminated);

                    break;

                case "CommandResign":

                    Match.End(TennisMatch.MatchStatus.Resigned);

                    break;

                case "CommandUndo":

                    if (CurrentPoint == null || CurrentPoint.Point.Winner == 0 && CurrentPoint.Point.Serve != TennisPoint.PointServe.SecondServe)
                    {
                        //Undo the last played point if the current point is not present, or if it has not been played yet.
                        Match.Undo();
                    }

                    NewPoint();

                    break;

                case "CommandSwitchServer":

                    Match.SwitchServer();

                    NewPoint();

                    break;

                case "CommandExtend":

                    Match.Extend();

                    NewPoint();

                    break;

                default:

                    CurrentPoint.ProcessAction(CommandMethod);

                    if (CurrentPoint.PossibleActions.Count <= 1)
                    {
                        //no choices to make; start a new point
                        Match.Add(CurrentPoint.Point);

                        NewPoint();
                    }
                    break;
                }

                NotifyPropertyChanged("CurrentPoint");
                NotifyPropertyChanged("Duration");
                NotifyPropertyChanged("IsExtendPossible");
                NotifyPropertyChanged("SetScores");
                NotifyPropertyChanged("ScorePlayer1");
                NotifyPropertyChanged("ScorePlayer2");
                NotifyPropertyChanged("Server");
                NotifyPropertyChanged("InProgress");
                NotifyPropertyChanged("Winner");
                NotifyPropertyChanged("Completed");
                NotifyPropertyChanged("Undo");
                NotifyPropertyChanged("Sets");
                NotifyPropertyChanged("Switch");
                NotifyPropertyChanged("MatchType");
                NotifyPropertyChanged("Status");

                CurrentSetScore.Notify();
                TotalSets.Notify();
                StatisticsCollection.Notify();
            }
            catch (Exception e)
            {
                ExtendedEventArgs eaa = new ExtendedEventArgs();
                eaa.Error = "A fatal error occurred. Please try again or stop this match to preserve the statistics.";
                #if DEBUG
                eaa.Error = String.Format("A fatal error occurred. {1}:{0}", e.Message, e.Source);
                #endif
                OnFatalError(eaa);
            }
        }