Beispiel #1
0
        //imports a path file with and sets the current path equal to it than reloads to the homePage
        private async void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker fileSelector = new FileOpenPicker
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            fileSelector.FileTypeFilter.Add(".csv");

            StorageFile file = await fileSelector.PickSingleFileAsync();

            if (file != null)
            {
                CachedFileManager.DeferUpdates(file);
                IList <string> lines = await FileIO.ReadLinesAsync(file);

                App.PlayerList.Add(SaveSystem.LoadSaveFile(lines));
                MainFrame.Navigate(typeof(HomePage));
            }
            else
            {
                WarningCD warning = new WarningCD("Error: File not found", "No file was selected.");
                warning.Show();
            }
        }
 //saves the direct coordinates of the points to the path
 private void CoordinateSaveButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (!(double.TryParse(ControlPointOneXTextBox.Text, out double cpOneX) && double.TryParse(ControlPointOneYTextBox.Text, out double cpOneY) && double.TryParse(ControlPointTwoXTextBox.Text, out double cpTwoX) && double.TryParse(ControlPointTwoYTextBox.Text, out double cpTwoY) && double.TryParse(ControlPointThreeXTextBox.Text, out double cpThreeX) && double.TryParse(ControlPointThreeYTextBox.Text, out double cpThreeY) && double.TryParse(ControlPointFourXTextBox.Text, out double cpFourX) && double.TryParse(ControlPointFourYTextBox.Text, out double cpFourY)))
     {
         WarningCD warning = new WarningCD("Please enter only numeric values", "");
         warning.Show();
         return;
     }
Beispiel #3
0
        private async void PlayerSaveButton_Click(object sender, RoutedEventArgs e)
        {
            FileSavePicker fileSelector = new FileSavePicker
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            fileSelector.FileTypeChoices.Add("csv", new List <string>()
            {
                ".csv"
            });
            fileSelector.SuggestedFileName = "Profile0";

            StorageFile file = await fileSelector.PickSaveFileAsync();

            //More safety needs to be added. Popups for exported and failed to export should also eventually appear.
            if (file != null)
            {
                CachedFileManager.DeferUpdates(file);
                String[] lines = SaveSystem.MakeSaveFile(App.PlayerList[PlayerExportComboBox.SelectedIndex]);
                await FileIO.WriteLinesAsync(file, lines);

                Windows.Storage.Provider.FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    //Yay it saved.
                    WarningCD warning = new WarningCD("Alert", "File Successfully saved.");
                    warning.Show();
                }
            }
            else
            {
                WarningCD warning = new WarningCD("Error: File not found", "No file was selected.");
                warning.Show();
            }
            SavePlayerPopup.IsOpen = false;
        }