The helper displayed on a page number has been adjusted in a small amount. The js version is attached. For more information, see. If you only want to download the ready-made application, you can go to this page to find it.
The License is "WTFPL", that is, "Do What The Fuck You Want To Public License ".
Source code ):
The Code is as follows:
Public static class PageNumExt
{
///
/// Use the input delegate to calculate and generate a friendly page number.
///
///
/// Current page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
Public static void PageNumView (this object o,
Long currentPage, PageNumAction actionPageNum, Action actionFolding,
Long maxSiblings = 2, long preventFolding = 1)
{
O. PageNumView (currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings, preventFolding );
}
///
/// Use the input delegate to calculate and generate a friendly page number. The current page number will be specially treated.
///
///
/// Current page number
/// How to process the current page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
Public static void PageNumView (this object o,
Long currentPage, PageNumAction actionCurrent,
PageNumAction actionPageNum, Action actionFolding,
Long maxSiblings = 2, long preventFolding = 1)
{
O. PageNumView (
CurrentPage, actionCurrent,
1, long. MaxValue,
ActionPageNum, I => {},
MaxSiblings, actionPageNum,
PreventFolding, actionFolding,
MaxSiblings, 0,
ActionPageNum, I => {}
);
}
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The current page number will be specially treated.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
Public static void PageNumView (this object o,
Long currentPage, PageNumAction actionCurrent,
Long beginPage, long endPage,
PageNumAction actionPageNum, Action actionFolding,
Long maxSiblings = 2, long preventFolding = 1)
{
O. PageNumView (currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionFolding, maxSiblings, preventFolding );
}
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The current page number, start page number, and end page number all specify a dedicated delegate for processing.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Processing the start page number
/// Handling the ending page number
/// Handling of near page numbers
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
Public static void PageNumView (this object o,
Long currentPage, PageNumAction actionCurrent,
Long beginPage, long endPage,
PageNumAction actionBegin, PageNumAction actionEnd,
PageNumAction actionSebling, Action actionFolding,
Long maxSiblings = 2, long preventFolding = 1)
{
O. PageNumView (
CurrentPage, actionCurrent,
BeginPage, endPage,
ActionBegin, actionEnd,
MaxSiblings, actionSebling,
PreventFolding, actionFolding,
MaxSiblings, maxSiblings,
ActionSebling, actionSebling
);
}
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The caller must assign a delegate to handle each page number.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Processing the start page number
/// Handling the ending page number
/// Number of adjacent pages of the current page
/// Handling of near page numbers
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
/// Handling the page number to be folded
/// Number of pages near the start page
/// Number of pages near the end page
/// Handling the page number near the start page
/// Handling the page near the end page
Public static void PageNumView (this object o,
Long currentPage, PageNumAction actionCurrent,
Long beginPage, long endPage,
PageNumAction actionBegin, PageNumAction actionEnd,
Long currentSiblings, PageNumAction actionCurrentSibling,
Long preventFolding, Action actionFolding,
Long endOfBegin, long beginOfEnd,
PageNumAction actionBeginSibling, PageNumAction actionEndSibling
)
{
Long I = beginPage;
// If the start page is smaller than the current page, process the start page.
If (beginPage <currentPage)
# Region
{
ActionBegin (beginPage );
I ++;
EndOfBegin + = I; // after resolving the page number near the start page
Var siblingBegin = currentPage-currentSiblings; // where the current page starts from
Var foldingStart = siblingBegin-preventFolding; // bottom line of page number folding
If (endOfBegin> siblingBegin)
EndOfBegin = siblingBegin; // ensure that the current page is near, and sacrifice the near page of the start page
For (; I <endOfBegin; I ++)
ActionBeginSibling (I );
If (I <foldingStart) // if the bottom line of the fold is not reached, collapse immediately.
{
ActionFolding ();
I = foldingStart + 1; // jump to the collapsed page number
}
}
# Endregion
// Process the near page before the current page
For (; I <currentPage; I ++)
ActionCurrentSibling (I );
// Process the current page
ActionCurrent (currentPage );
I = currentPage + 1; // indicates that the current page has been processed.
// Because the relationship between the current page and the expected start page cannot be guaranteed, the calculation starts from the current page.
Var goal = I + currentSiblings; // set a target
If (goal> endPage) // The target cannot exceed the end page
Goal = endPage;
// Process the near page after the current page until it reaches the target page
For (; I <goal; I ++)
ActionCurrentSibling (I );
// If the end page is greater than the current page, process the end page.
If (endPage> currentPage)
# Region
{
BeginOfEnd = endPage-beginOfEnd; // calculates where the near page of the end page starts.
Var foldingStart = beginOfEnd-preventFolding;
If (I <foldingStart) // the bottom line of the fold is not touched. Fold immediately.
{
ActionFolding ();
I = beginOfEnd;
}
Else // All are treated as near pages of the current page, but the close pages of the end page are retained.
For (; I <beginOfEnd; I ++)
ActionCurrentSibling (I );
For (; I <endPage; I ++)
ActionEndSibling (I );
ActionEnd (endPage );
}
# Endregion
}
}
The source code of the JavaScript version can be downloaded directly on the page mentioned above, but it is also listed here:
The Code is as follows:
! Function (){
Var g = this;
Var def_maxSiblings = 2;
Var def_preventFolding = 1;
Function pnView1 (
CurrentPage, actionPageNum, actionFolding,
MaxSiblings, preventFolding
){
///
/// Use the input delegate to calculate and generate a friendly page number.
///
///
/// Current page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
PnView2 (currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings | def_maxSiblings, preventFolding | def_preventFolding );
}
Function pnView2 (
CurrentPage, actionCurrent,
ActionPageNum, actionFolding,
MaxSiblings, preventFolding
){
///
/// Use the input delegate to calculate and generate a friendly page number. The current page number will be specially treated.
///
///
/// Current page number
/// How to process the current page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
PnView (
CurrentPage, actionCurrent,
1, Number. POSITIVE_INFINITY,
ActionPageNum, null,
MaxSiblings | def_maxSiblings, actionPageNum,
PreventFolding | def_preventFolding, actionFolding,
MaxSiblings | def_maxSiblings, 0,
ActionPageNum, null
);
}
Function pnView3 (
CurrentPage, actionCurrent,
BeginPage, endPage,
ActionPageNum, actionFolding,
MaxSiblings, preventFolding
){
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The current page number will be specially treated.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Page number processing method
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
PnView4 (currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionFolding, maxSiblings | def_maxSiblings, preventFolding | def_preventFolding );
}
Function pnView4 (
CurrentPage, actionCurrent,
BeginPage, endPage,
ActionBegin, actionEnd,
ActionSebling, actionFolding,
MaxSiblings, preventFolding
){
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The current page number, start page number, and end page number all specify a dedicated delegate for processing.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Processing the start page number
/// Handling the ending page number
/// Handling of near page numbers
/// Handling the page number to be folded
/// Number of adjacent pages
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
PnView (
CurrentPage, actionCurrent,
BeginPage, endPage,
ActionBegin, actionEnd,
MaxSiblings | def_maxSiblings, actionSebling,
PreventFolding | def_preventFolding, actionFolding,
MaxSiblings | def_maxSiblings, maxSiblings | def_maxSiblings,
ActionSebling, actionSebling
);
}
Function pnView (
CurrentPage, actionCurrent,
BeginPage, endPage,
ActionBegin, actionEnd,
CurrentSiblings, actionCurrentSibling,
PreventFolding, actionFolding,
EndOfBegin, beginOfEnd,
ActionBeginSibling, actionEndSibling
){
///
/// Calculate and generate friendly page numbers based on input parameters and delegation. The caller must assign a delegate to handle each page number.
///
///
/// Current page number
/// How to process the current page number
/// Default start page number
/// Default end page number
/// Processing the start page number
/// Handling the ending page number
/// Number of adjacent pages of the current page
/// Handling of near page numbers
/// Stops the critical value of page number folding. Pages exceeding this limit will be folded.
/// Handling the page number to be folded
/// Number of pages near the start page
/// Number of pages near the end page
/// Handling the page number near the start page
/// Handling the page near the end page
Var I = beginPage;
// If the start page is smaller than the current page, process the start page.
If (beginPage <currentPage ){
ActionBegin & actionBegin (beginPage );
I ++;
EndOfBegin + = I; // after resolving the page number near the start page
Var siblingBegin = currentPage-currentSiblings; // where the current page starts from
Var foldingStart = siblingBegin-preventFolding; // bottom line of page number folding
If (endOfBegin> siblingBegin)
EndOfBegin = siblingBegin; // ensure that the current page is near, and sacrifice the near page of the start page
For (; I <endOfBegin; I ++)
ActionBeginSibling & actionBeginSibling (I );
If (I <foldingStart) // if the bottom line of the fold is not reached, collapse immediately.
{
ActionFolding & actionFolding ();
I = foldingStart + 1; // jump to the collapsed page number
}
}
// Process the near page before the current page
For (; I <currentPage; I ++)
ActionCurrentSibling & actionCurrentSibling (I );
// Process the current page
ActionCurrent & actionCurrent (currentPage );
I = currentPage + 1; // indicates that the current page has been processed.
// Because the relationship between the current page and the expected start page cannot be guaranteed, the calculation starts from the current page.
Var goal = I + currentSiblings; // set a target
If (goal> endPage) // The target cannot exceed the end page
Goal = endPage;
// Process the near page after the current page until it reaches the target page
For (; I <goal; I ++)
ActionCurrentSibling & actionCurrentSibling (I );
// If the end page is greater than the current page, process the end page.
If (endPage> currentPage ){
BeginOfEnd = endPage-beginOfEnd; // calculates where the near page of the end page starts.
Var foldingStart = beginOfEnd-preventFolding;
If (I <foldingStart) // the bottom line of the fold is not touched. Fold immediately.
{
ActionFolding & actionFolding ();
I = beginOfEnd;
}
Else // All are treated as near pages of the current page, but the close pages of the end page are retained.
{
For (; I <beginOfEnd; I ++)
ActionCurrentSibling & actionCurrentSibling (I );
}
For (; I <endPage; I ++)
ActionEndSibling & actionEndSibling (I );
ActionEnd & actionEnd (endPage );
}
}
G. pnView1 = pnView1;
G. pnView2 = pnView2;
G. pnView3 = pnView3;
G. pnView4 = pnView4;
G. pnView5 = pnView;
G. pnView = pnView;
}();
/201009/yuanma/pnView_NanaView.rar