本文整理汇总了C#中Novacode.List.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# List.Clear方法的具体用法?C# List.Clear怎么用?C# List.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.List
的用法示例。
在下文中一共展示了List.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remove
/// <summary>
/// Remove this Paragraph from the document.
/// </summary>
/// <param name="trackChanges">Should this remove be tracked as a change?</param>
/// <example>
/// Remove a Paragraph from a document and track it as a change.
/// <code>
/// // Create a document using a relative filename.
/// using (DocX document = DocX.Load(@"C:\Example\Test.docx"))
/// {
/// // Create and Insert a new Paragraph into this document.
/// Paragraph p = document.InsertParagraph("Hello", false);
///
/// // Remove the Paragraph and track this as a change.
/// p.Remove(true);
///
/// // Save all changes made to this document.
/// document.Save();
/// }// Release this document from memory.
/// </code>
/// </example>
public void Remove(bool trackChanges)
{
if (trackChanges)
{
DateTime now = DateTime.Now.ToUniversalTime();
List<XElement> elements = Xml.Elements().ToList();
List<XElement> temp = new List<XElement>();
for (int i = 0; i < elements.Count(); i++)
{
XElement e = elements[i];
if (e.Name.LocalName != "del")
{
temp.Add(e);
e.Remove();
}
else
{
if (temp.Count() > 0)
{
e.AddBeforeSelf(CreateEdit(EditType.del, now, temp.Elements()));
temp.Clear();
}
}
}
if (temp.Count() > 0)
Xml.Add(CreateEdit(EditType.del, now, temp));
}
else
{
// If this is the only Paragraph in the Cell then we cannot remove it.
if (Xml.Parent.Name.LocalName == "tc" && Xml.Parent.Elements(XName.Get("p", DocX.w.NamespaceName)).Count() == 1)
Xml.Value = string.Empty;
else
{
// Remove this paragraph from the document
Xml.Remove();
Xml = null;
}
}
}
示例2: GenerateVisio
//.........这里部分代码省略.........
var references = languageContext.GetReferences(runbooksList);
if (references.Count == 0)
continue;
var totalRows = (double)(runbooksList.Count / maxProcessCountPerRow);
if (runbooksList.Count <= maxProcessCountPerRow)
totalRows = 2.0;
var y = (pageHeight / totalRows) + (totalRows * ((processHeight + processPaddingVertical)) / totalRows);
var x = (pageWidth / (maxProcessCountPerRow - 1)) + ((processWidth + processPaddingHorizontal) * activityPos);
var ay = y - ((processHeight + processPaddingVertical) * activityYPos);
// Add the current runbook as the start activity
var processId = document.GetMasterMetaData("Process").ID;
var visioActivity = new VisioShape(processId, x, ay, processWidth, processHeight);
var charFormat = new VisioAutomation.VDX.Sections.Char();
charFormat.Size.Result = 12;
visioActivity.CharFormats = new List<VisioAutomation.VDX.Sections.Char>();
visioActivity.CharFormats.Add(charFormat);
visioActivity.Text.Add(runbookProxy.RunbookName);
page.Shapes.Add(visioActivity);
shapes.Add(visioActivity);
activityPos += addToHorizontal;
foreach (var reference in references)
{
x = (pageWidth / (maxProcessCountPerRow - 1)) + ((processWidth + processPaddingHorizontal) * activityPos);
ay = y - ((processHeight + processPaddingVertical) * activityYPos);
// Add all references
processId = document.GetMasterMetaData("Process").ID;
visioActivity = new VisioShape(processId, x, ay, processWidth, processHeight);
visioActivity.CharFormats = new List<VisioAutomation.VDX.Sections.Char>();
visioActivity.CharFormats.Add(charFormat);
visioActivity.Text.Add(reference.RunbookName);
page.Shapes.Add(visioActivity);
shapes.Add(visioActivity);
/*//if (!String.IsNullOrEmpty(activity.Description))
{
int shapeID = visioActivity.ID;
var callOut = new VisioShape(26, x + 0.3, ay + 1.0);
//callOut.Text.Add(activity.Description);
callOut.Geom = new VisioAutomation.VDX.Sections.Geom();
page.Shapes.Add(callOut);
}*/
activityPos++;
if (activityPos >= maxProcessCountPerRow)
{
addToHorizontal = -1;
activityPos += addToHorizontal;
activityYPos++;
}
else
{
addToHorizontal = 1;
activityPos += addToHorizontal;
activityYPos++;
}
}
// Add connectors between the activities
for (int i = 0; i < shapes.Count; i++)
{
// We only add connectors up until the latest process object
if ((i + 1) >= shapes.Count)
break;
VisioShape a1 = shapes[i];
VisioShape a2 = shapes[i + 1];
var line = VisioShape.CreateDynamicConnector(document);
line.XForm1D.EndY.Result = 0;
line.Line = new VisioLine();
line.Line.EndArrow.Result = 2;
page.Shapes.Add(line);
page.ConnectShapesViaConnector(line, a1, a2);
}
shapes.Clear();
languageContext.ClearCache();
}
document.Save(drawingOutputPath);
}