示例#1
0
        /// <summary>
        /// Save track to db/localstoreage
        /// </summary>
        /// <param name="trk"></param>
        private async void SaveTrackToDb(Track trk)
        {
            try
            {
                SetProgressIndicator(true, "Writing track to memory");
                TrackDataBase newItem = new TrackDataBase
                {
                    FileName    = trk.name,
                    ItemName    = trk.name,
                    Description = trk.description,
                };
                TrackDataBases.Add(newItem);
                _trackDB.TrackTable.InsertOnSubmit(newItem);

                await _fileIO.WriteToFile(trk.name + ".gpx", AppResources.LocalFolder, _ser.CreateGPX(trk).ToString());

                _trackDB.SubmitChanges();
                SetProgressIndicator(false, "");
                NavigationService.Navigate(new Uri("/TracksPiv.xaml?index=1", UriKind.Relative));
                ClearTrackData();
            }
            catch
            {
                SetProgressIndicator(false, "");
                MessageBox.Show("Something went very wrong.");
            }
        }
示例#2
0
 /// <summary>
 /// Delete button event handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void BtnDelete_OnClick(object sender, RoutedEventArgs e)
 {
     if (_miscFunctions.ShowMessage("Please confirm delete.", "Delete Route"))
     {
         TrackDataBase trackToDelete = TrackDataBases[_trackId - 1];
         if (trackToDelete != null)
         {
             TrackDataBases.Remove(trackToDelete);
             _trackDb.TrackTable.DeleteOnSubmit(trackToDelete);
             await _fileIo.DeleteFileFromLocal(trackToDelete.FileName, AppResources.LocalFolder);
             _trackDb.SubmitChanges();
             NavigationService.Navigate(new Uri("/TracksPiv.xaml?index=1", UriKind.Relative));
         }
     }
 }