本文整理汇总了C#中Novacode.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.List
的用法示例。
在下文中一共展示了List.ToArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteToFile
public void WriteToFile(string fileName, List<Problem> source, int numberOfPage)
{
DocX doc = DocX.Create(fileName);
var font = new System.Drawing.FontFamily("Consolas");
var rand = new Random(DateTime.Now.Millisecond);
var gap = new string(' ', spaceBetweenProblem - 1);
var totalCount = colCount * rowCount * numberOfPage;
List<Problem> allItems = new List<Problem>();
while (allItems.Count < totalCount)
{
var problems = source.ToArray();
Utils.Shuffle(problems);
allItems.AddRange(problems);
}
Paragraph lastLine = null;
for (int page = 0; page < numberOfPage; page++)
{
var from = colCount * rowCount * page;
for (int row = 0; row < rowCount; row++)
{
var line1 = doc.InsertParagraph();
lastLine = doc.InsertParagraph();
for (int col = 0; col < colCount; col++)
{
line1.Append(string.Format("{0} ", allItems[from].LeftNumber.ToString().PadLeft(maxDigits + 1, ' '))).Font(font).FontSize(fontSize).Append(gap).Font(font).FontSize(fontSize);
lastLine.Append(string.Format("{0}{1} ", allItems[from].Sign, allItems[from].RightNumber.ToString().PadLeft(maxDigits, ' '))).Font(font).FontSize(fontSize).UnderlineStyle(UnderlineStyle.thick).Append(gap).Font(font).FontSize(fontSize);
from++;
}
if (row != rowCount - 1)
{
for (int i = 0; i < spaceLinesBetweenItem; i++)
{
lastLine = doc.InsertParagraph();
}
}
}
if (page != numberOfPage - 1 && addPageBreak)
{
lastLine.InsertPageBreakAfterSelf();
}
}
doc.Save();
}
示例2: ValidateBookmarks
public string[] ValidateBookmarks(params string[] bookmarkNames)
{
var headers = new[] {Document.Headers.first, Document.Headers.even, Document.Headers.odd}.Where(h => h != null).ToList();
var footers = new[] {Document.Footers.first, Document.Footers.even, Document.Footers.odd}.Where(f => f != null).ToList();
var nonMatching = new List<string>();
foreach (var bookmarkName in bookmarkNames)
{
if (headers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName))) return new string[0];
if (footers.SelectMany(h => h.Paragraphs).Any(p => p.ValidateBookmark(bookmarkName))) return new string[0];
if (Paragraphs.Any(p => p.ValidateBookmark(bookmarkName))) return new string[0];
nonMatching.Add(bookmarkName);
}
return nonMatching.ToArray();
}
示例3: InsertList
public List InsertList(int index, List list)
{
Paragraph p = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);
XElement[] split = HelperFunctions.SplitParagraph(p, index - p.startIndex);
var elements = new List<XElement> { split[0] };
elements.AddRange(list.Items.Select(i => new XElement(i.Xml)));
elements.Add(split[1]);
p.Xml.ReplaceWith(elements.ToArray());
return list;
}
示例4: SetWidthsPercentage
/// <summary>
/// Set Table column width by prescribing percent
/// </summary>
/// <param name="widthsPercentage">column width % list</param>
/// <param name="totalWidth">Total table width. Will be calculated if null sent.</param>
public void SetWidthsPercentage(float[] widthsPercentage, float? totalWidth)
{
if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width
List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width
widthsPercentage.ToList().ForEach(pWidth => { widths.Add((pWidth * totalWidth.Value / 100) * (96 / 72)); }); // convert percentage to actual width for all values in array
SetWidths(widths.ToArray()); // set actual column width
}
示例5: InsertParagraphs
public Paragraph[] InsertParagraphs(string text)
{
String[] textArray = text.Split('\n');
List<Paragraph> paragraphs = new List<Paragraph>();
foreach (var textForParagraph in textArray)
{
Paragraph p = base.InsertParagraph(text);
p.PackagePart = mainPart;
paragraphs.Add(p);
}
return paragraphs.ToArray();
}
示例6: getTables
//获取文档中的所有表格,tables[i]
public static Table[] getTables(DocX document)
{
List<Table> ts = new List<Table>();
ts = null;
ts = document.Tables;
return ts.ToArray<Table>();
}
示例7: Parse
public static Res1[] Parse(XElement elnote)
{
List<Res1> al = new List<Res1>();
foreach (var elres in elnote.Elements("resource")) {
foreach (var eldata in elres.Elements("data")) {
if (eldata.Attribute("encoding").Value == "base64") {
byte[] bin = Convert.FromBase64String(eldata.Value);
al.Add(new Res1 { si = new MemoryStream(bin, false), elres = elres, md5 = HUt.GetStr(MD5.Create().ComputeHash(bin)) });
}
break;
}
}
return al.ToArray();
}