本文整理汇总了C#中TextLine.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TextLine.Add方法的具体用法?C# TextLine.Add怎么用?C# TextLine.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextLine
的用法示例。
在下文中一共展示了TextLine.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFunctionIntelliSense
FormattedText GetFunctionIntelliSense(FunctionInfo functionInfo, int currentArgIndex)
{
var nameLine = new TextLine { new TextRun { Text = functionInfo.Name, LinkAddress = FixHelpTopic(functionInfo.HelpTopic) } };
nameLine.Add(new TextRun { Text = "(" });
if (functionInfo.ArgumentList.Count > 0)
{
var argNames = functionInfo.ArgumentList.Take(currentArgIndex).Select(arg => arg.Name).ToArray();
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun { Text = string.Join(_argumentSeparator, argNames) });
}
if (functionInfo.ArgumentList.Count > currentArgIndex)
{
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun
{
Text = _argumentSeparator
});
}
nameLine.Add(new TextRun
{
Text = functionInfo.ArgumentList[currentArgIndex].Name,
Style = System.Drawing.FontStyle.Bold
});
argNames = functionInfo.ArgumentList.Skip(currentArgIndex + 1).Select(arg => arg.Name).ToArray();
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun {Text = _argumentSeparator + string.Join(_argumentSeparator, argNames)});
}
}
}
nameLine.Add(new TextRun { Text = ")" });
var descriptionLines = GetFunctionDescriptionOrNull(functionInfo);
var formattedText = new FormattedText { nameLine, descriptionLines };
if (functionInfo.ArgumentList.Count > currentArgIndex)
{
var description = GetArgumentDescriptionOrNull(functionInfo.ArgumentList[currentArgIndex]);
if (description != null)
formattedText.Add(description);
}
return formattedText;
}
示例2: Interpret
protected void Interpret(Graphics g)
{
this._isMeasureInSync = false; // if structure is changed, the measure is out of sync
char[] searchchars = new Char[] { '\\', '\r', '\n', ')' };
// Modification of StringFormat is necessary to avoid
// too big spaces between successive words
StringFormat strfmt = (StringFormat)StringFormat.GenericTypographic.Clone();
strfmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
strfmt.LineAlignment = StringAlignment.Far;
strfmt.Alignment = StringAlignment.Near;
// next statement is necessary to have a consistent string length both
// on 0 degree rotated text and rotated text
// without this statement, the text is fitted to the pixel grid, which
// leads to "steps" during scaling
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
MeasureFont(g, _font, out _cyBaseLineSpace, out _cyBaseAscent, out _cyBaseDescent);
System.Collections.Stack itemstack = new System.Collections.Stack();
Font currFont = (Font)_font.Clone();
if(null!=_cachedTextLines)
_cachedTextLines.Clear(); // delete old contents
else
_cachedTextLines = new TextLine.TextLineCollection();
TextLine currTextLine = new TextLine();
// create a new text line first
_cachedTextLines.Add(currTextLine);
int currTxtIdx = 0;
TextItem currTextItem = new TextItem(currFont);
// TextItem firstItem = currTextItem; // preserve the first item
currTextLine.Add(currTextItem);
while(currTxtIdx<_text.Length)
{
// search for the first occurence of a backslash
int bi = _text.IndexOfAny(searchchars,currTxtIdx);
if(bi<0) // nothing was found
{
// move the rest of the text to the current item
currTextItem.Text += _text.Substring(currTxtIdx,_text.Length-currTxtIdx);
currTxtIdx = _text.Length;
}
else // something was found
{
// first finish the current item by moving the text from
// currTxtIdx to (bi-1) to the current text item
currTextItem.Text += _text.Substring(currTxtIdx,bi-currTxtIdx);
if('\r'==_text[bi]) // carriage return character : simply ignore it
{
// simply ignore this character, since we search for \n
currTxtIdx=bi+1;
}
else if('\n'==_text[bi]) // newline character : create a new line
{
currTxtIdx = bi+1;
// create a new line
currTextLine = new TextLine();
_cachedTextLines.Add(currTextLine);
// create also a new text item
currTextItem = new TextItem(currTextItem,null);
currTextLine.Add(currTextItem);
}
else if('\\'==_text[bi]) // backslash : look what comes after
{
if(bi+1<_text.Length && (')'==_text[bi+1] || '\\'==_text[bi+1])) // if a closing brace or a backslash, take these as chars
{
currTextItem.Text += _text[bi+1];
currTxtIdx = bi+2;
}
// if the backslash not followed by a symbol and than a (,
else if(bi+3<_text.Length && !char.IsSeparator(_text,bi+1) && '('==_text[bi+2])
{
switch(_text[bi+1])
{
case 'b':
case 'B':
{
itemstack.Push(currTextItem);
currTextItem = new TextItem(currTextItem, new Font(currTextItem.Font.FontFamily,currTextItem.Font.Size,currTextItem.Font.Style | FontStyle.Bold, GraphicsUnit.World));
currTextLine.Add(currTextItem);
currTxtIdx = bi+3;
}
//.........这里部分代码省略.........
示例3: GetFunctionIntelliSense
FormattedText GetFunctionIntelliSense(IntelliSenseFunctionInfo functionInfo, int currentArgIndex)
{
var nameLine = new TextLine { new TextRun { Text = functionInfo.FunctionName + "(" } };
if (functionInfo.ArgumentList.Count > 0)
{
var argNames = functionInfo.ArgumentList.Take(currentArgIndex).Select(arg => arg.ArgumentName).ToArray();
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun { Text = string.Join(", ", argNames) });
}
if (functionInfo.ArgumentList.Count > currentArgIndex)
{
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun
{
Text = ", "
});
}
nameLine.Add(new TextRun
{
Text = functionInfo.ArgumentList[currentArgIndex].ArgumentName,
Style = System.Drawing.FontStyle.Bold
});
argNames = functionInfo.ArgumentList.Skip(currentArgIndex + 1).Select(arg => arg.ArgumentName).ToArray();
if (argNames.Length >= 1)
{
nameLine.Add(new TextRun {Text = ", " + string.Join(", ", argNames)});
}
}
}
nameLine.Add(new TextRun { Text = ")" });
var descriptionLines = GetFunctionDescription(functionInfo);
var formattedText = new FormattedText { nameLine, descriptionLines };
if (functionInfo.ArgumentList.Count > currentArgIndex)
{
formattedText.Add(GetArgumentDescription(functionInfo.ArgumentList[currentArgIndex]));
}
return formattedText;
}