Exemple #1
0
        public async Task showMsg()
        {
            /*
             * I got some of the following code about the content dialog boxes from here
             * http://www.reflectionit.nl/blog/2015/windows-10-xaml-tips-messagedialog-and-contentdialog
             */

            //using localisation to retrieve strings that will be displayed in the end round/game message

            ResourceCandidate rc;

            rc = ResourceManager.Current.MainResourceMap.GetValue("Resources/ok",
                                                                  ResourceContext.GetForCurrentView());
            string ok      = rc.ValueAsString;
            var    message = new ContentDialog()
            {
                Title             = status + "\n" + App.usrName + ": " + pl.CurrScr + " AI: " + en.CurrScr,
                PrimaryButtonText = ok,
            };

            rc = ResourceManager.Current.MainResourceMap.GetValue("Resources/newGm",
                                                                  ResourceContext.GetForCurrentView());
            string newGame = rc.ValueAsString;

            //if the message asks for a new game, the user is given an extra option
            //they can select cancel, which will return them to the main menu
            if (status.Equals(newGame))
            {
                rc = ResourceManager.Current.MainResourceMap.GetValue("Resources/cancel",
                                                                      ResourceContext.GetForCurrentView());
                string cancel = rc.ValueAsString;
                //secondary button added to message dialog
                message.SecondaryButtonText = cancel;
                //store which button was pressed
                var result = await message.ShowAsync();

                //if user wants another game, reset and start a new game
                if (result == ContentDialogResult.Primary)
                {
                    resetScrCircles();
                    en.hardReset();
                    pl.hardReset();
                    newFrme();
                }
                //otherwise return user to main page
                else if (result == ContentDialogResult.Secondary)
                {
                    //navigate to home page
                    Frame.Navigate(typeof(MainPage));
                }
            }
            else
            {
                //show message normally if not end of game
                //await feedback and start a new round
                await message.ShowAsync();

                newFrme();
            }
        }