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));
 }
        private static void TripLegChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TripDetailListIntermediates _this = d as TripDetailListIntermediates;

            if (_this == null)
            {
                return;
            }

            TripLeg newLeg = e.NewValue as TripLeg;

            if (newLeg == null)
            {
                return;
            }

            if (newLeg.IntermediateStops?.Count > 0)
            {
                _this._backingIntermediatesList = newLeg.IntermediateStops;
                _this._backingSimpleText        = $"{newLeg.IntermediateStops.Count} {AppResources.TripDetailListIntermediates_IntermediateStopsNumber}";
            }
            else
            {
                var distanceString = newLeg.DistanceMeters.ToString("N0");
                if (newLeg.Mode == ApiEnums.ApiMode.Walk)
                {
                    _this._backingSimpleText = String.Format(AppResources.TripDetailListIntermediates_WalkDistance, distanceString);
                }
                else
                {
                    _this._backingSimpleText = String.Format(AppResources.TripDetailListIntermediates_TransitDistance, distanceString);
                }
            }

            if (_this._isShowingIntermediateStops)
            {
                _this.ItemsBackingCollection = new ObservableCollection <TransitStop>(_this._backingIntermediatesList);
            }
            else
            {
                TransitStop simpleTextProxy = new TransitStop {
                    Name = _this._backingSimpleText
                };
                _this.ItemsBackingCollection = new ObservableCollection <TransitStop>();
                _this.ItemsBackingCollection.Add(simpleTextProxy);
            }
            _this.IntermediateStopsControl.ItemsSource = _this.ItemsBackingCollection;
        }
        //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);
        }
 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();
 }
        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) });
        }
Example #6
0
 public StopsListSelectionChanged(TransitStop stop)
 {
     SelectedStop = stop;
 }
 public override Task <RetrievedData <TransitStop> > CorrectTransitStop(TransitStop stop, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
 protected virtual void OnStopChanged(TransitStop stop)
 {
 }
Example #9
0
 protected override void OnStopChanged(TransitStop stop)
 {
     VM.ShowArrivals = true;
     VM.Stop         = stop;
 }
Example #10
0
 public StopSearchElementViewModel(TransitStop backingStop, IMessenger messenger)
 {
     BackingStop = backingStop;
     _messenger  = messenger;
 }