protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Initialisation
            RtGraphicsLayouts = new RtGraphicsLayouts(this);
            RtGraphicsLayouts.SetColourStatusBar(Window, RtGraphicsColours.Orange);

            //Root
            LinearLayout RootLayout = new LinearLayout(this);

            RootLayout.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            RootLayout.Orientation      = Orientation.Vertical;
            SetContentView(RootLayout);

            //Navbar
            LinearLayout NavbarLayout = new LinearLayout(this);

            NavbarLayout.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, NAVBARHEIGHT);
            NavbarLayout.SetBackgroundColor(RtGraphicsColours.Orange);
            RootLayout.AddView(NavbarLayout);

            LinearLayout NavbarBack = new LinearLayout(this);

            NavbarBack.LayoutParameters = RtGraphicsLayouts.LayoutParameters(NAVBARHEIGHT, NAVBARHEIGHT);
            NavbarBack.SetBackgroundResource(Resource.Drawable.IconBack);
            NavbarBack.Click += NavbarBack_Click;;
            NavbarLayout.AddView(NavbarBack);

            TextView NavBarTitle = new TextView(this);

            NavBarTitle.LayoutParameters = RtGraphicsLayouts.LayoutParameters(-140, RtGraphicsLayouts.EXPAND);
            NavBarTitle.SetDpPadding(RtGraphicsLayouts, NAVBARPADDING, NAVBARPADDING, NAVBARHEIGHT + NAVBARPADDING, NAVBARPADDING);
            NavBarTitle.Gravity = GravityFlags.Center;
            NavBarTitle.Format(RtGraphicsExt.TextFormats.Heading);
            NavBarTitle.Text = NAVBARTEXT;
            NavbarLayout.AddView(NavBarTitle);

            //Content
            ScrollView ContentScrollerRoot = new ScrollView(this);

            ContentScrollerRoot.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            RootLayout.AddView(ContentScrollerRoot);

            LinearLayout ContentScrollRoot = new LinearLayout(this);

            ContentScrollRoot.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.CONTAIN);
            ContentScrollRoot.Orientation      = Orientation.Vertical;
            ContentScrollerRoot.AddView(ContentScrollRoot);

            LinearLayout NavbarTitleBorder = new LinearLayout(this);

            NavbarTitleBorder.SetBackgroundColor(RtGraphicsColours.OrangeDim);
            NavbarTitleBorder.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            NavbarTitleBorder.SetDpPadding(RtGraphicsLayouts, SMALLPADDING, SMALLPADDING, SMALLPADDING, SMALLPADDING);
            ContentScrollRoot.AddView(NavbarTitleBorder);

            EditText NavBarTitleSearch = new EditText(this);

            NavBarTitleSearch.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            //NavBarTitle.SetDpPadding(RtGraphicsLayouts, NAVBARPADDING, NAVBARPADDING, NAVBARHEIGHT + NAVBARPADDING, NAVBARPADDING);
            //NavBarTitleSearch.SetBackgroundColor(RtGraphicsColours.GreyLightest);
            NavBarTitleSearch.Background.SetColorFilter(RtGraphicsColours.OrangeDim, PorterDuff.Mode.SrcIn);
            NavBarTitleSearch.SetHintTextColor(RtGraphicsColours.Orange);
            NavBarTitleSearch.Format(RtGraphicsExt.TextFormats.Heading);
            NavBarTitleSearch.SetTextColor(RtGraphicsColours.GreyLightest);
            NavBarTitleSearch.Hint              = NAVBARTEXT;
            NavBarTitleSearch.AfterTextChanged += NavBarTitle_AfterTextChanged;
            NavbarTitleBorder.AddView(NavBarTitleSearch);

            ContentRoot = new LinearLayout(this);
            ContentRoot.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.CONTAIN);
            ContentRoot.Orientation      = Orientation.Vertical;
            ContentRoot.SetDpPadding(RtGraphicsLayouts, SMALLPADDING, SMALLPADDING, SMALLPADDING, SMALLPADDING);
            ContentScrollRoot.AddView(ContentRoot);
        }
Esempio n. 2
0
        private LinearLayout GenerateStationSelectionBox(StationSelectionBoxType StationSelectionBoxType)
        {
            //From Back
            LinearLayout FromBack = new LinearLayout(this);

            FromBack.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, 400);
            FromBack.Orientation      = Orientation.Vertical;
            FromBack.SetBackgroundResource(Resource.Drawable.StyleCornerBox);
            //FromBack.SetDpPadding(RtGraphicsLayouts, BIGPADDING, BIGPADDING, BIGPADDING, BIGPADDING);

            //From Station
            LinearLayout FromStationBack = new LinearLayout(this);

            FromStationBack.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromStationBack.Orientation      = Orientation.Vertical;
            FromStationBack.Visibility       = ViewStates.Gone;
            FromBack.AddView(FromStationBack);

            LinearLayout FromStationBar = new LinearLayout(this);

            FromStationBar.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, 100);
            FromStationBar.SetDpPadding(RtGraphicsLayouts, 10, 10, 10, 10);
            FromStationBack.AddView(FromStationBar);

            TextView FromStationText = new TextView(this);

            FromStationText.LayoutParameters = RtGraphicsLayouts.LayoutParameters(-(10 + 10 + SMALLPADDING + SMALLPADDING + 80), RtGraphicsLayouts.EXPAND);
            FromStationText.Format(RtGraphicsExt.TextFormats.Paragraph2);
            FromStationText.SetDpPadding(RtGraphicsLayouts, 25, 0, 0, 0);
            FromStationText.Gravity = GravityFlags.CenterVertical;
            FromStationText.Text    = "Not Set";
            FromStationBar.AddView(FromStationText);

            ImageView FromStationIcon = new ImageView(this);

            FromStationIcon.LayoutParameters = RtGraphicsLayouts.LayoutParameters(80, 80);
            FromStationIcon.SetImageResource(Resource.Drawable.IconCancel);
            FromStationBar.AddView(FromStationIcon);

            LinearLayout FromStationBarSeperator = new LinearLayout(this);

            FromStationBarSeperator.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, 2);
            FromStationBarSeperator.SetBackgroundColor(RtGraphicsColours.GreyLightest);
            FromStationBack.AddView(FromStationBarSeperator);

            TextView FromStationNoNav = new TextView(this);

            FromStationNoNav.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromStationNoNav.Gravity          = GravityFlags.Center;
            FromStationNoNav.Format(RtGraphicsExt.TextFormats.Paragraph1);
            FromStationNoNav.Text = "This station doesn't support navigation.";
            FromStationBack.AddView(FromStationNoNav);

            StationFacilitiesView StationFacilitiesView = new StationFacilitiesView(this);

            StationFacilitiesView.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromStationBack.AddView(StationFacilitiesView);

            //From Search
            LinearLayout FromSearchBack = new LinearLayout(this);

            FromSearchBack.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromSearchBack.Orientation      = Orientation.Vertical;
            FromBack.AddView(FromSearchBack);

            RelativeLayout FromSearchBar = new RelativeLayout(this);

            FromSearchBar.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, 100);
            FromSearchBar.SetDpPadding(RtGraphicsLayouts, 10, 10, 10, 10);
            FromSearchBack.AddView(FromSearchBar);

            ImageView FromSearchbarIcon = new ImageView(this);

            FromSearchbarIcon.LayoutParameters = RtGraphicsLayouts.LayoutParameters(80, 80);
            FromSearchbarIcon.SetImageResource(Resource.Drawable.IconSearch);
            FromSearchBar.AddView(FromSearchbarIcon);

            EditText FromSearchBox = new EditText(this);

            FromSearchBox.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromSearchBox.SetDpPadding(RtGraphicsLayouts, 80 + SMALLPADDING, 0, 0, 0);
            FromSearchBox.Background.SetColorFilter(Android.Graphics.Color.White, Android.Graphics.PorterDuff.Mode.SrcIn);
            FromSearchBox.Format(RtGraphicsExt.TextFormats.Paragraph2);
            FromSearchBox.Hint = (StationSelectionBoxType == StationSelectionBoxType.From) ? "From" : "To";
            FromSearchBar.AddView(FromSearchBox);

            LinearLayout FromSearchBarSeperator = new LinearLayout(this);

            FromSearchBarSeperator.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, 2);
            FromSearchBarSeperator.SetBackgroundColor(RtGraphicsColours.GreyLightest);
            FromSearchBack.AddView(FromSearchBarSeperator);

            TextView FromSearchEmpty = new TextView(this);

            FromSearchEmpty.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            FromSearchEmpty.Gravity          = GravityFlags.Center;
            FromSearchEmpty.Format(RtGraphicsExt.TextFormats.Paragraph1);
            FromSearchEmpty.Text = "Search above for a station.";
            FromSearchBack.AddView(FromSearchEmpty);

            ScrollView FromSearchResultsScroll = new ScrollView(this);

            FromSearchResultsScroll.Visibility = ViewStates.Gone;
            FromSearchBack.AddView(FromSearchResultsScroll);

            LinearLayout FromSearchResultsBack = new LinearLayout(this);

            FromSearchResultsBack.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.CONTAIN);
            FromSearchResultsBack.Orientation      = Orientation.Vertical;
            FromSearchResultsScroll.AddView(FromSearchResultsBack);

            //Event Handlers
            FromStationIcon.Click += delegate
            {
                FromStationBack.Visibility = ViewStates.Gone;
                FromSearchBack.Visibility  = ViewStates.Visible;

                if (StationSelectionBoxType == StationSelectionBoxType.From)
                {
                    FromStationCode = "";
                    FromStationname = "";
                }
                else
                {
                    ToStationCode = "";
                    ToStationname = "";
                }

                StationSelectionChanged();
            };
            FromSearchBox.AfterTextChanged += delegate
            {
                if (FromSearchBox.Length() > 1)
                {
                    DrawSearchResults(FromSearchResultsBack, FromSearchBox, FromSearchBack, FromStationBack, FromStationText, FromStationNoNav, FromSearchBox.Text, StationSelectionBoxType, StationFacilitiesView); FromSearchResultsScroll.Visibility = ViewStates.Visible; FromSearchEmpty.Visibility = ViewStates.Gone;
                }
                else
                {
                    FromSearchResultsScroll.Visibility = ViewStates.Gone;
                    FromSearchEmpty.Visibility         = ViewStates.Visible;
                }

                if (StationSelectionBoxType == StationSelectionBoxType.From)
                {
                    ContentScrollerRoot.SmoothScrollTo(0, 0);
                }
                else
                {
                    ContentScrollerRoot.SmoothScrollTo(0, 1000000);
                }
            };

            return(FromBack);
        }
        //Creates the view
        private void GenerateView()
        {
            //Dialog Shaded Back
            _RootView = new LinearLayout(this.Context);
            _RootView.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            _RootView.SetDpPadding(RtGraphicsLayouts, DIALOGPADDING, DIALOGPADDING, DIALOGPADDING, DIALOGPADDING);
            _RootView.SetBackgroundColor(RtGraphicsColours.SemiTransparentBlack);
            _RootView.Visibility = ViewStates.Gone;
            _RootView.SetGravity(GravityFlags.Center);

            //Dialog Back
            LinearLayout DialogLayout = new LinearLayout(this.Context);

            DialogLayout.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            DialogLayout.Orientation      = Orientation.Vertical;
            DialogLayout.SetBackgroundResource(Resource.Drawable.StyleCornerBox);
            _RootView.AddView(DialogLayout);

            //Dialog Top Bar
            LinearLayout DialogTopBar = new LinearLayout(this.Context);

            DialogTopBar.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, DIALOGHORIZONTALSHEIGHT);
            DialogTopBar.SetDpPadding(RtGraphicsLayouts, ZERO, SMALLPADDING, ZERO, SMALLPADDING);
            DialogLayout.AddView(DialogTopBar);

            //Location Icon
            ImageView DialogLocation = new ImageView(this.Context);

            DialogLocation.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogLocation.SetImageResource((Option_SearchLocation) ? Resource.Drawable.Icon_Location : Resource.Drawable.Icon_LocationFaded);
            DialogTopBar.AddView(DialogLocation);

            //Navigable Icon
            ImageView DialogNavigatable = new ImageView(this.Context);

            DialogNavigatable.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogNavigatable.SetImageResource((Option_SearchNavigable) ? Resource.Drawable.Icon_Navigation : Resource.Drawable.Icon_NavigationFaded);
            DialogTopBar.AddView(DialogNavigatable);

            //Cancel Icon
            ImageView DialogCancel = new ImageView(this.Context);

            DialogCancel.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogCancel.SetImageResource(Resource.Drawable.IconCancel);
            DialogTopBar.AddView(DialogCancel);

            //Search Input
            SearchInput = new EditText(this.Context);
            SearchInput.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, DIALOGHORIZONTALSHEIGHT);
            SearchInput.SetDpPadding(RtGraphicsLayouts, DIALOGPADDING, SMALLPADDING, DIALOGPADDING, SMALLPADDING);
            SearchInput.SetBackgroundColor(RtGraphicsColours.Orange);
            SearchInput.Format(RtGraphicsExt.TextFormats.Heading);
            DialogLayout.AddView(SearchInput);

            //Results Scroller
            ScrollView ResultsScroll = new ScrollView(this.Context);

            DialogLayout.AddView(ResultsScroll);

            //Results Root
            LinearLayout ResultsRoot = new LinearLayout(this.Context);

            ResultsRoot.Orientation = Orientation.Vertical;
            ResultsScroll.AddView(ResultsRoot);

            //GPS Instance
            RtGPS GPS = new RtGPS((LocationManager)ContextWrapper.GetSystemService(ContextWrapper.LocationService));

            //Event Handlers
            _RootView.Click              += delegate { CloseDialog(); };
            DialogCancel.Click           += delegate { CloseDialog(); };
            SearchInput.AfterTextChanged += delegate { DrawResults(ResultsRoot, GPS); };
            DialogLocation.Click         += delegate { ToggleLocationOption(DialogLocation); };
            DialogNavigatable.Click      += delegate { ToggleNavigableOption(DialogNavigatable); };
        }