private async Task setNextTrips(DateTime time) { if (Location != null) { if (Near) { var dist = await StopTransfers.WalkDistance(Location, CurrentStop.Coordinate); setDistanceText(Services.Resources.LocalizedStringOf("TripStopDistance"), Location, dist.DistanceInMeters); setNextTripsAtTime(time + dist.EstimatedDuration, time); var newLocation = await CurrentLocation.Get(); if (newLocation != null && newLocation != Location) { this.Location = newLocation; var dist1 = await StopTransfers.WalkDistance(Location, CurrentStop.Coordinate); setDistanceText(Services.Resources.LocalizedStringOf("TripStopDistance"), Location, dist1.DistanceInMeters); setNextTripsAtTime(time + dist1.EstimatedDuration, time); } } else { var dist = await StopTransfers.WalkDistance(SourceStop.Coordinate, CurrentStop.Coordinate); setDistanceText(Services.Resources.LocalizedStringOf("TripTransferDistance"), Location, dist.DistanceInMeters); setNextTripsAtTime(time + dist.EstimatedDuration, time); } } else { setNextTripsAtTime(time, time); } }
public async void SetContent() { ListView.Visibility = Visibility.Collapsed; StatusBar.GetForCurrentView().ProgressIndicator.ProgressValue = null; StatusBar.GetForCurrentView().ProgressIndicator.ShowAsync(); var loc = await CurrentLocation.Get(); StatusBar.GetForCurrentView().ProgressIndicator.HideAsync(); if (loc == null) { if (SettingsModel.LocationServices == false) { showConsentMessage(); } else { showUnavailableMessage(); } } else { ListView.Visibility = Visibility.Visible; await setMostNarrowRange(); initialized = true; } }
private async Task setContentAsync() { ItemsSource.Clear(); this.InProgress = true; if (Near) { this.Location = await CurrentLocation.Get(); } var stopItems = await calculateRoutes(Stop); ItemsSource.Add(createStopHeader(Stop, stopItems, !CurrentTime, Near, Location, ShowTransfers)); this.InProgress = false; }
//private AdControl AdControl; //public void SetPlanningSource(StopGroup stop) //{ //} //public void SetPlanningDestination(StopGroup stop) //{ //} private async void updateContent() { FavoritesPart.UpdateContent(); if (SettingsModel.AutomaticNearSearch) { var nearestStop = await StopTransfers.GetNearestStop(await CurrentLocation.Get()); if (nearestStop != null) { FavoritesPart.NearStop = nearestStop.Stop.Group; PlanningPart.SetNearStop(nearestStop.Stop.Group, nearestStop.EstimatedDuration); } } }
private async Task setMostNarrowRange() { StatusBar.GetForCurrentView().ProgressIndicator.ProgressValue = null; StatusBar.GetForCurrentView().ProgressIndicator.ShowAsync(); for (int i = 0; i < DistanceSelection.Length; i++) { radius = DistanceSelection[i]; var nearStops = (await StopTransfers.NearStops(await CurrentLocation.Get(), radius.Value)).ToList(); if (nearStops.Count > 0) { BtnDist.SelectedItem = radius; ListView.ItemsSource = nearStops.Select(s => new StopModel(s.StopGroup, true)).ToList(); break; } } StatusBar.GetForCurrentView().ProgressIndicator.HideAsync(); }
private async void DoLocationMarking() { GeoCoordinate myLocation = await CurrentLocation.Get(upToDate : true); if (myLocation != null) { if (CurrentPositionLayer != null) { MapControl.Children.Remove(CurrentPositionLayer); } CurrentPositionLayer = createUserMark(); MapControl.SetLocation(CurrentPositionLayer, myLocation.ToGeopoint()); MapControl.SetNormalizedAnchorPoint(CurrentPositionLayer, new Point(0.5, 0.5)); MapControl.Children.Add(CurrentPositionLayer); } }
private async void DoLocationMarking() { GeoCoordinate myLocation = await CurrentLocation.Get(upToDate : true); if (myLocation != null) { if (CurrentPositionLayer != null) { Map.Layers.Remove(CurrentPositionLayer); } MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(new MapOverlay { Content = createUserMark(), PositionOrigin = new Point(0.5, 0.5), GeoCoordinate = MapController.Convert(myLocation) }); CurrentPositionLayer = myLocationLayer; Map.Layers.Add(myLocationLayer); } }
public async void SetListContent() { StatusBar.GetForCurrentView().ProgressIndicator.ProgressValue = null; StatusBar.GetForCurrentView().ProgressIndicator.ShowAsync(); var location = await CurrentLocation.Get(); //logging UniversalDirections.QueryTimes.Clear(); var sw = Stopwatch.StartNew(); var nearStops = await StopTransfers.NearStops(location, radius.Value); sw.Stop(); ListView.ItemsSource = nearStops.Select(s => new StopModel(s.StopGroup, true)).ToList(); ListView.Height = ListView.ItemsSource().Count > 0 ? double.NaN : 0; StatusBar.GetForCurrentView().ProgressIndicator.HideAsync(); PerfLogging.AddRow( "setListContent", sw.Elapsed, UniversalDirections.QueryTimes.Count, UniversalDirections.QueryTimes.Count > 0 ? UniversalDirections.QueryTimes.Average(x => x.TotalMilliseconds) : 0.0); }
public override async void Bind(MapPage page) { base.Bind(page); base.RegisterElementTypes(typeof(StopPushpin)); int stopGroupId = int.Parse(page.NavigationContext.QueryString["stopGroupID"]); if (stopGroupId != 0) { this.stopGroup = App.Model.GetStopGroupByID(stopGroupId); this.mainStops = new HashSet <Stop>(stopGroup.Stops); this.mainPoints = mainStops.Select(s => s.Coordinate).ToArray(); } else { this.fromMainPage = true; if (StopTransfers.LastNearestStop != null) { this.mainPoints = StopTransfers.LastNearestStop.Stop.Group.Stops.Select(s => s.Coordinate).ToArray(); } } string locationStr = null, dateTimeStr = null; if (page.NavigationContext.QueryString.TryGetValue("location", out locationStr)) { this.postQuery.Add("location", locationStr); if (locationStr != "near") { this.sourceStop = App.Model.GetStopByID(int.Parse(locationStr)); this.location = sourceStop.Coordinate; } else { this.location = CurrentLocation.Last; isNear = true; } } if (page.NavigationContext.QueryString.TryGetValue("dateTime", out dateTimeStr)) { this.postQuery.Add("dateTime", dateTimeStr); this.dateTime = System.Convert.ToDateTime(dateTimeStr); isNow = false; } if (isNow) { timeUpdaterTask = new PeriodicTask(DoTimeUpdate); timeUpdaterTask.RunEveryMinute(); page.Tasks.Add(timeUpdaterTask); } if (isNear) { locationUpdaterTask = new PeriodicTask(10000, DoLocationUpdate); locationUpdaterTask.Run(delay: 1000); page.Tasks.Add(locationUpdaterTask); } //foreach (var transfer in transfers) //{ // Microsoft.Phone.Maps.Controls.MapPolyline line = new Microsoft.Phone.Maps.Controls.MapPolyline // { // StrokeColor = Colors.Gray, // StrokeDashed = true, // StrokeThickness = 8 // }; // line.Path.Add(transfer.Origin.Coordinate); // line.Path.AddRange(transfer.InnerPoints.Select(p => new GeoCoordinate(p.Latitude, p.Longitude))); // line.Path.Add(transfer.Target.Coordinate); // Map.MapElements.Add(line); //} this.EmptyMapTap += (sender, args) => clearSelection(); this.MapElementTap += (sender, element) => tapActions[element].Invoke(); var boundAddition = isNear ? new GeoCoordinate[] { CurrentLocation.Last ?? App.Config.CenterLocation } : new GeoCoordinate[0]; var boundaries = calculateBoundaries(mainPoints.Concat(boundAddition)); //await Task.Delay(250); await initializeMapLabels(page); page.Map.SetView(boundaries, MapAnimationKind.None); while (page.Map.ZoomLevel < 15) { page.Map.SetView(boundaries, MapAnimationKind.None); await Task.Delay(100); } //while (page.IsMapEmpty) //{ // initializeMapLabels(page); // await Task.Delay(100); //} page.Map.CenterChanged += async(sender, args) => { await mapFillingLock.WaitAsync(); if (page.Map.ZoomLevel >= App.Config.LowStopsMapLevel) { var newLocation = page.Map.Center; await tryCreateStopLabelsAt(page, Convert(newLocation)); } else if (page.Map.ZoomLevel >= App.Config.HighStopsMapLevel) { var newLocation = page.Map.Center; await tryCreateHighStopLabelsAt(page, Convert(newLocation)); clearMap(page, 2.1); } else { clearMap(page); } mapFillingLock.Release(); }; if (isNear && stopGroupId == 0 && mainPoints.Length == 0) { var nearestResult = await StopTransfers.GetNearestStop(await CurrentLocation.Get()); if (nearestResult != null) { this.location = CurrentLocation.Last; this.mainPoints = nearestResult.Stop.Group.Stops.Select(s => s.Coordinate).ToArray(); boundAddition = new GeoCoordinate[] { CurrentLocation.Last ?? App.Config.CenterLocation }; boundaries = calculateBoundaries(mainPoints.Concat(boundAddition)); page.Map.SetView(boundaries, MapAnimationKind.None); await initializeMapLabels(page); } } }