示例#1
0
 protected virtual void OnPageChanged(EventArgs e)
 {
     if (PageChanged != null)
     {
         PageChanged.Invoke(this, e);
     }
 }
示例#2
0
        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());
        }
示例#3
0
        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));
            }
        }
示例#4
0
 private static void ChangePage(INavigablePage page, object parameter)
 {
     CurrentPage?.OnNavigatedFrom();
     page.OnNavigatedTo(parameter);
     CurrentPage = page;
     PageChanged?.Invoke(null, EventArgs.Empty);
 }
示例#5
0
        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));
        }
 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);
 }
 public void NavigateForward()
 {
     if (CanGoForward)
     {
         GoForward();
         PageChanged?.Invoke(Path);
     }
 }
 public void NavigateBack()
 {
     if (CanGoBack)
     {
         GoBack();
         PageChanged?.Invoke(Path);
     }
 }
示例#9
0
        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);
        }
    }
示例#11
0
 private void btnNextPage_Click(object sender, EventArgs e)
 {
     if (_currentPage < MaxNumberOfPages - 1)
     {
         _currentPage += 1;
         ChangeCurrentPageLabel(_currentPage);
         PageChanged?.Invoke(this, new PageChangedArgs(_currentPage));
     }
 }
示例#12
0
 private void btnPreviousPage_Click(object sender, EventArgs e)
 {
     if (_currentPage > 0)
     {
         _currentPage -= 1;
         ChangeCurrentPageLabel(_currentPage);
         PageChanged?.Invoke(this, new PageChangedArgs(_currentPage));
     }
 }
示例#13
0
 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);
     });
 }
示例#14
0
        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
     }
 }
示例#16
0
 /// <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);
     }
 }
示例#17
0
        /// <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);
        }
示例#18
0
        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());
     }
 }
示例#21
0
        public async Task ChangePage(bool forwards)
        {
            if (forwards)
            {
                await RunPageChange(Width * -1);
            }
            else
            {
                await RunPageChange(Width);
            }

            PageChanged?.Invoke(this, new EventArgs());
            ShowControls();
        }
        /// <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);
        }
示例#23
0
        /// <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);
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        /// <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);
            }
        }
示例#27
0
        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);
            }
        }
示例#28
0
 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();
         }
     }
 }
示例#29
0
 private void Paginator_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.X < 15)
     {
         if (PageChanged != null && currentPage > 0)
         {
             PageChanged.Invoke(this, PageChange.First);
             currentPage = 0;
             Refresh();
         }
     }
     if (e.X > (Width - 15))
     {
         if (PageChanged != null && (currentPage + 1) < totalPages)
         {
             PageChanged.Invoke(this, PageChange.Last);
             currentPage = totalPages - 1;
             Refresh();
         }
     }
 }
示例#30
0
        public void SetPage(int page)
        {
            if (pvFile != null && page <= pvFile.PageCount && page > 0)
            {
                try
                {
                    bmpSource = pvFile.LoadPage(page);
                }
                catch (Exception ex)
                {
                    pvFile.Dispose();
                    MessageBox.Show(ex.Message, "Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    PageChanged.Invoke(this, new PageChangedEventArgs());
                    return;
                }

                currentPage     = page;
                resample.Source = bmpSource;
                PageChanged.Invoke(this, new PageChangedEventArgs(bmpSource.Size, currentPage, bmpSource.PixelFormat));
            }
        }