我有以下原始字符串:“这是文本框中的原始句子”。我对此文本进行了更改,将“原始句子”替换为“新文本”,并在“文本框”之后添加了“形状”一词。现在我必须将所有内容标记并显示为一个整体:
这是代码,但它不会产生预期的结果。//创建一个颜色 Color myForegroundColor = Color.Red; 颜色 mtBlackColor = 颜色.黑色;
//Translate to an OLE color
int redColor = ColorTranslator.ToOle(myForegroundColor);
int blackColor = ColorTranslator.ToOle(myBlackColor);
for (int i = 0; i < diff.Count; i++)
{
if (diff[i].operation == Operation.DELETE)
{
// This is for "original sentence"
PowerPoint.TextRange tr = allMarkupTextRange.InsertAfter(diff[i].text);
tr.Font.Color.RGB = redColor;
tr.Font.Underline = MsoTriState.msoFalse;
//allMarkupTextRange2.InsertAfter(diff[i].text).Font.Strikethrough = MsoTriState.msoTrue;
}
else if (diff[i].operation == Operation.INSERT)
{
// This is for "new text" and for "shape" parts
PowerPoint.TextRange tr = allMarkupTextRange.InsertAfter(diff[i].text);
tr.Font.Color.RGB = redColor;
tr.Font.Underline = MsoTriState.msoTrue;
}
else
{
// This is for the rest
PowerPoint.TextRange tr = allMarkupTextRange.InsertAfter(diff[i].text);
tr.Font.Color.RGB = blackColor;
tr.Font.Underline = MsoTriState.msoFalse;
}
}
编辑:我几乎解决了这段代码的问题。但是,我剩下的主要问题是:如何实现删除线字体?