예제 #1
0
        private void setBtnDisplay(ViewerPageButton b, bool active)
        {
            if (active)
            {
                if (_activeBtn != b)
                {
                    _activeBtn?.SetActive(false);
                }
                _activeBtn = b;
            }

            b?.SetActive(active);
        }
예제 #2
0
        private void handlePageBtnClick(ViewerPageButton b)
        {
            if (b != _activeBtn && _nextActiveBtn == null)
            {
                _nextActiveBtn = b;

                setBtnDisplay(b, true);
                scrollToPageBtn(b);

                _pageScroll.Post(() =>
                {
                    OnPageButtonHit?.Invoke(b, EventArgs.Empty);
                });
            }
        }
예제 #3
0
 private void setActivePageLarge(int activePage)
 {
     if (_nextActiveBtn == null)
     {
         Post(() =>
         {
             ViewerPageButton b = (ViewerPageButton)_scrollContentLayout.GetChildAt(activePage - 1);
             setBtnDisplay(b, true);
             scrollToPageBtn(b);
         });
     }
     else if (_nextActiveBtn.PageNumber == activePage)
     {
         _nextActiveBtn = null;
     }
 }
예제 #4
0
        private bool scrollToPageBtn(ViewerPageButton b)
        {
            if (_scrollContentLayout.Width > _pageScroll.Width)
            {
                int scrollX = 0;

                if (b.Left >= (_pageScroll.Width / 2.0f))
                {
                    scrollX = (int)((b.Left + (b.Width / 2.0f)) - (_pageScroll.Width / 2.0f));
                }

                _pageScroll.ScrollTo(scrollX, 0);

                return(scrollX != _pageScroll.ScrollX);
            }

            return(false);
        }
예제 #5
0
        private void addPageButtons(int pageCount, int activePage)
        {
            _scrollContentLayout.RemoveAllViewsInLayout();

            for (int i = 1; i <= pageCount; i++)
            {
                ViewerPageButton b = new ViewerPageButton(Context);
                b.PageNumber = i;
                b.OnClick   += handlePageBtnClick;

                if (i == activePage)
                {
                    _activeBtn = b;
                }

                b.SetActive(_activeBtn == b);

                _scrollContentLayout.AddView(b);
            }
        }