private bool RemoveVehicle(RealTimeArrival arrival)
        {
            var key = new Tuple <string, string>(arrival.Stop, arrival.Trip);

            if (VehicleWrappers.ContainsKey(key))
            {
                var tviw = VehicleWrappers[key];
                MapElementsShown.Remove(tviw.Element);
                VehicleWrappers.Remove(key);
                return(true);
            }
            return(false);
        }
        private void SetVehicle(RealTimeArrival arrival)
        {
            var key = new Tuple <string, string>(arrival.Stop, arrival.Trip);

            if (VehicleWrappers.ContainsKey(key))
            {
                var tviw = VehicleWrappers[key];
                tviw.Arrival         = arrival;
                VehicleWrappers[key] = tviw;
            }
            else
            {
                TransitVehicleIconWrapper tviw = new TransitVehicleIconWrapper();
                tviw.Arrival = arrival;
                MapElementsShown.Add(tviw.Element);
                VehicleWrappers.Add(key, tviw);
            }
        }
Пример #3
0
        public RealTimeArrivalViewModel(RealTimeArrival arrival)
        {
            if (arrival.FrequencyMinutes == null)
            {
                Instances.Add(new WeakReference <RealTimeArrivalViewModel>(this));
            }
            HasLongRouteName     = arrival.RouteName.Length >= 8;
            Arrival              = arrival;
            RouteName            = arrival.RouteName;
            RouteDestination     = arrival.Destination;
            DegreeOfConfidence   = arrival.DegreeOfConfidence;
            IsPredicted          = arrival.PredictedArrivalTime.HasValue;
            Vehicle              = arrival.Vehicle;
            HasAlert             = arrival.Status == AlertStatus.Alert;
            IsCancelled          = arrival.Status == AlertStatus.Cancelled;
            IsDropOffOnly        = arrival.IsDropOffOnly;
            IsFrequencyBased     = arrival.FrequencyMinutes != null;
            HasScheduledLocation = arrival.ScheduledVehicleLocation.HasValue;
            HasKnownLocation     = arrival.KnownVehicleLocation.HasValue;

            var detail = PugetSoundVehicleDetailSource.Instance.GetVehicleDetails(arrival);

            HasVehicleDetails = detail.HasValue;
            if (HasVehicleDetails)
            {
                VehicleDetails = detail.Value;
            }

            if (arrival.FrequencyMinutes == null)
            {
                PredictedArrivalTimeText = arrival.PredictedArrivalTime?.ToString("h:mm tt") ?? "Unknown";
                if (arrival.ScheduledArrivalTime == null)
                {
                    ScheduledArrivalTimeText = "(Unscheduled)";
                }
                else
                {
                    ScheduledArrivalTimeText = $"(Sched. {arrival.ScheduledArrivalTime?.ToString("h:mm")})";
                }
                if (arrival.PredictedArrivalTime != null && arrival.ScheduledArrivalTime != null)
                {
                    var minsLate = (int)(arrival.PredictedArrivalTime.Value - arrival.ScheduledArrivalTime.Value).TotalMinutes;
                    if (minsLate > 0)
                    {
                        PredictedArrivalTimeText += $", {minsLate}m late";
                    }
                    else if (minsLate == 0)
                    {
                        PredictedArrivalTimeText += ", on time";
                    }
                    else
                    {
                        PredictedArrivalTimeText += $", {-minsLate}m early";
                    }
                    IsEarly = minsLate < 0;
                }
                RefreshMinutesAway();
            }
            else
            {
                Frequency = (int)arrival.FrequencyMinutes.Value;
            }
        }
 public override Task <RetrievedData <RealTimeArrival> > CorrectRealTimeArrival(RealTimeArrival arrival, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }