private async void Submit_Click(object sender, RoutedEventArgs e) { int steps = 0; double distance = 0; if (!int.TryParse(StepsBox.Text, out steps) || !double.TryParse(DistanceBox.Text, out distance)) { await new MessageDialog("You need to fill in an approximate number of steps and distance.").ShowAsync(); return; } Activity activity = new Activity { Id = id, AccountId = UserState.CurrentId, BeginTime = BeginDate.Date.DateTime + BeginTime.Time, EndTime = EndDate.Date.DateTime + EndTime.Time, Description = "<placeholder>", Steps = steps, Distance = UserState.UseOldUnits ? distance * 3.0 : distance, Type = (ActivityType)TypeBox.SelectedIndex }; var result = await Api.Do.UpdateActivity(activity); activity = result; PageDispatch.ViewActivity(Frame, activity); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { this.activity = (Activity)e.Parameter; StepCounter.Text = "Steps: " + activity.Steps; DurationDisplay.Text = "Duration: " + (activity.EndTime - activity.BeginTime).ToString("hh':'mm':'ss"); TypeDisplay.Text = "Type: " + Enum.GetName(typeof(ActivityType), activity.Type); DistanceDisplay.Text = "Distance: " + (UserState.UseOldUnits ? Math.Round(activity.Distance / 3.0, 2) + " leagues" : activity.Distance + " miles"); Path path = await Api.Do.GetPath(activity.Id); if (path != null) { Map.Center = new Geopoint(path[0]); Map.ZoomLevel = 15; MapPolyline poly = new MapPolyline(); poly.Path = new Geopath(path.Coordinates); poly.StrokeColor = Color.FromArgb(255, 120, 220, 140); poly.StrokeThickness = 5.0; poly.Visible = true; Map.MapElements.Add(poly); } }
private async void RecordButton_Tapped(object sender, TappedRoutedEventArgs e) { if (recording) { DateTime end = DateTime.UtcNow; Activity activity = new Activity { AccountId = UserState.CurrentId, BeginTime = begin, EndTime = end, Steps = pedometer.Steps, Distance = path.Distance }; GPSSpinner.IsActive = true; ((Button)sender).IsEnabled = false; geolocator.PositionChanged -= geolocator_PositionChanged; pedometer.Stepped -= pedometer_Stepped; activity.Type = await Api.Do.Predict(activity); activity = (await Api.Do.SendActivity(activity)).Item1; path.ActivityId = activity.Id; path = await Api.Do.PostPath(path); PageDispatch.ViewActivity(Frame, activity); } else { begin = DateTime.UtcNow; current = DateTime.UtcNow; timer = new Timer((o) => { current = current.AddSeconds(1); Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DurationDisplay.Text = "Duration: " + (current - begin).ToString("hh':'mm':'ss")); }, null, 1000, 1000); ((Button)sender).Content = "Stop Activity"; pedometer.Start(); begin = DateTime.UtcNow; pedometer.Stepped += pedometer_Stepped; recording = true; geolocator.PositionChanged += geolocator_PositionChanged; } }
public Task<ActivityType> Predict(Activity activity) { throw new NotImplementedException(); }
public Task<Activity> UpdateActivity(Activity activity) { throw new NotImplementedException(); }
public Task<Tuple<Activity, List<Goal>, List<Attainment>>> SendActivity(Activity activity) { activity.Id = random.Next(); activities.Add(activity.Id, activity); if (UserState.CurrentId == activity.AccountId) { UserState.ActiveAccount.Activities.Add(activity); } throw new NotImplementedException(); }
public static void EditActivity(Frame frame, Activity activity) { frame.Navigate(typeof(UpdateActivityPage), activity); }
public static void ViewActivity(Frame frame, Activity activity) { frame.Navigate(typeof(ViewActivityPage), activity); }