public ARunData ToARunData()
 {
     ARunData data = new ARunData();
     for (int i = 0; i < longitude.Count(); i++)
     {
         GeoCoordinate geoCord = new GeoCoordinate();
         geoCord.Longitude = longitude[i];
         geoCord.Latitude = latitude[i];
         data.geoCollection.Add(geoCord);
     }
    
    
     //data.datetime = JsonConvert.DeserializeObject<DateTime>(datetime, new JavaScriptDateTimeConverter());
     try
     {
         data.datetime = TimeZoneInfo.ConvertTime(datetime, TimeZoneInfo.Local);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "The time will be set to default");
         data.datetime = DateTime.MinValue;
     }
     int dem = (int)IsolatedStorageSettings.ApplicationSettings["RunCount"];
     dem++;
     IsolatedStorageSettings.ApplicationSettings.Save();
     data.BurnedCalories = BurnedCalories;
     data.Duration = Duration;
     data.AvgSpeed = AvgSpeed;
     data.AvgPace = AvgPace;
     data.Distance = Distance;
     data.No = dem;
     data.IsSynced = true;
     return data;
 }
 public void ParseFrom (ARunData data)
 {
     longitude = new double[data.geoCollection.Count];
     latitude = new double[data.geoCollection.Count];
     for (int i = 0; i < data.geoCollection.Count; i++)
     {
         longitude[i] = data.geoCollection[i].Longitude;
         latitude[i] = data.geoCollection[i].Latitude;
     }
     datetime = data.datetime.ToUniversalTime(); // So Json Serializer/Deserializer could understands and do the Parsing
     //datetime = JsonConvert.SerializeObject(data.datetime, new JavaScriptDateTimeConverter());
     BurnedCalories = data.BurnedCalories;
     Duration = data.Duration;
     AvgSpeed = data.AvgSpeed;
     AvgPace = data.AvgPace;
     Distance = data.Distance;
 }
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            ARunData rundata = new ARunData();
            DateTime date = (DateTime)dpDate.Value;
            DateTime datetime = date + ((DateTime)tpTime.Value).TimeOfDay;

            rundata.datetime = datetime;
            try
            {
                rundata.BurnedCalories = double.Parse(tbCalo.Text);
            }
            catch
            {
                rundata.BurnedCalories = 0;
            }
            try
            {
                rundata.Distance = double.Parse(tbDistance.Text);
            }
            catch
            {
                rundata.Distance = 0;
            }
            try
            {
                int _timeCount = ((int)double.Parse(tbDuration.Text) * 60);
                rundata.Duration = string.Format("{0}h {1}m {2}s", _timeCount / 3600, (_timeCount / 60) % 60, _timeCount % 60);
            }
            catch
            {
                rundata.Duration = "0h 0m 0s";
            }
            rundata.Save();
            MessageBox.Show(AppResources.Saved);
            // NavigationService.GoBack();
            //

        }