private void save_DoIt(StorageFile myStorageFile)
        {
            IList <Point> outerCurve = ConvertUIElementList2PointList(mOuterCurveUIElements);
            IList <Point> innerCurve = ConvertUIElementList2PointList(mInnerCurveUIElements);

            if ((outerCurve.Count == 0) || (innerCurve.Count == 0))
            {
                mTrackCreationState = trackCreationState.Error;
                SetInstructionText(true, ERROR_INTERNAL);
            }
            else
            {
                TrackLoader.SaveTrack(myStorageFile, outerCurve, innerCurve);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the track that was chosen and paint that
        /// </summary>
        /// <param name="e"></param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // first paint the track
            int?trackNumber = e.Parameter as int?;

            if (trackNumber != null)
            {
                try
                {
                    if (trackNumber != LOAD_TRACK_NR)
                    {
                        // a predefined track was chosen, get this track
                        mActiveTrack = TrackProvider.GetTrack((uint)trackNumber);
                    }
                    else
                    {
                        // user chose "Load Track"
                        // FileBrowseDialog
                        string filePath = await MyFilePicker.LetUserPickFile2Open();

                        if (filePath != null)
                        {
                            try
                            {
                                // load track
                                mActiveTrack = await TrackLoader.LoadTrack(filePath);
                            }
                            catch (Exception)
                            {
                                MessageDialog dialog = new MessageDialog("Please choose another track file, because the selected file is invalid: "
                                                                         + Environment.NewLine + "'" + filePath + "'.", "Error");
                                await dialog.ShowAsync();

                                // an exception occurred, return to main page
                                Back2Main();
                            }
                        }
                    }

                    if (mActiveTrack != null)
                    {
                        mActiveTrack.PaintTrack(xMyCanvas.Children, xMyCanvas.Width, xMyCanvas.Height,
                                                GridLinePainter.GetMiddleGridRowYCoordinate(xMyCanvas));

                        // highscore
                        SetHighscoreInGUI();

                        InitRace();
                    }
                    else
                    {
                        // loading track failed, navigate back to main
                        Back2Main();
                    }
                }
                catch (Exception)
                {
                    MessageDialog dialog = new MessageDialog("Problem with loading the track", "Error");
                    await dialog.ShowAsync();

                    // an exception occurred, return to main page
                    Back2Main();
                }
            }
        }