Exemple #1
0
        public MenuPage()
        {
            InitializeComponent();

            client = new HttpClient();
            client.MaxResponseContentBufferSize = 256000;

            if (Application.Current.Properties.ContainsKey("map"))
            {
                map = (GMTEMap)Application.Current.Properties["map"];
            }

            else
            {
                map = new GMTEMap();
            }

            scroll = new ScrollView();
            stack  = new StackLayout {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new Image
                    {
                        VerticalOptions   = LayoutOptions.Center,
                        HorizontalOptions = LayoutOptions.Center,
                        Source            = "splash_logo.jpg",
                        Scale             = 0.8
                    },

                    new Label
                    {
                        Text              = "Transportation Experience",
                        TextColor         = Color.White,
                        FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                        FontFamily        = Device.OnPlatform("AppleSDGothicNeo-UltraLight", "Droid Sans Mono", "Comic Sans MS"),
                        HorizontalOptions = LayoutOptions.Center,
                    },
                    new Label
                    {
                        Text = " "
                    },
                }
            };

            scroll.Content  = stack;
            Content         = scroll;
            Title           = "None";
            BackgroundColor = Color.FromRgb(104, 151, 243);
            Icon            = Device.OS == TargetPlatform.iOS ? "menu.png" : null;
        }
Exemple #2
0
        // add all campus which come from API and show them in the menu page
        public void AddButtons()
        {
            if (Application.Current.Properties.ContainsKey("map"))
            {
                map = (GMTEMap)Application.Current.Properties["map"];
            }

            for (int i = stack.Children.Count - 1; i >= 2; i--)
            {
                stack.Children.RemoveAt(i);
            }

            var campusList = map.GetCampusList();

            foreach (string name in campusList)
            {
                var click = new MenuButtons(name);
                stack.Children.Add(click);
            }
        }
Exemple #3
0
        // make sure the app is still working while the phone is in sleeping mode
        protected override void OnSleep()
        {
            if (Application.Current.Properties.ContainsKey("map"))
            {
                map = (GMTEMap)Application.Current.Properties["map"];
            }

            else
            {
                map = new GMTEMap()
                {
                    IsShowingUser   = true,
                    HeightRequest   = 100,
                    WidthRequest    = 960,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    HasZoomEnabled  = true
                };
            }



            // check geolocation
            CrossGeolocator.Current.PositionChanged += (o, args) =>
            {
                // check campus
                if ((map.CheckInGeofences(args.Position)) &&
                    (onCampus == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        mCurrentCampus = map.InWhichGeofences(args.Position);
                        //DisplayAlert("Welcome to " + mCurrentCampus + "!", "We hope you find your way around!", "Okay");
                    });
                    onCampus = true;
                }

                else if ((map.CheckInGeofences(args.Position) == false) &&
                         (onCampus == true))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        //DisplayAlert("Now leaving " + mCurrentCampus, "Did you mean to do that?", "Maybe?");
                        onCampus       = false;
                        mCurrentCampus = "";
                    });
                }
                // check parking lot
                if (map.CheckInLotGeofences(args.Position, mCurrentCampus) && (mParked == false) && (inLot == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        mCurrentLot = map.InWhichLot(args.Position, mCurrentCampus);
                        //DisplayAlert("You are in lot " + mCurrentLot + "!", "We hope you find a spot!", "Okay");
                    });

                    inLot = true;
                }

                if ((mParked) && (mShown == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        //DisplayAlert("You Parked!", "We detected that you parked in " + mLotParked, "Okay");
                    });
                    mShown = true;
                }

                if ((map.InWhichLot(args.Position, mCurrentCampus) != mCurrentLot) && (mCurrentLot != "") &&
                    (mTimerStarted == false) && (mParked == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        //DisplayAlert("Now leaving " + mCurrentLot, "Start parking-detection algorithm", "Start");
                    });
                    mLotParked    = mCurrentLot;
                    mCurrentLot   = "";
                    mTimerStarted = true;

                    if (map.CheckInLotGeofences(args.Position, mCurrentCampus))
                    {
                        inLot = true;
                    }

                    else
                    {
                        inLot = false;
                    }

                    //Device.StartTimer(TimeSpan.FromSeconds(.5), new Func<bool>(() => CheckSpeed(args.Position)));
                }

                if ((map.CheckInLotGeofences(args.Position, mCurrentCampus) == false) && (mParked == false))
                {
                    mCurrentLot = "";
                    inLot       = false;
                }
            };
        }
        // constructor
        public EnterUserInfoPage(string campus)
        {
            // initialize map
            map = (GMTEMap)Application.Current.Properties["map"];

            // UI
            NavigationPage.SetBackButtonTitle(this, "");
            this.campusName      = campus;
            Title                = "Preference";
            this.BackgroundColor = Color.FromRgb(104, 151, 243);
            var scroll = new ScrollView();
            var grid   = new Grid {
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            grid.RowDefinitions.Add(new RowDefinition {
                Height = 80
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = 80
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = 80
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 80
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 200
            });

            string font;

            switch (Device.RuntimePlatform)
            {
            case "iOS":
                font = "AppleSDGothicNeo-UltraLight";
                break;

            case "Android":
                font = "Droid Sans Mono";
                break;

            default:
                font = "Comic Sans MS";
                break;
            }
            // create pickers
            var labelC = new Label
            {
                Text            = "Campus: ",
                TextColor       = Color.White,
                FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes  = FontAttributes.Bold,
                FontFamily      = font,
                VerticalOptions = LayoutOptions.Center,
            };

            grid.Children.Add(labelC, 0, 0);
            var labelN = new Label
            {
                Text            = this.campusName,
                TextColor       = Color.White,
                FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes  = FontAttributes.Bold,
                FontFamily      = font,
                VerticalOptions = LayoutOptions.Center,
            };

            grid.Children.Add(labelN, 1, 0);
            var labelR = new Label
            {
                Text            = "Role: ",
                TextColor       = Color.White,
                FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes  = FontAttributes.Bold,
                FontFamily      = font,
                VerticalOptions = LayoutOptions.Center,
            };

            grid.Children.Add(labelR, 0, 1);
            var rolePicker = new Picker
            {
                Title           = "Select Your Role",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            var roles = map.GetRoles(campusName);

            foreach (Role r in roles)
            {
                rolePicker.Items.Add(r.GetName());
            }
            rolePicker.SelectedIndexChanged += (sender, args) =>
            {
                if (rolePicker.SelectedIndex == -1)
                {
                    this.role = "False";
                }
                else
                {
                    this.role = rolePicker.Items[rolePicker.SelectedIndex];
                }
            };
            grid.Children.Add(rolePicker, 1, 1);
            var labelB = new Label
            {
                Text            = "Building: ",
                TextColor       = Color.White,
                FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes  = FontAttributes.Bold,
                FontFamily      = font,
                VerticalOptions = LayoutOptions.Center,
            };

            grid.Children.Add(labelB, 0, 2);
            var buildingPicker = new Picker
            {
                Title           = "Select Your Building",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            var buildings = map.GetBuildingList(campusName);

            foreach (string b in buildings)
            {
                buildingPicker.Items.Add(b);
            }

            // display selected role if users already saved their preference
            if (Application.Current.Properties.ContainsKey(campus + "role"))
            {
                int i = 0;
                foreach (string item in rolePicker.Items)
                {
                    if (item == (string)Application.Current.Properties[campus + "role"])
                    {
                        rolePicker.SelectedIndex = i;
                    }
                    i += 1;
                }
            }
            if (Application.Current.Properties.ContainsKey(campus + "building"))
            {
                int i = 0;
                foreach (string item in buildingPicker.Items)
                {
                    if (item == (string)Application.Current.Properties[campus + "building"])
                    {
                        buildingPicker.SelectedIndex = i;
                    }
                    i += 1;
                }
            }
            buildingPicker.SelectedIndexChanged += (sender, args) =>
            {
                if (buildingPicker.SelectedIndex == -1)
                {
                    this.building = "False";
                }
                else
                {
                    this.building = buildingPicker.Items[buildingPicker.SelectedIndex];
                }
            };
            grid.Children.Add(buildingPicker, 1, 2);

            // button for saving all user's preference
            Button saveButton = new Button {
                Text            = "Save",
                Font            = Font.SystemFontOfSize(NamedSize.Large),
                TextColor       = Color.White,
                BackgroundColor = Color.Transparent,
                FontFamily      = font,
                BorderWidth     = 1,
                BorderColor     = Color.White,
                Margin          = new Thickness(4, 4, 4, 4)
            };

            saveButton.Clicked += OnClicked;
            var stack = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    grid,
                    new Label {
                        Text = " "
                    },
                    saveButton
                }
            };

            scroll.Content = stack;
            Content        = scroll;
        }
Exemple #5
0
        public MapPage(string selectedRole, string buildingName, string campusName)
        {
            InitializeComponent();

            mCampusName   = campusName;
            mBuildingName = buildingName;
            mRole         = selectedRole;
            this.Title    = mBuildingName;

            if (Application.Current.Properties.ContainsKey("map"))
            {
                map = (GMTEMap)Application.Current.Properties["map"];
            }

            else
            {
                // Creates campuses objects and draws them
                map.AddCampus(campusName);

                // Assigns title of page to building that is to be going to
                this.Title = buildingName;

                Task addBuild = map.DrawBuildings(campusName);
                map.DrawLots(campusName);
            }

            string font;

            switch (Device.RuntimePlatform)
            {
            case "iOS":
                font = "AppleSDGothicNeo-UltraLight";
                break;

            case "Android":
                font = "Droid Sans Mono";
                break;

            default:
                font = "Comic Sans MS";
                break;
            }

            client = new HttpClient();
            client.MaxResponseContentBufferSize = 256000;

            var lotTask = GetLotOrder();

            var lotLabel = new Label
            {
                FontFamily = font,
                TextColor  = Color.Blue
            };

            var goingToLabel = new Label
            {
                FontFamily = font,
                TextColor  = Color.Green,
            };

            lotLabel.SetBinding(Label.TextProperty, new Binding("Lots", stringFormat: "{0}"));
            goingToLabel.SetBinding(Label.TextProperty, new Binding("GoingTo", stringFormat: "Going to: {0}"));

            var button = new Button()
            {
                Text             = "Start Directions!",
                Font             = Font.SystemFontOfSize(NamedSize.Large),
                FontFamily       = font,
                CommandParameter = new double()
            };

            button.Clicked += OnClicked;
            button.SetBinding(Button.CommandParameterProperty, new Binding("Pos"));

            stack.Children.Add(lotLabel);
            stack.Children.Add(goingToLabel);
            stack.Children.Add(map);
            stack.Children.Add(button);
            stack.BindingContext = new { Lots = "Retrieving closest lots..." };

            stack.BindingContext = stack.Children[0].BindingContext;

            this.Content = stack;

            Task stackTask = ConvertLots(lotTask);

            AwaitTask(stackTask);

            map.SpanToBuilding(buildingName, campusName);

            StartGeoLocation();

            CrossGeolocator.Current.PositionChanged += (o, args) =>
            {
                if ((map.CheckInGeofences(args.Position)) &&
                    (onCampus == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        mCurrentCampus = map.InWhichGeofences(args.Position);
                        DisplayAlert("Welcome to " + mCurrentCampus + "!", "We hope you find your way around!", "Okay");
                        DependencyService.Get <ITextToSpeech>().Speak("Welcome to " + mCurrentCampus);
                        onCampus = true;
                    });
                }

                else if ((map.CheckInGeofences(args.Position) == false) &&
                         (onCampus == true))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        DisplayAlert("Now leaving " + mCurrentCampus, "Did you mean to do that?", "Maybe?");
                        onCampus       = false;
                        mCurrentCampus = "";
                    });
                }

                if (map.CheckInLotGeofences(args.Position, mCurrentCampus) && (mParked == false) && (inLot == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        mCurrentLot = map.InWhichLot(args.Position, mCurrentCampus);
                        DisplayAlert("You are in lot " + mCurrentLot + "!", "We hope you find a spot!", "Okay");
                        DependencyService.Get <ITextToSpeech>().Speak("You are in lot " + mCurrentLot);
                    });

                    inLot = true;
                }

                if ((mParked) && (mShown == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        DisplayAlert("You Parked!", "We detected that you parked in " + mLotParked, "Okay");
                        DependencyService.Get <ITextToSpeech>().Speak("You Parked in " + mLotParked);
                    });
                    mShown = true;
                }

                if ((map.InWhichLot(args.Position, mCurrentCampus) != mCurrentLot) && (mCurrentLot != "") &&
                    (mTimerStarted == false) && (mParked == false))
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        DisplayAlert("Now leaving " + mCurrentLot, "Start parking-detection algorithm", "Start");
                    });
                    mLotParked    = mCurrentLot;
                    mCurrentLot   = "";
                    mTimerStarted = true;

                    if (map.CheckInLotGeofences(args.Position, mCurrentCampus))
                    {
                        inLot = true;
                    }

                    else
                    {
                        inLot = false;
                    }

                    Device.StartTimer(TimeSpan.FromSeconds(.5), new Func <bool>(() => CheckSpeed(args.Position)));
                }

                if ((map.CheckInLotGeofences(args.Position, mCurrentCampus) == false) && (mParked == false))
                {
                    mCurrentLot = "";
                    inLot       = false;
                }
            };
        }