public TransitStopIconWrapper(TransitStop stop)
 {
     if (stop.Path == null)
     {
         Element = new MapIcon() { Location = stop.Position.ToGeopoint(), NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 0.5), CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible, ZIndex = 5 };
     }
     else
     {
         Element = new MapPolygon() { Path = new Windows.Devices.Geolocation.Geopath(GooglePolylineConverter.Decode(stop.Path).Select(ll => ll.ToBasicGeoposition())), StrokeColor = Colors.Black, FillColor = Colors.DarkGray, StrokeThickness = 2, ZIndex = 4 };
     }
     AttachedProperties.SetElementType(Element, "TransitStop");
     AttachedProperties.SetElementID(Element, stop.ID);
     Stop = stop;
     SetStopSize();
 }
Ejemplo n.º 2
0
        public static async Task <RetrievedData <IEnumerable <TransitStop> > > GetTransitStopsForAreaAsync(LatLonRect area, DataSourcePreference preference, CancellationToken cancellationToken)
        {
            IEnumerable <TransitStop> resultStops      = null;
            List <string>             resultErrors     = new List <string>();
            List <Exception>          resultExceptions = new List <Exception>();

            foreach (var source in Sources)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    throw new OperationCanceledException();
                }
                if (!source.IsQualified(preference))
                {
                    continue;
                }
                if (source.CanGetTransitStopsForArea)
                {
                    var sResult = await source.GetTransitStopsForArea(area, cancellationToken);

                    if (sResult.HasData)
                    {
                        if (resultStops == null)
                        {
                            resultStops = sResult.Data;
                        }
                        else
                        {
                            resultStops = resultStops.Union(sResult.Data);
                        }
                    }
                    if (sResult.ErrorMessage != null)
                    {
                        resultErrors.Add(sResult.ErrorMessage);
                    }
                    if (sResult.CaughtException != null)
                    {
                        resultExceptions.Add(sResult.CaughtException);
                    }
                }
            }
            if (resultStops == null)
            {
                resultStops = new TransitStop[] { }
            }
            ;
            return(new RetrievedData <IEnumerable <TransitStop> >(resultStops, resultErrors.Count == 0 ? null : resultErrors.Aggregate("", (acc, err) => (acc == "" ? "" : ", ") + err), resultExceptions.Count == 0 ? null : new AggregateException(resultExceptions)));
        }
 public override Task <RetrievedData <TransitStop> > CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public abstract Task<RetrievedData<TransitStop>> CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken);
Ejemplo n.º 5
0
 public static async Task<RetrievedData<IEnumerable<TransitStop>>> GetTransitStopsForAreaAsync(LatLonRect area, DataSourcePreference preference, CancellationToken cancellationToken)
 {
     IEnumerable<TransitStop> resultStops = null;
     List<string> resultErrors = new List<string>();
     List<Exception> resultExceptions = new List<Exception>();
     foreach (var source in Sources)
     {
         if (cancellationToken.IsCancellationRequested)
             throw new OperationCanceledException();
         if (!source.IsQualified(preference))
             continue;
         if (source.CanGetTransitStopsForArea)
         {
             var sResult = await source.GetTransitStopsForArea(area, cancellationToken);
             if (sResult.HasData)
             {
                 if (resultStops == null)
                     resultStops = sResult.Data;
                 else
                     resultStops = resultStops.Union(sResult.Data);
             }
             if (sResult.ErrorMessage != null)
                 resultErrors.Add(sResult.ErrorMessage);
             if (sResult.CaughtException != null)
                 resultExceptions.Add(sResult.CaughtException);
         }
     }
     if (resultStops == null)
         resultStops = new TransitStop[] { };
     return new RetrievedData<IEnumerable<TransitStop>>(resultStops, resultErrors.Count == 0 ? null : resultErrors.Aggregate("", (acc, err) => (acc == "" ? "" : ", ") + err), resultExceptions.Count == 0 ? null : new AggregateException(resultExceptions));
 }
 public override Task<RetrievedData<TransitStop>> CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     var fwtc = new string[] { "1_80439", "1_80431", "1_80438", "1_80432", "1_80437", "1_80433", "3_27814", "3_29410" };
     var stops = await _1_1.Data.ApiLayer.GetTransitStopsForArea(MainMap.Area, new System.Threading.CancellationToken());
     var fwtcStop = new TransitStop() { ID = "FWTC", Position = new LatLon(47.31753, -122.30486), Path = "_vx_HlnniVF??LJ??MF??nIG??MK??LG?", Name = "Federal Way Transit Center" };
     TransitStop.SqlProvider.Insert(fwtcStop, DatabaseManager.MemoryDatabase);
     foreach (var stop in stops)
     {
         var finalStop = stop;
         if (fwtc.Contains(finalStop.ID))
             finalStop.Parent = "FWTC";
         TransitStop.SqlProvider.Insert(finalStop, DatabaseManager.MemoryDatabase);
     }
     LoadFromDatabase();
     //MainGrid.Children.Add(new Controls.StopArrivalsControl() { DataContext = new StopArrivalsViewModel(new TransitStop() { Children = new string[] { "FWTC" }, Name = "Selected Stops" }), Margin = new Thickness(50) });
 }
 protected override void OnStopChanged(TransitStop stop)
 {
     VM.ShowArrivals = true;
     VM.Stop = stop;
 }
 protected virtual void OnStopChanged(TransitStop stop) { }
 public override Task <RetrievedData <TransitStop> > CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken)
 {
     stop.Parent = Stops.FirstOrDefault(st => st.Children?.Contains(stop.ID) ?? false).ID;
     return(Task.FromResult(new RetrievedData <TransitStop>(stop)));
 }
        public TransitCenterDataSource()
        {
            var           assembly     = Assembly.Load(new AssemblyName("CommonClasses"));
            XmlSerializer deserializer = new XmlSerializer(typeof(TransitStop[]), new XmlAttributeOverrides(), TransitStop.GetSerializationTypes().ToArray(), new XmlRootAttribute("TransitStops"), null);

            using (var stream = assembly.GetManifestResourceStream(@"OneAppAway._1_1.XmlDataSources.TransitCenterData.xml"))
            {
                Stops = (TransitStop[])deserializer.Deserialize(stream);
            }
        }
        //private void RegisterArrivalsViewModelCloseEventHandler()
        //{
        //    if (!ArrivalsViewModelCloseEventHandled && ArrivalsViewModel != null)
        //    {
        //        ArrivalsViewModel.Closed += ArrivalsViewModel_Closed;
        //        ArrivalsViewModelCloseEventHandled = true;
        //    }
        //}

        //private void UnregisterArrivalsViewModelCloseEventHandler()
        //{
        //    if (ArrivalsViewModelCloseEventHandled)
        //    {
        //        ArrivalsViewModel.Closed -= ArrivalsViewModel_Closed;
        //        ArrivalsViewModelCloseEventHandled = true;
        //    }
        //}
        #endregion

        #region Functions
        private static TransitStop CombineSeveralStops(LatLon? center, params TransitStop[] stops)
        {
            if (stops.Length == 0)
                throw new ArgumentException("stops needs to contain at least one stop.", "stops");
            if (stops.Length == 1)
                return stops[0];
            TransitStop result = new TransitStop();
            result.Name = $"Selected Stops";
            result.Direction = Data.StopDirection.Unspecified;
            result.ID = stops.Aggregate("", (acc, stop) => acc + "&" + stop.ID).Substring(1);
            result.Position = center ?? stops[0].Position;
            result.Children = stops.Select(stop => stop.ID).ToArray();
            return result;
        }
 private void SetPopup(TransitStop stop)
 {
     ArrivalsPopup.Stop = stop;
     if (ArrivalsPopup.Visibility != Visibility.Visible)
     {
         ArrivalsPopup.Visibility = Visibility.Visible;
         OnMapPopup.Visibility = Visibility.Visible;
         OffMapPopup.Visibility = Visibility.Visible;
         ArrivalsPopup.Offset(offsetY: 0).Fade(value: 1).SetDurationForAll(ANIMATION_DURATION).Start();
     }
     MapControl.SetLocation(OnMapPopup, stop.Position.ToGeopoint());
     SetTakeover(new MapView(stop.Position));
 }
Ejemplo n.º 14
0
 public abstract Task <RetrievedData <TransitStop> > CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken);
 public override Task<RetrievedData<TransitStop>> CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken)
 {
     stop.Parent = Stops.FirstOrDefault(st => st.Children?.Contains(stop.ID) ?? false).ID;
     return Task.FromResult(new RetrievedData<TransitStop>(stop));
 }