private void setBtnDisplay(ViewerPageButton b, bool active) { if (active) { if (_activeBtn != b) { _activeBtn?.SetActive(false); } _activeBtn = b; } b?.SetActive(active); }
private void handlePageBtnClick(ViewerPageButton b) { if (b != _activeBtn && _nextActiveBtn == null) { _nextActiveBtn = b; setBtnDisplay(b, true); scrollToPageBtn(b); _pageScroll.Post(() => { OnPageButtonHit?.Invoke(b, EventArgs.Empty); }); } }
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; } }
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); }
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); } }