public void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e) { DurationString = DateTime.UtcNow.Subtract(_startTimeConst).ToString(); DurationLabel.Text = DurationString.ToString(); // TODO: // попробовать вынести с главного потока Device.BeginInvokeOnMainThread(() => { var positionGeolocator = e.Position; if ((positionGeolocator.Latitude != _previousPosition.Latitude) || (positionGeolocator.Longitude != _previousPosition.Longitude)) { var snappedPointDb = new SnappedPointDb { TrackId = _track.Id, Latitude = positionGeolocator.Latitude, Longitude = positionGeolocator.Longitude, Time = positionGeolocator.Timestamp.UtcDateTime }; App.SnappedPointDatabase.SaveItem(snappedPointDb); _snappedPointsCount += 1; _previousPosition = positionGeolocator; } }); }
public int SaveItem(SnappedPointDb item) { if (item.Id != 0) { database.Update(item); return(item.Id); } else { return(database.Insert(item)); } }
public SnappedPointDb[] GetItemsByTrackId(int trackId) { SnappedPointDb[] items; try { items = GetItems().Where(i => i.TrackId == trackId).ToArray(); } catch (Exception e) { items = new SnappedPointDb[] {}; } return(items); }