public HomePage(CarouselLayout.IndicatorStyleEnum indicatorStyle)
        {
            _indicatorStyle = indicatorStyle;

            viewModel      = new SwitcherPageViewModel();
            BindingContext = viewModel;

            Title = _indicatorStyle.ToString();

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            var pagesCarousel = CreatePagesCarousel();
            var dots          = CreatePagerIndicatorContainer();

            _tabs = CreateTabs();

            switch (pagesCarousel.IndicatorStyle)
            {
            case CarouselLayout.IndicatorStyleEnum.Dots:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height / 2); })
                                            );

                relativeLayout.Children.Add(dots,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToView(pagesCarousel,
                                                                      (parent, sibling) => { return(sibling.Height - 18); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(18)
                                            );
                break;

            case CarouselLayout.IndicatorStyleEnum.Tabs:
                var tabsHeight = 50;
                relativeLayout.Children.Add(_tabs,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(tabsHeight)
                                            );

                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height)); })
                                            );
                break;

            default:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height); })
                                            );
                break;
            }

            Content = relativeLayout;
        }
        public HomePage(CarouselLayout.IndicatorStyleEnum indicatorStyle)
        {
            _indicatorStyle = indicatorStyle;

            _viewModel = new TabbedPageViewModel();
            BindingContext = _viewModel;

            BackgroundColor = Color.Black;

            Title = _indicatorStyle.ToString();

            _relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var pagesCarousel = CreatePagesCarousel();
            var dots = CreatePagerIndicatorContainer();
            _tabs = CreateTabs();

            switch (pagesCarousel.IndicatorStyle)
            {
                case CarouselLayout.IndicatorStyleEnum.Dots:
                    _relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.RelativeToParent((parent) => { return parent.Y; }),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToParent((parent) => { return parent.Height / 2; })
                    );

                    _relativeLayout.Children.Add(dots,
                        Constraint.Constant(0),
                        Constraint.RelativeToView(pagesCarousel,
                            (parent, sibling) => { return sibling.Height - 18; }),
                        Constraint.RelativeToParent(parent => parent.Width),
                        Constraint.Constant(18)
                    );
                    break;

                case CarouselLayout.IndicatorStyleEnum.Tabs:
                    var tabsHeight = 50;
                    _relativeLayout.Children.Add(_tabs,
                        Constraint.Constant(0),
                        Constraint.RelativeToParent((parent) => { return parent.Height - tabsHeight; }),
                        Constraint.RelativeToParent(parent => parent.Width),
                        Constraint.Constant(tabsHeight)
                    );

                    _relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.RelativeToParent((parent) => { return parent.Y; }),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToView(_tabs, (parent, sibling) => { return parent.Height - (sibling.Height); })
                    );
                    break;

                default:
                    _relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.RelativeToParent((parent) => { return parent.Y; }),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToParent((parent) => { return parent.Height; })
                    );
                    break;
            }

            Content = _relativeLayout;
        }
Esempio n. 3
0
        public TabbedGameExperience(TabbedGameExperience previousContext)
        {
            System.Diagnostics.Debug.WriteLine("Doing previous init");
            _indicatorStyle = CarouselLayout.IndicatorStyleEnum.Tabs;

            List <HomeViewModel> pages = CreatePages().Result;

            viewModel             = new SwitcherPageViewModel(pages);
            viewModel.CurrentPage = previousContext.Get_Current_Page(); //Line to duplicate current page selection.
            BindingContext        = viewModel;

            Title = _indicatorStyle.ToString();

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            System.Diagnostics.Debug.WriteLine("Pre-Carousel");
            var pagesCarousel = CreatePagesCarousel();

            System.Diagnostics.Debug.WriteLine("Post-Carousel");
            _tabs = CreateTabs();

            var tabsHeight   = 50;
            var offsetTabsUp = 15;

            relativeLayout.Children.Add(_tabs,
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight - offsetTabsUp); }),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.Constant(tabsHeight)
                                        );

            relativeLayout.Children.Add(pagesCarousel,
                                        Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                        Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height) - offsetTabsUp); })
                                        );

            ShapeView navigationBarBottom = new ShapeView
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightGray,
                StrokeWidth = 1
            };

            relativeLayout.Children.Add(navigationBarBottom, Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Height - offsetTabsUp + 1); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.Constant(1));

            ShapeView navigationBarTop = new ShapeView
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightGray,
                StrokeWidth = 1
            };

            relativeLayout.Children.Add(navigationBarTop, Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Height - offsetTabsUp - _tabs.Height - 1); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.Constant(1));

            System.Diagnostics.Debug.WriteLine("Content loaded");
            this.Content = relativeLayout;
        }
Esempio n. 4
0
        public HomePage(CarouselLayout.IndicatorStyleEnum indicatorStyle)
        {
            _indicatorStyle = indicatorStyle;

            viewModel      = new SwitcherPageViewModel();
            BindingContext = viewModel;

            Title = _indicatorStyle.ToString();

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            var pagesCarousel = CreatePagesCarousel();
            var dots          = CreatePagerIndicatorContainer();

            _tabs = CreateTabs();

            switch (pagesCarousel.IndicatorStyle)
            {
            case CarouselLayout.IndicatorStyleEnum.Dots:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height / 2); })
                                            );

                relativeLayout.Children.Add(dots,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToView(pagesCarousel,
                                                                      (parent, sibling) => { return(sibling.Height - 18); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(18)
                                            );
                break;

            case CarouselLayout.IndicatorStyleEnum.Tabs:
                var tabsHeight = 50;
                relativeLayout.Children.Add(_tabs,
                                            Constraint.Constant(0),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight); }),
                                            Constraint.RelativeToParent(parent => parent.Width),
                                            Constraint.Constant(tabsHeight)
                                            );

                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height)); })
                                            );
                break;

            default:
                relativeLayout.Children.Add(pagesCarousel,
                                            Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                            Constraint.RelativeToParent((parent) => { return(parent.Height); })
                                            );
                break;
            }

            Timer delayTimer = new Timer();

            delayTimer.Interval = 5000;
            delayTimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                if (pagesCarousel.SelectedIndex > 2)
                {
                    pagesCarousel.SelectedIndex = 0;
                }
                else
                {
                    pagesCarousel.SelectedIndex = pagesCarousel.SelectedIndex + 1;
                }
            };
            delayTimer.Start();

            Content = relativeLayout;
        }
Esempio n. 5
0
        public MainContentView()
        {
            _indicatorStyle = CarouselLayout.IndicatorStyleEnum.Tabs;

            viewModel = new SwitcherMainPageViewModel();
            BindingContext = viewModel;

            Title = _indicatorStyle.ToString();

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var pagesCarousel = CreatePagesCarousel();
            var dots = CreatePagerIndicatorContainer();
            _tabs = CreateTabs();

            switch (pagesCarousel.IndicatorStyle)
            {
                case CarouselLayout.IndicatorStyleEnum.Dots:
                    relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.RelativeToParent((parent) => { return parent.Y; }),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToParent((parent) => { return parent.Height / 2; })
                    );

                    relativeLayout.Children.Add(dots,
                        Constraint.Constant(0),
                        Constraint.RelativeToView(pagesCarousel,
                            (parent, sibling) => { return sibling.Height - 18; }),
                        Constraint.RelativeToParent(parent => parent.Width),
                        Constraint.Constant(18)
                    );
                    break;
                case CarouselLayout.IndicatorStyleEnum.Tabs:
                    var tabsHeight = 50;
                    relativeLayout.Children.Add(_tabs,
                        Constraint.Constant(0),
                        Constraint.Constant(0),
                        Constraint.RelativeToParent(parent => parent.Width),
                        Constraint.Constant(tabsHeight)
                    );
                    //Constraint.RelativeToParent((parent) => { return parent.Height - tabsHeight; })
                    relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.Constant(tabsHeight),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToView(_tabs, (parent, sibling) => { return parent.Height - (sibling.Height); })
                    );
                    //Constraint.RelativeToParent((parent) => { return parent.Y; }),
                    break;
                default:
                    relativeLayout.Children.Add(pagesCarousel,
                        Constraint.RelativeToParent((parent) => { return parent.X; }),
                        Constraint.RelativeToParent((parent) => { return parent.Y; }),
                        Constraint.RelativeToParent((parent) => { return parent.Width; }),
                        Constraint.RelativeToParent((parent) => { return parent.Height; })
                    );
                    break;
            }

            Content = relativeLayout;
        }