/// <summary> /// Instructs the component to show the specified page. /// </summary> /// <param name="criteria">Details of the page to be displayed.</param> public async Task PageAsync(PageCriteria criteria) { SetPageCriteria(criteria); await GetDataAsync().ConfigureAwait(true); await PageChanged.InvokeAsync(criteria).ConfigureAwait(true); }
public void PreviousPage() { if (Collection.Count == 0) { return; } int oldPage = CurrentPage; if (CurrentPage == 0) { if (!InfiniteCycle) { return; } CurrentPage = TotalPages - 1; } else { CurrentPage--; } UpdateMedias(); if (oldPage != CurrentPage) { PageChanged?.Invoke(this, new MediaCollectionPageChangedEventArgs(CurrentPage, TotalPages)); } }
protected void OnPaginationItemClick(string pageName) { if (int.TryParse(pageName, out var pageNumber)) { CurrentPage = pageNumber; } else { if (pageName == "prev") { CurrentPage--; if (CurrentPage < 1) { CurrentPage = 1; } } else if (pageName == "next") { CurrentPage++; if (CurrentPage > LastPage) { CurrentPage = LastPage; } } } PageChanged?.Invoke(CurrentPage.ToString()); }
private static void ChangePage(INavigablePage page, object parameter) { CurrentPage?.OnNavigatedFrom(); page.OnNavigatedTo(parameter); CurrentPage = page; PageChanged?.Invoke(null, EventArgs.Empty); }
protected override void OnApplyTemplate() { SetValue(TemplateSettingsProperty, new PagerTemplateSettings(this)); NumberPanelEndStateStartIndex = NumberOfPages - 3; // Grab UIElements for later FirstPageButton = GetTemplateChild("FirstPageButton") as Button; PreviousPageButton = GetTemplateChild("PreviousPageButton") as Button; NextPageButton = GetTemplateChild("NextPageButton") as Button; LastPageButton = GetTemplateChild("LastPageButton") as Button; PagerComboBox = GetTemplateChild("ComboBoxDisplay") as ComboBox; PagerNumberBox = GetTemplateChild("NumberBoxDisplay") as NumberBox; PagerNumberPanel = GetTemplateChild("NumberPanelItemsRepeater") as ItemsRepeater; NumberPanelCurrentPageIdentifier = GetTemplateChild("NumberPanelCurrentPageIdentifier") as Rectangle; // Attach TestHooks FirstPageButtonTestHook = FirstPageButton; PreviousPageButtonTestHook = PreviousPageButton; NextPageButtonTestHook = NextPageButton; LastPageButtonTestHook = LastPageButton; NumberBoxDisplayTestHook = PagerNumberBox; ComboBoxDisplayTestHook = PagerComboBox; NumberPanelDisplayTestHook = PagerNumberPanel; NumberPanelCurrentPageIdentifierTestHook = NumberPanelCurrentPageIdentifier; // Attach click events if (FirstPageButton != null) { FirstPageButton.Click += (s, e) => { SelectedIndex = 1; }; } if (PreviousPageButton != null) { PreviousPageButton.Click += (s, e) => { SelectedIndex -= 1; }; } if (NextPageButton != null) { NextPageButton.Click += (s, e) => { SelectedIndex += 1; }; } if (LastPageButton != null) { LastPageButton.Click += (s, e) => { SelectedIndex = NumberOfPages; }; } if (PagerComboBox != null) { PagerComboBox.SelectedIndex = SelectedIndex - 1; PagerComboBox.SelectionChanged += (s, e) => { OnComboBoxSelectionChanged(); }; } if (PagerNumberPanel != null) { UpdateNumberPanel(); PagerNumberPanel.ElementPrepared += OnElementPrepared; PagerNumberPanel.ElementClearing += OnElementClearing; } OnPagerDisplayModeChanged(); templateApplied = true; // This is for the initial page being loaded whatever page that might be. PageChanged?.Invoke(this, new PageChangedEventArgs(PreviousPageIndex, SelectedIndex - 1)); }
protected virtual void OnPageChanged(EventArgs e) { if (PageChanged != null) { PageChanged.Invoke(this, e); } }
public void SwitchTab(string targetPath) { //called by ButtonInfo.cs when clicked. "targetPath" is usually a "PathHead" foreach (TabPage tabPage in tabControl.Controls) { var nav = GetINavigatableFromControl(tabPage); if (nav.PathHead == targetPath) { if (CurrentNavigatable == nav) { Path = targetPath; // double click on forum go to forum home } else { string lastPath; if (lastTabPaths.TryGetValue(nav, out lastPath)) { targetPath = lastPath; //go to current page of the tab } Path = targetPath; } return; } } Path = targetPath; PageChanged?.Invoke(Path); }
protected async Task OnPaginationItemClick(string pageName) { if (int.TryParse(pageName, out var pageNumber)) { CurrentPage = pageNumber; } else { if (pageName == "prev") { CurrentPage--; if (CurrentPage < 1) { CurrentPage = 1; } } else if (pageName == "next") { CurrentPage++; if (CurrentPage > LastPage) { CurrentPage = LastPage; } } } await PageChanged.InvokeAsync(new DataGridPageChangedEventArgs( CurrentPage, PageSize )); if (ReadData.HasDelegate) { await HandleReadData(); } }
public void NavigateForward() { if (CanGoForward) { GoForward(); PageChanged?.Invoke(Path); } }
public void NavigateBack() { if (CanGoBack) { GoBack(); PageChanged?.Invoke(Path); } }
public SlideBox() { InitializeComponent(); panel.Size = Size; panel.Left = panel.Top = 0; panel.AutoScroll = false; panel.AutoSize = true; this.ControlAdded += (s, e) => { AddPage(e.Control); }; this.Resize += (s, e) => { // 挂起UI this.SuspendLayout(); panel.Size = Size; if (pageIndex != -1) { foreach (Control page in panel.Controls) { page.Size = panel.Size; } panel.Left = -panel.Controls[pageIndex].Left; } // 恢复UI this.ResumeLayout(); }; this.SizeChanged += (s, e) => { foreach (Control c in panel.Controls) { c.Size = Size; } }; timer.Enabled = false; timer.Interval = 10; timer.Tick += (s, e) => { // 当前位置与目标位置相差距离小于最小移动距离时,结束运动 if (Math.Abs(panel.Left - targetLocation) <= ReviseValue) { panel.Left = targetLocation; timer.Enabled = false; PageChanged?.Invoke(this, new PageChangedEventArgs(pageIndex)); return; } int v = (panel.Left - targetLocation) / Rate; if (Math.Abs(v) < ReviseValue) { v = ReviseValue * (v < 0 ? -1 : 1); } panel.Left = panel.Left - v; }; }
private void FirePageChanged() { EventArgs args = new EventArgs(); if (PageChanged != null) { PageChanged.Invoke(this, args); } }
private void btnNextPage_Click(object sender, EventArgs e) { if (_currentPage < MaxNumberOfPages - 1) { _currentPage += 1; ChangeCurrentPageLabel(_currentPage); PageChanged?.Invoke(this, new PageChangedArgs(_currentPage)); } }
private void btnPreviousPage_Click(object sender, EventArgs e) { if (_currentPage > 0) { _currentPage -= 1; ChangeCurrentPageLabel(_currentPage); PageChanged?.Invoke(this, new PageChangedArgs(_currentPage)); } }
public void SwapTo(IList <PageItem> pages, int page) { SetPage(0, 1); SetPage(1, page, pages); SwapAnimate(true, () => { CurrentPage = page; PageChanged?.Invoke(this, page, pages[0].Begin); }); }
private void OnSelectedIndexChanged() { if (PagerComboBox != null) { PagerComboBox.SelectedIndex = SelectedIndex - 1; } DisablePageButtonsOnEdge(); UpdateNumberPanel(); PageChanged?.Invoke(this, new PageChangedEventArgs(PreviousPageIndex, SelectedIndex - 1)); }
protected virtual void OnPageChanged(int pageNo) { try { PageChanged?.Invoke(pageNo); } catch (Exception) { //ignore } }
/// <summary> /// Tells the application to load a specific <see cref="Page"/> /// </summary> /// <param name="ID">The ID of the <see cref="Page"/> to load</param> public static void LoadPage(string ID) { try { PageChanged?.Invoke(GetPage(ID), ID); history.Push(ID); Logging.Write($"Changed to page \"{ID}\"", "Paging"); } catch (ArgumentNullException) { Logging.Write(string.Format(LOAD_NULL_PAGE_FORMAT, Assembly.GetCallingAssembly().GetName().Name, Environment.StackTrace), "Paging", LogLevel.Fatal); } catch (KeyNotFoundException) { Logging.Write(string.Format(LOAD_INVALID_PAGE_FORMAT, Assembly.GetCallingAssembly().GetName().Name, ID, Environment.StackTrace), "Paging", LogLevel.Fatal); } }
/// <summary> /// 尾页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void last_hyperlinkLabelControl_Click(object sender, EventArgs e) { if (_pageTotal == 0) { curPage_labelControl.Text = "1/1 页"; return; } _pageIndex = (_pageTotal % _pageSize) == 0 ? PageTotal / _pageSize : (PageTotal / _pageSize) + 1; curPage_labelControl.Text = string.Format("{0}/{0} 页", _pageIndex); PageChanged?.Invoke(sender, e); }
public void Back(object page = null) { if (page is TrainsPlanViewModel || page is DiaryTrainsViewModel) { PageChanged?.Invoke(typeof(StartPage)); return; } _ = _pages.Pop(); var previouspage = _pages.Peek(); PageChanged?.Invoke(previouspage.GetType()); }
private void FirePageChangedEvent() { int startIndex = (CurrentPage - 1) * ItemsPerPage; int length = ItemsPerPage; int remain = numberOfItem - startIndex; if (remain < length) { length = remain; } PageChanged?.Invoke(startIndex, length); }
/// <summary> /// Navigiert zu einer Seite. /// </summary> /// <param name="resourceKey">Schlüssel aus dem ResourceDictionary der Seite, zu der navigiert werden soll</param> public void NavigateTo(string resourceKey) { if (!resourceKey.Equals(String.Empty)) { var page = App.Current.FindResource(resourceKey) as Page; PageChanged?.Invoke(this, new NavigationEventArgs() { ZielPage = page, }); (App.Current.FindResource("MainWindowVM") as MainWindowVM).CurrentPage = page; PageChangedFinished?.Invoke(this, new EventArgs()); } }
/// <summary> /// Set the current page index to a specific value. Invokes the PageChanged event. /// </summary> /// <param name="requestedPageIndex">The page index to move to. Gets clamped between 0 and the number of pages.</param> /// <returns>True if the page was updated, false if it wasn't.</returns> public bool SetPage(int requestedPageIndex) { int oldPageIndex = PageIndex; PageIndex = Math.Clamp(requestedPageIndex, 0, NumPages - 1); if (oldPageIndex != PageIndex) { PageChanged?.Invoke(GetPageItems()); return(true); } return(false); }
public async Task ChangePage(bool forwards) { if (forwards) { await RunPageChange(Width * -1); } else { await RunPageChange(Width); } PageChanged?.Invoke(this, new EventArgs()); ShowControls(); }
/// <summary> /// Changed the current page, clamps to pages limits /// </summary> /// <param name="newPage">New page number, starting from 0</param> public void ChangePage(int newPage) { newPage = Mathf.Clamp(newPage, 0, PagesCount - 1); if (CurrentPage == newPage) { return; } currentPage = newPage; var startElement = CurrentPage * elementsPerPage; for (var i = 0; i < elementsPerPage; i++) { currentPageElements[i] = startElement + i < elements.Length ? elements[startElement + i] : null; } PageChanged?.Invoke(CurrentPage, currentPageElements); }
private void vScrollBar_ValueChanged(object sender, EventArgs e) { int inc = (last - vScrollBar.Value) * 2; last = vScrollBar.Value; if (y8Selected != -1) { y8Selected += inc; } if (y8LastHover != -1) { y8LastHover += inc; } UpdateImage(); PageChanged?.Invoke(this, EventArgs.Empty); }
private void next_hyperlinkLabelControl_Click(object sender, EventArgs e) { if (_pageTotal == 0) { curPage_labelControl.Text = "1/1 页"; return; } int result = (_pageTotal % _pageSize) == 0 ? PageTotal / _pageSize : (PageTotal / _pageSize) + 1; if (_pageIndex >= result) { return; } ++_pageIndex; curPage_labelControl.Text = string.Format("{0}/{1} 页", _pageIndex, result); PageChanged?.Invoke(sender, e); }
/// <summary> /// Called if the page change button is clicked. /// </summary> /// <param name="sender">Sender that raised the event.</param> /// <param name="e">The event args.</param> public void ButtonClick(object sender, EventArgs e) { if (PageChanged != null) { Button button = sender as Button; if (button == null) { return; } int page = Convert.ToInt32(button.Text); var eventArgs = new PageSelectedEventArgs { SelectedPage = page }; PageChanged.Invoke(this, eventArgs); } }
public void SetFile(PVFile newFile) { if (pvFile != null) { pvFile.Dispose(); } pvFile = newFile; if (pvFile == null) { FileChanged.Invoke(this, new FileChangedEventArgs()); PageChanged.Invoke(this, new PageChangedEventArgs()); } else { FileChanged.Invoke(this, new FileChangedEventArgs(pvFile.FileName, pvFile.PageCount)); SetPage(1); //SetPage(currentPage < 1 ? 1 : currentPage > pvFile.PageCount ? pvFile.PageCount : currentPage); } }
private void Paginator_MouseClick(object sender, MouseEventArgs e) { if (e.X < 15) { if (PageChanged != null && currentPage > 0) { PageChanged.Invoke(this, PageChange.Back); currentPage--; Refresh(); } } if (e.X > (Width - 15)) { if (PageChanged != null && (currentPage + 1) < totalPages) { PageChanged.Invoke(this, PageChange.Next); currentPage++; Refresh(); } } }