本文整理汇总了C#中Novacode.List.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddItem方法的具体用法?C# List.AddItem怎么用?C# List.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.List
的用法示例。
在下文中一共展示了List.AddItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateItemInList
internal static List CreateItemInList(List list, string listText, int level = 0, ListItemType listType = ListItemType.Numbered, int? startNumber = null, bool trackChanges = false)
{
if (list.NumId == 0)
{
list.CreateNewNumberingNumId(level, listType);
}
if (!string.IsNullOrEmpty(listText))
{
var newParagraphSection = new XElement
(
XName.Get("p", DocX.w.NamespaceName),
new XElement(XName.Get("pPr", DocX.w.NamespaceName),
new XElement(XName.Get("numPr", DocX.w.NamespaceName),
new XElement(XName.Get("ilvl", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", level)),
new XElement(XName.Get("numId", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", list.NumId)))),
new XElement(XName.Get("r", DocX.w.NamespaceName), new XElement(XName.Get("t", DocX.w.NamespaceName), listText))
);
if (trackChanges)
newParagraphSection = CreateEdit(EditType.ins, DateTime.Now, newParagraphSection);
if (startNumber == null)
{
list.AddItem(new Paragraph(list.Document, newParagraphSection, 0, ContainerType.Paragraph));
}
else
{
list.AddItemWithStartValue(new Paragraph(list.Document, newParagraphSection, 0, ContainerType.Paragraph), (int)startNumber);
}
}
return list;
}
示例2: CreateItemInList
internal static List CreateItemInList(List list, string listText, int level = 0, ListItemType listType = ListItemType.Numbered, int? startNumber = null, bool trackChanges = false, bool continueNumbering = false)
{
if (list.NumId == 0)
{
list.CreateNewNumberingNumId(level, listType, startNumber, continueNumbering);
}
if (listText != null) //I see no reason why you shouldn't be able to insert an empty element. It simplifies tasks such as populating an item from html.
{
var newParagraphSection = new XElement
(
XName.Get("p", DocX.w.NamespaceName),
new XElement(XName.Get("pPr", DocX.w.NamespaceName),
new XElement(XName.Get("numPr", DocX.w.NamespaceName),
new XElement(XName.Get("ilvl", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", level)),
new XElement(XName.Get("numId", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", list.NumId)))),
new XElement(XName.Get("r", DocX.w.NamespaceName), new XElement(XName.Get("t", DocX.w.NamespaceName), listText))
);
if (trackChanges)
newParagraphSection = CreateEdit(EditType.ins, DateTime.Now, newParagraphSection);
if (startNumber == null)
{
list.AddItem(new Paragraph(list.Document, newParagraphSection, 0, ContainerType.Paragraph));
}
else
{
list.AddItemWithStartValue(new Paragraph(list.Document, newParagraphSection, 0, ContainerType.Paragraph), (int)startNumber);
}
}
return list;
}