本文整理汇总了C#中Paragraph.RemoveAllChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.RemoveAllChildren方法的具体用法?C# Paragraph.RemoveAllChildren怎么用?C# Paragraph.RemoveAllChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paragraph
的用法示例。
在下文中一共展示了Paragraph.RemoveAllChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRunsToSdtContentCell
/// <summary>
/// Adds the runs to SDT content cell.
/// </summary>
/// <param name="sdtContentCell">The SDT content cell.</param>
/// <param name="runs">The runs.</param>
private static void AddRunsToSdtContentCell(OpenXmlCompositeElement sdtContentCell, IEnumerable<Run> runs)
{
var cell = new TableCell();
var para = new Paragraph();
para.RemoveAllChildren();
foreach (var run in runs)
{
para.AppendChild(run);
}
cell.AppendChild(para);
SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
}
示例2: AddRunsToSdtContentCell
/// <summary>
/// Adds the runs to SDT content cell.
/// </summary>
/// <param name="sdtContentCell">The SDT content cell.</param>
/// <param name="runs">The runs.</param>
private void AddRunsToSdtContentCell(SdtContentCell sdtContentCell, List<Run> runs)
{
TableCell cell = new TableCell();
Paragraph para = new Paragraph();
para.RemoveAllChildren();
foreach (Run run in runs)
{
para.AppendChild<Run>(run);
}
cell.AppendChild<Paragraph>(para);
SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
}
示例3: AddRunsToSdtContentCell
/// <summary>
/// Adds the runs to SDT content cell.
/// </summary>
/// <param name="sdtContentCell">The SDT content cell.</param>
/// <param name="runs">The runs.</param>
private void AddRunsToSdtContentCell(SdtContentCell sdtContentCell, List<Run> runs)
{
TableCell cell = new TableCell();
Paragraph para = new Paragraph();
para.RemoveAllChildren();
if (sdtContentCell.Descendants<ParagraphProperties>().Count() > 0)
para.ParagraphProperties = (ParagraphProperties)sdtContentCell.Descendants<ParagraphProperties>().First().Clone();
foreach (Run run in runs)
{
para.AppendChild<Run>(run);
}
cell.AppendChild<Paragraph>(para);
SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
}
示例4: RemoveElementTest
public void RemoveElementTest()
{
Paragraph para = new Paragraph();
Run r1 = para.AppendChild(new Run());
Bold b1 = r1.AppendChild(new RunProperties()).AppendChild(new Bold());
Text t1 = r1.AppendChild(new Text());
BookmarkStart bkStart = para.AppendChild(new BookmarkStart());
Run r2 = para.AppendChild(new Run());
r2.AppendChild(new Text());
BookmarkEnd bkEnd = para.AppendChild(new BookmarkEnd());
Run r3 = para.AppendChild(new Run());
t1.Remove();
Assert.Equal(1, r1.ChildElements.Count);
Assert.Null(t1.Parent);
Assert.NotNull(r1.FirstChild);
Assert.NotNull(r1.LastChild);
r1.RemoveAllChildren<Text>(); // should do nothing
Assert.NotNull(r1.FirstChild);
Assert.NotNull(r1.LastChild);
r1.RemoveAllChildren<RunProperties>();
Assert.Null(r1.FirstChild);
Assert.Null(r1.LastChild);
para.RemoveAllChildren<BookmarkStart>();
Assert.Null(bkStart.Parent);
para.RemoveAllChildren<Run>();
Assert.Same(bkEnd, para.FirstChild);
Assert.Same(bkEnd, para.LastChild);
para.RemoveAllChildren<Run>(); // should do nothing
Assert.Same(bkEnd, para.FirstChild);
Assert.Same(bkEnd, para.LastChild);
}