private void DetailedTripList_OnItemClick(object sender, ItemClickEventArgs e)
        {
            ListView list = sender as ListView;

            if (list == null)
            {
                return;
            }

            //Frame clicked point on the map
            TripLeg clickedLeg   = (TripLeg)e.ClickedItem;
            var     boundingBox  = SingleMap.GetBoundingBoxWithIds(clickedLeg.TemporaryId);
            double  bottomMargin = DirectionsFloatingPanel.IsOpen ? DirectionsFloatingPanel.ExpandedHeight + 10 : 10;

            SingleMap.TrySetViewBoundsAsync(boundingBox, new Thickness(10, 10, 10, bottomMargin), MapAnimationKind.Bow).DoNotAwait();

            //Expand intermediate stops of clicked leg
            var element = list.ContainerFromItem(e.ClickedItem);
            var intermediatesControl = element.FindChild <TripDetailListIntermediates>("IntermediateStops");

            if (intermediatesControl != null)
            {
                intermediatesControl.ToggleViewState();
            }
        }
Example #2
0
        private void SaveRoute(TripItinerary routeToSave)
        {
            var route = new FavoriteRoute
            {
                FontIconGlyph  = FontIconGlyphs.FilledStar,
                Id             = Guid.NewGuid(),
                IconFontFace   = Constants.SegoeMdl2FontName,
                IconFontSize   = Constants.SymbolFontSize,
                UserChosenName = $"{routeToSave.StartingPlaceName} → {routeToSave.EndingPlaceName}",
            };

            TripLeg startPlace = routeToSave.ItineraryLegs.First();
            TripLeg endPlace   = routeToSave.ItineraryLegs.Last();
            var     places     = new List <SimpleFavoritePlace>();

            places.Add(new SimpleFavoritePlace
            {
                Lat  = startPlace.StartCoords.Latitude,
                Lon  = startPlace.StartCoords.Longitude,
                Name = routeToSave.StartingPlaceName,
                Type = ModelEnums.PlaceType.FavoritePlace
            });
            places.Add(new SimpleFavoritePlace
            {
                Lat  = endPlace.EndCoords.Latitude,
                Lon  = endPlace.EndCoords.Longitude,
                Name = routeToSave.EndingPlaceName,
                Type = ModelEnums.PlaceType.FavoritePlace
            });

            route.RoutePlaces          = places;
            route.RouteGeometryStrings = routeToSave.RouteGeometryStrings.ToList();
            _favoritesService.AddFavorite(route);
        }
Example #3
0
        public ServiceResponse AddLeg(TripLeg leg)
        {
            try
            {
                using (var connection = new SqlConnection(DatabaseUtilities.GetConnectionString(this._configuration)))
                {
                    connection.Open();

                    using (var command = new SqlCommand("dbo.uspInsertLeg", connection))
                    {
                        command.ExecuteNonQuery();
                    }
                }

                return(new ServiceResponse
                {
                    Code = HttpStatusCode.Created,
                    Message = "Success! Added leg."
                });
            } catch (SqlException exception)
            {
                // Add Logging
            }

            return(new ServiceResponse
            {
                Code = HttpStatusCode.InternalServerError,
                Message = "Failed to add leg."
            });
        }
        private void TransitIconButtonHost_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                TripLeg tappedLeg = button.DataContext as TripLeg;
                if (tappedLeg != null)
                {
                    ViewModel.SearchForLineCommand.Execute(tappedLeg.RouteGtfsId);
                }
            }
        }
        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;
        }
Example #6
0
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            TripLeg leg = item as TripLeg;

            if (leg == null)
            {
                throw new ArgumentException($"{nameof(DetailedTripListLegItemTemplateSelector)} expects only items of type {nameof(TripLeg)}");
            }

            if (leg.IsEnd)
            {
                return(EndLegTemplate);
            }
            else
            {
                return(StartOrMiddleLegTemplate);
            }
        }