本文整理汇总了C#中TextLine类的典型用法代码示例。如果您正苦于以下问题:C# TextLine类的具体用法?C# TextLine怎么用?C# TextLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextLine类属于命名空间,在下文中一共展示了TextLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTextLine
private static void DrawTextLine(Graphics grph, TextLine line)
{
foreach (Word word in line.Words)
DrawWord(grph, word);
line.Draw(grph);
}
示例2: PutText
void PutText(int typeId, string text)
{
TextLine tl = new TextLine(typeId, text);
lines.Insert(0, tl);
if (maxLines > 0 && lines.Count > maxLines)
lines.RemoveRange(maxLines, lines.Count - maxLines);
}
示例3: AbstractIndenter
public AbstractIndenter(
ISyntaxFactsService syntaxFacts,
SyntaxTree syntaxTree,
IEnumerable<IFormattingRule> rules,
OptionSet optionSet,
TextLine lineToBeIndented,
CancellationToken cancellationToken)
{
var syntaxRoot = syntaxTree.GetRoot(cancellationToken);
this._syntaxFacts = syntaxFacts;
this.OptionSet = optionSet;
this.Tree = syntaxTree;
this.LineToBeIndented = lineToBeIndented;
this.TabSize = this.OptionSet.GetOption(FormattingOptions.TabSize, syntaxRoot.Language);
this.CancellationToken = cancellationToken;
this.Rules = rules;
this.Finder = new BottomUpBaseIndentationFinder(
new ChainedFormattingRules(this.Rules, OptionSet),
this.TabSize,
this.OptionSet.GetOption(FormattingOptions.IndentationSize, syntaxRoot.Language),
tokenStream: null,
lastToken: default(SyntaxToken));
}
示例4: GetIndentationOfLine
protected IndentationResult GetIndentationOfLine(TextLine lineToMatch, int addedSpaces)
{
var firstNonWhitespace = lineToMatch.GetFirstNonWhitespacePosition();
firstNonWhitespace = firstNonWhitespace ?? lineToMatch.End;
return GetIndentationOfPosition(firstNonWhitespace.Value, addedSpaces);
}
示例5: CSVSheet
CSVSheet(string filePath, TextLine textLine)
{
Assert.IsTrue(textLine != null);
this.filePath = filePath;
using (var lines = textLine.GetEnumerator())
{
lines.MoveNext();
string colNames = lines.Current;
lines.MoveNext();
string colTypes = lines.Current;
this.columnInfo = new ColumnInfo(colNames, colTypes, filePath);
List<RowData> tempList = new List<RowData>();
while (lines.MoveNext())
{
string line = lines.Current;
if (!string.IsNullOrEmpty(line))
{
var tokens = line.Split(',');
var newRow = new RowData(tokens);
Assert.IsTrue(newRow.IsValidInLength(columnInfo), string.Format("tokens.Length={0}, columnInfo.Length={1} in \n{2}", tokens.Length, columnInfo.Length, line));
int errIndex;
Assert.IsTrue(newRow.IsValidInType(columnInfo, out errIndex), errIndex < 0 ? string.Empty : string.Format("Converting error: [{0}] to {1} in {2}", tokens[errIndex], columnInfo[errIndex].Value, filePath));
tempList.Add(newRow);
}
}
rows = tempList;
}
}
示例6: GetIndenter
protected override AbstractIndenter GetIndenter(
ISyntaxFactsService syntaxFacts, SyntaxTree syntaxTree, TextLine lineToBeIndented, IEnumerable<IFormattingRule> formattingRules, OptionSet optionSet, CancellationToken cancellationToken)
{
return new Indenter(
syntaxFacts, syntaxTree, formattingRules,
optionSet, lineToBeIndented, cancellationToken);
}
示例7: TextLineInfo
public TextLineInfo(string file, IImage img, TextLine line, bool orient)
{
Line = line;
var firstRect = line.Chars.First();
Coordinate = new Point(firstRect.Left, firstRect.Top);
FileName = file;
Size = img.Size;
Orientation = orient;
}
示例8: Example_04
public Example_04()
{
String fileName = "data/happy-new-year.txt";
FileStream fos = new FileStream("Example_04.pdf", FileMode.Create);
BufferedStream bos = new BufferedStream(fos);
PDF pdf = new PDF(bos);
pdf.setCompressor(Compressor.ORIGINAL_ZLIB);
Font f1 = new Font(
pdf,
"AdobeMingStd-Light", // Chinese (Traditional) font
CodePage.UNICODE);
Font f2 = new Font(
pdf,
"AdobeSongStd-Light", // Chinese (Simplified) font
CodePage.UNICODE);
Font f3 = new Font(
pdf,
"KozMinProVI-Regular", // Japanese font
CodePage.UNICODE);
Font f4 = new Font(
pdf,
"AdobeMyungjoStd-Medium", // Korean font
CodePage.UNICODE);
Page page = new Page(pdf, Letter.PORTRAIT);
f1.SetSize(14);
f2.SetSize(14);
f3.SetSize(14);
f4.SetSize(14);
double x_pos = 100.0;
double y_pos = 20.0;
StreamReader reader = new StreamReader(
new FileStream(fileName, FileMode.Open));
TextLine text = new TextLine(f1);
String line = null;
while ((line = reader.ReadLine()) != null) {
if (line.IndexOf("Simplified") != -1) {
text.SetFont(f2);
} else if (line.IndexOf("Japanese") != -1) {
text.SetFont(f3);
} else if (line.IndexOf("Korean") != -1) {
text.SetFont(f4);
}
text.SetText(line);
text.SetPosition(x_pos, y_pos += 24);
text.DrawOn(page);
}
reader.Close();
pdf.Flush();
bos.Close();
}
示例9: CheckEqualLine
void CheckEqualLine(TextLine first, TextLine second)
{
Assert.Equal(first, second);
#if false
// We do not guarantee either identity or Equals!
Assert.Equal(first.Extent, second.Extent);
Assert.Equal(first.ExtentIncludingLineBreak, second.ExtentIncludingLineBreak);
#endif
}
示例10: ShouldUseSmartTokenFormatterInsteadOfIndenter
protected override bool ShouldUseSmartTokenFormatterInsteadOfIndenter(
IEnumerable<IFormattingRule> formattingRules,
SyntaxNode root,
TextLine line,
OptionSet optionSet,
CancellationToken cancellationToken)
{
return ShouldUseSmartTokenFormatterInsteadOfIndenter(
formattingRules, (CompilationUnitSyntax)root, line, optionSet, cancellationToken);
}
示例11: ShouldUseSmartTokenFormatterInsteadOfIndenter
public static bool ShouldUseSmartTokenFormatterInsteadOfIndenter(
IEnumerable<IFormattingRule> formattingRules,
CompilationUnitSyntax root,
TextLine line,
OptionSet optionSet,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(formattingRules);
Contract.ThrowIfNull(root);
if (!optionSet.GetOption(FeatureOnOffOptions.AutoFormattingOnReturn, LanguageNames.CSharp))
{
return false;
}
if (optionSet.GetOption(FormattingOptions.SmartIndent, LanguageNames.CSharp) != FormattingOptions.IndentStyle.Smart)
{
return false;
}
var firstNonWhitespacePosition = line.GetFirstNonWhitespacePosition();
if (!firstNonWhitespacePosition.HasValue)
{
return false;
}
var token = root.FindToken(firstNonWhitespacePosition.Value);
if (token.IsKind(SyntaxKind.None) ||
token.SpanStart != firstNonWhitespacePosition)
{
return false;
}
// first see whether there is a line operation for current token
var previousToken = token.GetPreviousToken(includeZeroWidth: true);
// only use smart token formatter when we have two visible tokens.
if (previousToken.Kind() == SyntaxKind.None || previousToken.IsMissing)
{
return false;
}
var lineOperation = FormattingOperations.GetAdjustNewLinesOperation(formattingRules, previousToken, token, optionSet);
if (lineOperation == null || lineOperation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
{
// no indentation operation, nothing to do for smart token formatter
return false;
}
// We're pressing enter between two tokens, have the formatter figure out hte appropriate
// indentation.
return true;
}
示例12: IsBlank
private static bool IsBlank(TextLine line)
{
var text = line.ToString();
for (int i = 0; i < text.Length; i++)
{
if (!SyntaxFacts.IsWhitespace(text[i]))
{
return false;
}
}
return true;
}
示例13: SplitByLines
public void SplitByLines(float _width, EFonts _font, float _newLineIndent, IDrawHelper _drawHelper)
{
var textLines = new List<TextLine>();
var paragraphs = Text.Split(new[] {Environment.NewLine, "\t"}, StringSplitOptions.RemoveEmptyEntries);
var sb = new StringBuilder();
foreach (var paragraph in paragraphs)
{
sb.Clear();
var x = _newLineIndent;
var tl = new TextLine(x, Highlights);
textLines.Add(tl);
var part = paragraph.Split(Punctuation);
var processedChars = 0;
for (var partIndex = 0; partIndex < part.Length; partIndex++)
{
var addStr = part[partIndex];
processedChars += addStr.Length;
addStr += (processedChars == 0 || processedChars >= paragraph.Length)
? ""
: paragraph[processedChars].ToString(CultureInfo.InvariantCulture);
processedChars++;
var size = _drawHelper.MeasureString(_font, addStr);
if (size.Width > (_width - x))
{
tl.Text = sb.ToString();
sb.Clear();
x = 0;
tl = new TextLine(x, Highlights);
textLines.Add(tl);
}
sb.Append(addStr);
x += size.Width;
}
if (sb.Length > 0)
{
tl.Text = sb.ToString();
}
}
m_textLines = textLines.ToArray();
}
示例14: TableGenerator
TableGenerator(string resPath, string className)
{
TextAsset csvFile = Resources.Load(resPath) as TextAsset;
Assert.IsTrue(csvFile != null, "File not found: " + resPath);
TextLine textLine = new TextLine(csvFile.text);
Assert.IsTrue(textLine != null);
using (var lines = textLine.GetEnumerator())
{
lines.MoveNext();
string colNames = lines.Current;
lines.MoveNext();
string colTypes = lines.Current;
this.columnInfo = new ColumnInfo(colNames, colTypes, resPath);
}
this.className = className;
}
示例15: ItemGetter
private ItemGetter(
AbstractOverrideCompletionProvider overrideCompletionProvider,
Document document,
int position,
SourceText text,
SyntaxTree syntaxTree,
int startLineNumber,
TextLine startLine,
CancellationToken cancellationToken)
{
_provider = overrideCompletionProvider;
_document = document;
_position = position;
_text = text;
_syntaxTree = syntaxTree;
_startLineNumber = startLineNumber;
_startLine = startLine;
_cancellationToken = cancellationToken;
}