private async void EndBtn_ClickedAsync(object sender, EventArgs e) { IsRunning = false; StartBtn.IsVisible = true; PauseBtn.IsVisible = false; ResumeBtn.IsVisible = false; EndBtn.IsEnabled = false; bool answer = await DisplayAlert("Great Run!", "Would you like to save it to history?", "Yes", "No"); if (answer) { CalculationClass calculationsClass = new CalculationClass(); FinalSpeed = calculationsClass.finalSpeed(FinalSpeed, hr, min, sec); try { var db = App.database; var tableItems = new ExerciseTable { DURATION = TimerLabel.Text, DISTANCE = TimerDistance.Text, AVGSPEED = FinalSpeed.ToString(), DATETIME = DateTime.Now }; await db.SaveItemAsync(tableItems); } catch (SQLiteException ex) { TimerLabel.Text = ex.ToString(); } } }
public void Calculations(double nextLat, double nextLong) { lat2 = nextLat; long2 = nextLong; CalculationClass calculationClass = new CalculationClass(); Distance2 = calculationClass.DistanceBtwnTwoPnts(lat1, long1, lat2, long2); FinalDistance = FinalDistance + Distance2; Distance2 = 0; //Now the second point is the first one and we wait for the coordinates of the next point lat1 = lat2; long1 = long2; CurrentSpeed = calculationClass.currentSpeed(Distance2); TimerDistance.Text = "Distance: " + FinalDistance.ToString() + " Meters"; TimerCurSpeed.Text = "Speed: " + CurrentSpeed.ToString() + " Km/h"; TimerLabel.Text = hr.ToString() + " h: " + min.ToString() + " m: " + sec.ToString() + " s"; }