本文整理汇总了C#中Comment.SetText方法的典型用法代码示例。如果您正苦于以下问题:C# Comment.SetText方法的具体用法?C# Comment.SetText怎么用?C# Comment.SetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment.SetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTextEx
public void SetTextEx()
{
//ExStart
//ExFor:Comment.SetText
//ExSummary:Shows how to add a comment to a document and set it's text.
Document doc = new Document(MyDir + "Document.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now);
builder.CurrentParagraph.AppendChild(comment);
comment.SetText("My comment.");
//ExEnd
}
示例2: FromStrings
public static Document FromStrings(string[] strings, out Run[] runs)
{
var builder = new DocumentBuilder();
var runList = new List<Run>();
var comments = new Dictionary<string, Comment>();
foreach (var str in strings)
{
// Bookmark
if (str.StartsWith("@{") && str.EndsWith("}"))
{
if (str.StartsWith("@{/"))
{
var bookmarkName = str.Substring(3, str.Length - 4);
builder.EndBookmark(bookmarkName);
}
else
{
var bookmarkName = str.Substring(2, str.Length - 3);
builder.StartBookmark(bookmarkName);
}
continue;
}
// Comment
if (str.StartsWith("!{") && str.EndsWith("}"))
{
if (str.StartsWith("!{/"))
{
var commentName = str.Substring(3, str.Length - 4);
var comment = comments[commentName];
var commentEnd = new CommentRangeEnd(builder.Document, comment.Id);
builder.InsertNode(commentEnd);
}
else
{
var commentName = str.Substring(2, str.Length - 3);
var comment = new Comment(builder.Document, "", "", DateTime.Now);
comments.Add(commentName, comment);
comment.SetText("Comment: " + commentName);
builder.InsertNode(comment);
var commentStart = new CommentRangeStart(builder.Document, comment.Id);
builder.InsertNode(commentStart);
}
continue;
}
runList.Add(builder.InsertRun(str));
}
runs = runList.ToArray();
return builder.Document;
}