Exemplo n.º 1
0
        void InitializeComponent()
        {
            _mainBox = new Box(Forms.NativeParent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };
            _mainBox.Show();
            _mainBox.SetLayoutCallback(OnLayout);

            _indexIndicator = new Index(_mainBox)
            {
                IsHorizontal = true,
                AutoHide     = false,
            }.SetStyledIndex();
            _indexIndicator.Show();

            _scroller               = new Scroller(_mainBox);
            _scroller.Scrolled     += OnScrolled;
            _scroller.PageScrolled += OnScrollStop;

            //PageScrolled event is not invoked when a user scrolls beyond the end using bezel
            var scrollAnimationStop = new SmartEvent(_scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation);

            scrollAnimationStop.On += OnScrollStop;

            _scroller.Focused   += OnFocused;
            _scroller.Unfocused += OnUnfocused;

            // Disables the visibility of the scrollbar in both directions:
            _scroller.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
            _scroller.VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible;

            // Sets the limit of scroll to one page maximum:
            _scroller.HorizontalPageScrollLimit = 1;
            _scroller.SetPageSize(1.0, 1.0);
            _scroller.SetAlignment(-1, -1);
            _scroller.SetWeight(1.0, 1.0);
            _scroller.Show();

            _innerContainer = new Box(_mainBox);
            _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
            _innerContainer.SetAlignment(-1, -1);
            _innerContainer.SetWeight(1.0, 1.0);
            _innerContainer.Show();
            _scroller.SetContent(_innerContainer);

            _mainBox.PackEnd(_indexIndicator);
            _mainBox.PackEnd(_scroller);
            _indexIndicator.StackAbove(_scroller);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the CarouselPage class.
        /// </summary>
        public CarouselPage(EvasObject parent) : base(parent)
        {
            AlignmentX = -1;
            AlignmentY = -1;
            WeightX    = 1;
            WeightY    = 1;
            Show();

            _scroller = new Scroller(parent)
            {
                HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
                VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible,
                HorizontalPageScrollLimit        = 1,
                HorizontalRelativePageSize       = 1.0,
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };
            _scroller.PageScrolled += OnPageScrolled;
            _scroller.Show();

            _innerContainer = new EBox(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };
            _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
            _innerContainer.Show();
            _scroller.SetContent(_innerContainer);

            _index = new Index(parent)
            {
                IsHorizontal = true,
                AutoHide     = false,
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
            };
            _index.Changed += OnIndexChanged;
            _index.Show();

            SetLayoutCallback(OnOutterLayoutUpdate);
            PackEnd(_scroller);
            PackEnd(_index);
        }
Exemplo n.º 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <CarouselPage> e)
        {
            if (NativeView == null)
            {
                _outterLayout = new Box(Forms.NativeParent)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _outterLayout.Show();

                _scroller = new Scroller(Forms.NativeParent)
                {
                    HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
                    VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible,
                    HorizontalPageScrollLimit        = 1,
                    HorizontalRelativePageSize       = 1.0,
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _scroller.PageScrolled += OnPageScrolled;
                _scroller.Show();

                _innerContainer = new Box(Forms.NativeParent)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                };
                _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
                _innerContainer.Show();
                _scroller.SetContent(_innerContainer);

                _index = new Index(Forms.NativeParent)
                {
                    IsHorizontal = true,
                    AutoHide     = false,
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                };
                _index.Changed += OnIndexChanged;
                _index.Show();

                _outterLayout.SetLayoutCallback(OnOutterLayoutUpdate);
                _outterLayout.PackEnd(_scroller);
                _outterLayout.PackEnd(_index);

                SetNativeView(_outterLayout);
            }

            if (e.OldElement != null)
            {
                e.OldElement.CurrentPageChanged -= OnCurrentPageChanged;
                e.OldElement.PagesChanged       -= OnPagesChanged;
                _isInitalized = false;
            }

            if (e.NewElement != null)
            {
                Element.CurrentPageChanged += OnCurrentPageChanged;
                Element.PagesChanged       += OnPagesChanged;
            }

            base.OnElementChanged(e);
        }