private string ProcRefPages(string pstrPages, PagesType pagesType) { if (pstrPages == null) { return(""); } String strPages = pstrPages.Trim(); char nrule = '–'; // Ensure there is no dash(NRules) without a closing number. if (!String.IsNullOrEmpty(strPages)) { // Replace dashes with NRules. strPages = strPages.Replace('-', nrule); if (strPages[0] == nrule) { strPages = strPages + " *** Closing page expected ***"; } } // Install the pp for pages of a book. switch (pagesType) { case PagesType.REF_SECTION_PAGES: if (!strPages.Contains(nrule)) { if (!strPages.Contains("p")) { strPages = "p. " + strPages; } } else { if (!strPages.Contains("pp")) { strPages = "pp. " + strPages; } } break; case PagesType.ALWAYS_RANGE: if (!strPages.Contains(nrule)) { if (!strPages.Contains("pp")) { strPages = strPages + " pp."; } } else { if (!strPages.Contains("pp")) { strPages = "pp. " + strPages; } } break; } return(strPages); }
private string ProcRefPages(string pstrPages, PagesType pagesType) { if (pstrPages == null) { return ""; } String strPages = pstrPages.Trim(); char nrule = '–'; // Ensure there is no dash(NRules) without a closing number. if (!String.IsNullOrEmpty(strPages)) { // Replace dashes with NRules. strPages = strPages.Replace('-', nrule); if (strPages[0] == nrule) { strPages = strPages + " *** Closing page expected ***"; } } // Install the pp for pages of a book. switch (pagesType) { case PagesType.REF_SECTION_PAGES: if (!strPages.Contains(nrule)) { if (!strPages.Contains("p")) { strPages = "p. " + strPages; } } else { if (!strPages.Contains("pp")) { strPages = "pp. " + strPages; } } break; case PagesType.ALWAYS_RANGE: if (!strPages.Contains(nrule)) { if (!strPages.Contains("pp")) { strPages = strPages + " pp."; } } else { if (!strPages.Contains("pp")) { strPages = "pp. " + strPages; } } break; } return strPages; }
/// <summary> /// Метод устанавливающий текст для копирования и страницы /// </summary> public void SetCopyPagesAndText() { if (PageSizeTypes.A4_BW == PagesType) { PagesTypeText = "А4(чб)"; } else if (PageSizeTypes.A4 == PagesType) { PagesTypeText = "А4(ц)"; } else if (PageSizeTypes.A3_BW == PagesType) { PagesTypeText = "A3(чб)"; } else if (PageSizeTypes.A3 == PagesType) { PagesTypeText = "A3(ц)"; } else if (PageSizeTypes.None == PagesType) { PagesTypeText = "Не определено"; } else { PagesTypeText = PagesType.ToString(); } //Алгоритм сокращения идущих подряд страниц до вида 1-5 bool skip = false; for (int i = 0; i < Pages.Count; i++) { if (!skip) { CopyPages += Pages[i]; } if (i + 1 < Pages.Count && Pages[i + 1] - 1 == Pages[i]) { skip = true; } else if (i + 1 >= Pages.Count) { if (skip) { CopyPages += "-" + Pages[i] + ";"; skip = false; } else { CopyPages += ";"; } } else { if (skip) { CopyPages += "-" + Pages[i] + ","; skip = false; } else { CopyPages += ","; } } } }