Example #1
0
        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
                    }
                }
            };
        }
Example #2
0
        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
                    }
                }
            };
        }
Example #3
0
        public App()
        {
            // The root page of your application
            Console.WriteLine(Utility.GetUserId());
            MapUtil.UpdateDelays();
            TaMap page = new TaMap();

            NavigationPage.SetHasNavigationBar(page, false);
            MainPage = page;
        }