当前位置: 首页>>代码示例>>C#>>正文


C# List.ToArray方法代码示例

本文整理汇总了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();
        }
开发者ID:shengqh,项目名称:education,代码行数:49,代码来源:ProblemWordRowColWriter.cs

示例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();
        }
开发者ID:ScottSnodgrass,项目名称:DocX,代码行数:16,代码来源:Container.cs

示例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;
        }
开发者ID:ScottSnodgrass,项目名称:DocX,代码行数:12,代码来源:Container.cs

示例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
 }
开发者ID:WordDocX,项目名称:DocX,代码行数:12,代码来源:Table.cs

示例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();
 }
开发者ID:EnergonV,项目名称:BestCS,代码行数:12,代码来源:DocX.cs

示例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>();
 }
开发者ID:jacean,项目名称:DocXfunc,代码行数:8,代码来源:DocXClass.cs

示例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();
 }
开发者ID:kenjiuno,项目名称:enex2docx,代码行数:14,代码来源:Program.cs


注:本文中的Novacode.List.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。