private MapContent() { Trips = MapUtil.GetDefaultTripFile(); TripPointers = new int[Trips.Count]; Console.WriteLine("Est. Screen size: " + App.GetScreenWidth() + ", " + App.GetScreenHeight()); Map = new DefaultMap(); FavoritesButton = new Button { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, WidthRequest = 50, HeightRequest = 50, Image = (FileImageSource)(ImageSource.FromFile("Star_Button.png")), BackgroundColor = new Color(0, 1, 0), Margin = new Thickness(10, 0, 0, 10), #if __IOS__ CornerRadius = 25, #endif }; SettingsButton = new Button { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End, WidthRequest = 50, HeightRequest = 50, Image = (FileImageSource)(ImageSource.FromFile("Settings_Button.png")), BackgroundColor = new Color(0, 1, 0), Margin = new Thickness(0, 0, 10, 10), #if __IOS__ CornerRadius = 25, #endif }; var rightNow = new StopTime(DateTime.Now); for (var a = 0; a < Trips.Count; a++) { var isDelayed = MapUtil.IsTripDelayed(Trips[a].Id); Utility.Vertex vert = Trips[a].GetBusLocation(rightNow); TripPointers[a] = Map.Pins.Count; if (vert == null) { continue; } vert.Pin(Map.Pins, (!_taggedRandomBus || isDelayed) ? Map.DelayedBusIndices : null, Trips[a].Id); _taggedRandomBus = true; } MapUtil.Favorites.OnFavouriteAdded += UpdateServer; Content = new ContentPage { Content = new Grid { Children = { Map, FavoritesButton, SettingsButton } } }; }
public FavouriteTripDisplay(NavigationPage page, DefaultMap map, int tripId) { Map = map; NavPage = page; var isFavorite = MapUtil.Favorites.Contains(tripId); var isDelayed = MapUtil.IsTripDelayed(tripId); Trip = Trips.GetTripWithTripId(tripId); _favouriteButton = new Button { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Image = isFavorite ? StarDisabled : StarAccept, IsEnabled = !isFavorite, Margin = new Thickness(0, 40, 0, 0) }; _issueLabel = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, Text = isDelayed ? "Delayed by " + (MapUtil.DelayTable[tripId] / 60) + " minute(s)." : "On Schedule", Margin = new Thickness(0, 20, 0, 0), TextColor = isDelayed ? Red : Blue }; _gotoButton = new Button { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, Text = "Go to Bus..." }; _favouriteButton.Clicked += OnFavourite; _gotoButton.Clicked += OnGoto; //TODO just realised this is kinda redundant Content=Content= Content = new ContentPage { Content = new StackLayout { Children = { new Label { Margin = new Thickness(0, 40, 0, 0), HorizontalOptions = LayoutOptions.Center, Text = Trip.Route.Name }, new Label { HorizontalOptions = LayoutOptions.Center, Text = Trip.Id + " (" + Trip.ListStopTimeRangeAsString() + ")" }, _favouriteButton, _issueLabel, _gotoButton } } }; }
public FavouriteContent(NavigationPage page, DefaultMap map) { Map = map; NavPage = page; var routeList = new ListView { ItemsSource = GenTableContent() }; routeList.ItemSelected += ItemSelected; Content = new ContentPage { Content = new Grid { Children = { routeList } } }; }
public FavouriteSubContent(NavigationPage page, DefaultMap map, int routeId) { Map = map; NavPage = page; var timeList = new ListView { ItemsSource = GenTableContent(routeId) }; timeList.ItemSelected += ItemSelected; Content = new ContentPage { Content = new Grid { Children = { timeList } } }; }
public MyFavourites(NavigationPage page, DefaultMap map) { Map = map; NavPage = page; _favList = new ListView { ItemsSource = GenTableContent() }; _favList.ItemSelected += ItemSelected; MapUtil.Favorites.OnFavouriteAdded += Refresh; Content = new ContentPage { Content = new Grid { Children = { _favList } } }; }