Ejemplo n.º 1
0
        private async void saveGameButton_Click(object sender, RoutedEventArgs e)
        {
            string              text       = string.Empty;
            SaveDialog          saveDialog = new SaveDialog();
            ContentDialogResult result     = await saveDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                try
                {
                    MapLearner.save(mapLearner, saveDialog.Text);
                }
                catch (ArgumentException err)
                {
                    ContentDialog errorDialog = new ContentDialog
                    {
                        Title             = "Saving Error:",
                        Content           = err.Message,
                        PrimaryButtonText = "Ok"
                    };

                    await errorDialog.ShowAsync();
                }
            }
        }
Ejemplo n.º 2
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     // If this is internal navigation, we do not want to auto save
     if (e.SourcePageType != typeof(MainPage))
     {
         XmlServiceClient client = XmlServiceClient.Instance;
         MapLearner.save(mapLearner, client.AutoSaveName);
     }
 }
Ejemplo n.º 3
0
 private static SaveGame getDataToSave(MapLearner mapLearner, string saveName)
 {
     return(new SaveGame
     {
         Name = saveName,
         CurrentState = mapLearner.CurrentState,
         States = mapLearner.States,
         Region = MapLearnerRegionHelper.convertRegionToString(mapLearner.Region)
     });
 }
Ejemplo n.º 4
0
        private async void loadGameButton_Click(object sender, RoutedEventArgs e)
        {
            LoadDialog          loadDialog = new LoadDialog();
            ContentDialogResult result     = await loadDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                mapLearner = new MapLearner(loadDialog.SaveGameName);
                initializeBoard();
            }
        }
Ejemplo n.º 5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string parameter = e.Parameter as string;

            if (continueFromPrevious(parameter))
            {
                mapLearner = MapLearner.loadMostRecent();
            }
            else if (parameter == null)
            {
                mapLearner = new MapLearner(MapLearnerRegion.UnitedStates);
            }
            else
            {
                mapLearner = new MapLearner(parameter);
            }

            initializeBoard();
        }
Ejemplo n.º 6
0
        private async void deleteSaveButton_Click(object sender, RoutedEventArgs e)
        {
            DeleteSaveDialog    deleteSaveDialog = new DeleteSaveDialog();
            ContentDialogResult result           = await deleteSaveDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                ContentDialog locationPromptDialog = new ContentDialog
                {
                    Title               = "Are you sure you want to delete save '" + deleteSaveDialog.DeleteSaveName + "'?",
                    Content             = "Once deleted, your save will be lost forever!",
                    SecondaryButtonText = "Cancel",
                    PrimaryButtonText   = "Yes!"
                };

                if (await locationPromptDialog.ShowAsync() == ContentDialogResult.Primary)
                {
                    MapLearner.removeSaveGame(deleteSaveDialog.DeleteSaveName);

                    var messageDialog = new Windows.UI.Popups.MessageDialog(deleteSaveDialog.DeleteSaveName + " has been deleted.", "Success!");
                    await messageDialog.ShowAsync();
                }
            }
        }
Ejemplo n.º 7
0
        public static void save(MapLearner mapLearner, string saveName)
        {
            XmlServiceClient client = XmlServiceClient.Instance;

            client.save(getDataToSave(mapLearner, saveName));
        }
Ejemplo n.º 8
0
 private void newGame()
 {
     mapLearner = new MapLearner(MapLearnerRegion.UnitedStates);
     initializeBoard();
 }
Ejemplo n.º 9
0
 private void newGame(MapLearnerRegion region)
 {
     mapLearner = new MapLearner(region);
     initializeBoard();
 }