SoFunction
Updated on 2025-03-01

A small amount of helper displayed on a certain page number is adjusted, and a js version is attached

If you just want to download ready-made ones,You can search on this page
The license is "WTFPL", which means "Do What The Fuck You Want To Public License”。

The source code is as follows (because there are comments, I won't explain it separately):
Copy the codeThe code is as follows:

public static class PageNumExt
{
/// <summary>
/// Use incoming delegates to calculate and generate friendly page numbers.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
public static void PageNumView(this object o,
long currentPage, PageNumAction actionPageNum, Action actionFolding,
long maxSiblings = 2, long preventFolding = 1)
{
(currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings, preventFolding);
}
/// <summary>
/// Use incoming delegates to calculate and generate friendly page numbers. The current page number will be treated specially.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
public static void PageNumView(this object o,
long currentPage, PageNumAction actionCurrent,
PageNumAction actionPageNum, Action actionFolding,
long maxSiblings = 2, long preventFolding = 1)
{
(
currentPage, actionCurrent,
1, ,
actionPageNum, i => { },
maxSiblings, actionPageNum,
preventFolding, actionFolding,
maxSiblings, 0,
actionPageNum, i => { }
);
}
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The current page number will be treated specially.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
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)
{
(currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionPageNum, actionPageNum, actionFolding, maxSiblings, preventFolding);
}
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The current page number, the start page number and the end page number all specify a dedicated delegation to handle.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionBegin">How to process the start page number</param>
/// <param name="actionEnd">How to process end page number</param>
/// <param name="actionSebling">How to deal with adjacent page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
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)
{
(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin, actionEnd,
maxSiblings, actionSebling,
preventFolding, actionFolding,
maxSiblings, maxSiblings,
actionSebling, actionSebling
);
}
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The specific processing method of each page number needs to be assigned by the caller.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionBegin">How to process the start page number</param>
/// <param name="actionEnd">How to process end page number</param>
/// <param name="currentSiblings">Number of adjacent page numbers for the current page number</param>
/// <param name="actionCurrentSibling">How to handle adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="endOfBegin">Number of page numbers near the start page</param>
/// <param name="beginOfEnd">Number of page numbers near to end page</param>
/// <param name="actionBeginSibling">How to handle the page number of the start page</param>
/// <param name="actionEndSibling">How to handle the end page near the page number</param>
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, start processing the start page
if (beginPage < currentPage)
#region
{
actionBegin(beginPage);
i++;
endOfBegin += i; // After solving the page number close to the start page
var siblingBegin = currentPage - currentSiblings; // Where does the current page begin to be near to the page
var foldingStart = siblingBegin - preventFolding; // The bottom line of page number folding
if (endOfBegin > siblingBegin)
endOfBegin = siblingBegin; // Ensure that the current page is close to the page, and sacrifice the beginning page is close to the page
for (; i < endOfBegin; i++)
actionBeginSibling(i);
if (i < foldingStart) // If you have not reached the folding line, start folding immediately
{
actionFolding();
i = foldingStart + 1; // Jump to the page number after folding
}
}
#endregion
// Process the adjacent page before the current page
for (; i < currentPage; i++)
actionCurrentSibling(i);
// Process the current page
actionCurrent(currentPage);
i = currentPage + 1; // means that the current page has been processed.
// Since the relationship between the current page and the expected starting page cannot be guaranteed, the calculation starts from the current page.
var goal = i + currentSiblings; // Set a target
if (goal > endPage) // Don't exceed the end page
goal = endPage;
// Process the adjacent page after the current page until the destination page is reached
for (; i < goal; i++)
actionCurrentSibling(i);
// If the end page is larger than the current page, the end page will be processed.
if (endPage > currentPage)
#region
{
beginOfEnd = endPage - beginOfEnd; // Calculate where the adjacent page of the end page starts
var foldingStart = beginOfEnd - preventFolding;
If (i < foldingStart) // No folding line is touched, start folding immediately
{
actionFolding();
i = beginOfEnd;
}
else // All are treated as the adjacent page of the current page, but the adjacent page of the end page is retained
for (; i < beginOfEnd; i++)
actionCurrentSibling(i);

for (; i < endPage; i++)
actionEndSibling(i);
actionEnd(endPage);
}
#endregion
}
}

The source code of JavaScript can be downloaded directly from the page mentioned above, but here are also listed:
Copy the codeThe code is as follows:

!function () {
var g = this;
var def_maxSiblings = 2;
var def_preventFolding = 1;
function pnView1(
currentPage, actionPageNum, actionFolding,
maxSiblings, preventFolding
) {
/// <summary>
/// Use incoming delegates to calculate and generate friendly page numbers.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
pnView2(currentPage, actionPageNum, actionPageNum, actionFolding, maxSiblings || def_maxSiblings, preventFolding || def_preventFolding);
}
function pnView2(
currentPage, actionCurrent,
actionPageNum, actionFolding,
maxSiblings, preventFolding
) {
/// <summary>
/// Use incoming delegates to calculate and generate friendly page numbers. The current page number will be treated specially.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
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
) {
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The current page number will be treated specially.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionPageNum">How to process page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
pnView4(currentPage, actionCurrent, beginPage, endPage, actionPageNum, actionPageNum, actionPageNum, actionFolding, maxSiblings || def_maxSiblings, preventFolding || def_preventFolding);
}
function pnView4(
currentPage, actionCurrent,
beginPage, endPage,
actionBegin, actionEnd,
actionSebling, actionFolding,
maxSiblings, preventFolding
) {
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The current page number, the start page number and the end page number all specify a dedicated delegation to handle.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionBegin">How to process the start page number</param>
/// <param name="actionEnd">How to process end page number</param>
/// <param name="actionSebling">How to deal with adjacent page numbers</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="maxSiblings">Number of adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
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
) {
/// <summary>
/// Calculate and generate friendly page numbers based on the incoming parameters and delegates. The specific processing method of each page number needs to be assigned by the caller.
/// </summary>
/// <param name="o"></param>
/// <param name="currentPage">Current page number</param>
/// <param name="actionCurrent">How to handle the current page number</param>
/// <param name="beginPage">Preset start page number</param>
/// <param name="endPage">Preset end page number</param>
/// <param name="actionBegin">How to process the start page number</param>
/// <param name="actionEnd">How to process end page number</param>
/// <param name="currentSiblings">Number of adjacent page numbers for the current page number</param>
/// <param name="actionCurrentSibling">How to handle adjacent page numbers</param>
/// <param name="preventFolding">The critical value of preventing the collapse of the page number, the page number exceeding this number will be collapsed</param>
/// <param name="actionFolding">How to handle folded page numbers</param>
/// <param name="endOfBegin">Number of page numbers near the start page</param>
/// <param name="beginOfEnd">Number of page numbers near to end page</param>
/// <param name="actionBeginSibling">How to handle the page number of the start page</param>
/// <param name="actionEndSibling">How to handle the end page near the page number</param>
var i = beginPage;
// If the start page is smaller than the current page, start processing the start page
if (beginPage < currentPage) {
actionBegin && actionBegin(beginPage);
i++;
endOfBegin += i; // After solving the page number close to the start page
var siblingBegin = currentPage - currentSiblings; // Where does the current page begin to be near to the page
var foldingStart = siblingBegin - preventFolding; // The bottom line of page number folding
if (endOfBegin > siblingBegin)
endOfBegin = siblingBegin; // Ensure that the current page is close to the page, and sacrifice the beginning page is close to the page
for (; i < endOfBegin; i++)
actionBeginSibling && actionBeginSibling(i);
if (i < foldingStart) // If you have not reached the folding line, start folding immediately
{
actionFolding && actionFolding();
i = foldingStart + 1; // Jump to the page number after folding
}
}
// Process the adjacent page before the current page
for (; i < currentPage; i++)
actionCurrentSibling && actionCurrentSibling(i);
// Process the current page
actionCurrent && actionCurrent(currentPage);
i = currentPage + 1; // means that the current page has been processed.
// Since the relationship between the current page and the expected starting page cannot be guaranteed, the calculation starts from the current page.
var goal = i + currentSiblings; // Set a target
if (goal > endPage) // Don't exceed the end page
goal = endPage;
// Process the adjacent page after the current page until the destination page is reached
for (; i < goal; i++)
actionCurrentSibling && actionCurrentSibling(i);
// If the end page is larger than the current page, the end page will be processed.
if (endPage > currentPage) {
beginOfEnd = endPage - beginOfEnd; // Calculate where the adjacent page of the end page starts
var foldingStart = beginOfEnd - preventFolding;
If (i < foldingStart) // No folding line is touched, start folding immediately
{
actionFolding && actionFolding();
i = beginOfEnd;
}
else // All are treated as the adjacent page of the current page, but the adjacent page of the end page is 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;
= pnView;
} ();

/201009/yuanma/pnView_NanaView.rar