Пример #1
0
        public async void CheckNearExhibit(IEnumerable <Exhibit> exhibits, GeoLocation gpsLocation, bool considerTimeouts)
        {
            foreach (Exhibit e in exhibits)
            {
                var dist = MathUtil.CalculateDistance(e.Location, gpsLocation);
                if (dist < AppSharedData.ExhibitRadius)
                {
                    if (considerTimeouts)
                    {
                        DateTimeOffset now = DateTimeOffset.Now;
                        if (e.LastNearbyTime.HasValue)
                        {
                            if (now.Subtract(e.LastNearbyTime.Value) <= dialogTimeout)
                            {
                                // dialog for this exhibit was shown recently, skip it
                                continue;
                            }
                        }

                        // update the time the dialog was last shown
                        using (DbManager.StartTransaction())
                        {
                            e.LastNearbyTime = now;
                        }
                    }

                    var result =
                        await
                        IoCManager.Resolve <INavigationService> ()
                        .DisplayAlert(Strings.ExhibitNearby_ExhibitNearby, Strings.ExhibitOrRouteNearby_Question_Part1 + " \"" + e.Name + "\" " + Strings.ExhibitOrRouteNearby_Question_Part2,
                                      Strings.ExhibitOrRouteNearby_Confirm, Strings.ExhibitOrRouteNearby_Reject);

                    if (result)
                    {
                        await IoCManager.Resolve <INavigationService>().PushAsync(new ExhibitDetailsViewModel(e.Id));

                        ExhibitVisitedEvent?.Invoke(this, e);
                        return;
                    }
                }
            }
        }
Пример #2
0
 public void InvokeExhibitVisitedEvent(Exhibit exhibit)
 {
     ExhibitVisitedEvent?.Invoke(this, exhibit);
 }