本文整理汇总了C#中Paragraph.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.Add方法的具体用法?C# Paragraph.Add怎么用?C# Paragraph.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paragraph
的用法示例。
在下文中一共展示了Paragraph.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
++frames;
var fx = e.Graphics;
using ( var buffer = new Bitmap( ClientSize.Width, ClientSize.Height ) ) {
using ( var clr = Graphics.FromImage(buffer) ) clr.Clear( Color.Transparent );
var target = buffer.LockBits( ClientRectangle, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
int y = 0;
while ( y < ClientSize.Height ) {
#if false
string text = "Hello, World!";
Font.RenderLineTo( target, text, new Rectangle(0,y,ClientSize.Width,ClientSize.Height-y), Industry.FX.HorizontalAlignment.Center, VerticalAlignment.Top );
y += Font.MeasureLine(text).Advance.Y;
#else
Paragraph text = new Paragraph();
text.Add( new TextRun() { Font = RedFont , Text = "He" } );
text.Add( new TextRun() { Font = BlueFont, Text = "llo, W" } );
text.Add( new TextRun() { Font = RedFont , Text = "orld!" } );
var lines = text.ToLines(ClientSize.Width);
FX.Font.RenderLinesTo( target, lines, new Rectangle(0,y,ClientSize.Width,int.MaxValue), FX.HorizontalAlignment.Center, VerticalAlignment.Top );
y += FX.Font.MeasureLines(lines).Advance.Y;
#endif
}
DateTime now = DateTime.Now;
var span = now-prev;
if ( span.TotalSeconds >= 1.0 ) {
prev = now;
framedisplay = frames;
frames = 0;
}
RedFont.RenderLineTo( target, "FPS: "+framedisplay, ClientRectangle, Industry.FX.HorizontalAlignment.Right, VerticalAlignment.Top );
buffer.UnlockBits(target);
fx.DrawImage(buffer,0,0);
}
Invalidate();
}
示例2: GetActivatedText
public static Text GetActivatedText(Text text)
{
var activeText = new Text();
foreach(var paragraph in text)
{
var activeParagraph = new Paragraph();
foreach(var sentence in paragraph)
{
activeParagraph.Add(GetActivatedSentence(sentence));
}
activeText.Add(activeParagraph);
}
return activeText;
}
示例3: Main
static void Main()
{
Document doc = new Document();
doc.Title = "My First Document";
doc.Author = "Nakov";
doc.Add(new Paragraph("I am a paragraph"));
doc.Add(new Hyperlink("http://dir.bg"));
doc.Add(new Paragraph("I am another paragraph"));
doc.Add(new Heading("Heading 1"));
Paragraph paragraph = new Paragraph();
paragraph.Add(new TextElement("Default Font", Font.DefaultFont));
paragraph.Add(new TextElement(" "));
paragraph.Add(new TextElement("Second Red", new Font(color: Color.Red)));
paragraph.Add(new TextElement(" "));
paragraph.Add(new TextElement("Green Italic",
new Font(color: Color.Green, style: FontStyle.Italic)));
paragraph.Add(new Paragraph());
paragraph.Add(
new TextElement("Consolas Bold Blue Italic",
new Font(
color: Color.Blue,
style: FontStyle.BoldItalic,
name: "Consolas")));
doc.Add(paragraph);
doc.Add(new Heading("Heading 2<br>", 2));
doc.Add(
new Hyperlink("http://softuni.bg")
.Add(Image.CreateFromFile("../../logo.png"))
.Add(new TextElement("some text"))
);
doc.Add(paragraph);
var htmlDoc = new HtmlDocument(doc);
var writer = new StringWriter();
htmlDoc.Render(writer);
Console.WriteLine(writer.ToString());
File.WriteAllText("document.html", writer.ToString());
var txtDoc = new TxtDocument(doc);
writer = new StringWriter();
txtDoc.Render(writer);
Console.WriteLine(writer.ToString());
File.WriteAllText("document.txt", writer.ToString());
}
示例4: Parse
public static Text Parse(TextReader reader)
{
var text = new Text();
var line = reader.ReadLine();
while(!string.IsNullOrEmpty(line))
{
var paragraph = new Paragraph();
text.Add(paragraph);
while (!string.IsNullOrEmpty(line))
{
var sentenceString = line;
var terminalPunctuationMark = line.GetFirstOrDefaultPunctuationMark(DefaultPunctuationMarks.TerminalPunctuationMarks);
if (terminalPunctuationMark.HasValue)
{
var index = line.IndexOfPunctuationMark(terminalPunctuationMark);
sentenceString = line.Substring(0, index).TrimStart(' ');
line = line.Remove(0, index + terminalPunctuationMark.StringValue.Length);
if(text.Count > 1)
{
var lastParagraph = text.Last(p => p.HasValue);
if (lastParagraph.Any())
{
var lastSentence = lastParagraph.Last();
if (lastSentence.IsNotFinished)
{
text.Remove(paragraph);
paragraph = lastParagraph;
lastSentence.Concat(sentenceString);
continue;
}
}
}
}
else
{
line = string.Empty;
}
var sentence = ParseSentenceString(sentenceString, terminalPunctuationMark);
paragraph.Add(sentence);
}
line = reader.ReadLine();
}
return text;
}
示例5: ImportCell
/**
* Imports the Cell properties into the RtfCell
*
* @param cell The PdfPCell to import
* @since 2.1.3
*/
private void ImportCell(PdfPCell cell)
{
this.content = new ArrayList();
if (cell == null) {
this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, this.parentRow.GetParentTable().GetBorders());
return;
}
// padding
this.cellPadding = (int) this.parentRow.GetParentTable().GetCellPadding();
this.cellPaddingBottom = cell.PaddingBottom;
this.cellPaddingTop = cell.PaddingTop;
this.cellPaddingRight = cell.PaddingRight;
this.cellPaddingLeft = cell.PaddingLeft;
// BORDERS
this.borders = new RtfBorderGroup(this.document, RtfBorder.CELL_BORDER, cell.Border, cell.BorderWidth, cell.BorderColor);
// border colors
this.border = cell.Border;
this.borderColor = cell.BorderColor;
this.borderColorBottom = cell.BorderColorBottom;
this.borderColorTop = cell.BorderColorTop;
this.borderColorLeft = cell.BorderColorLeft;
this.borderColorRight = cell.BorderColorRight;
// border widths
this.borderWidth = cell.BorderWidth;
this.borderWidthBottom = cell.BorderWidthBottom;
this.borderWidthTop = cell.BorderWidthTop;
this.borderWidthLeft = cell.BorderWidthLeft;
this.borderWidthRight = cell.BorderWidthRight;
this.colspan = cell.Colspan;
this.rowspan = 1; //cell.GetRowspan();
// if (cell.GetRowspan() > 1) {
// this.mergeType = MERGE_VERT_PARENT;
// }
this.verticalAlignment = cell.VerticalAlignment;
if (cell.BackgroundColor == null) {
this.backgroundColor = new RtfColor(this.document, 255, 255, 255);
} else {
this.backgroundColor = new RtfColor(this.document, cell.BackgroundColor);
}
// does it have column composite info?
ArrayList compositeElements = cell.CompositeElements;
if (compositeElements != null) {
// does it have column info?
Paragraph container = null;
foreach (IElement element in compositeElements) {
try {
// should we wrap it in a paragraph
if (!(element is Paragraph) && !(element is Legacy.Text.List)) {
if (container != null) {
container.Add(element);
} else {
container = new Paragraph();
container.Alignment = cell.HorizontalAlignment;
container.Add(element);
}
} else {
IRtfBasicElement[] rtfElements = null;
if (container != null) {
rtfElements = this.document.GetMapper().MapElement(container);
for (int i = 0; i < rtfElements.Length; i++) {
rtfElements[i].SetInTable(true);
this.content.Add(rtfElements[i]);
}
container = null;
}
// if horizontal alignment is undefined overwrite
// with that of enclosing cell
if (element is Paragraph && ((Paragraph) element).Alignment == Element.ALIGN_UNDEFINED) {
((Paragraph) element).Alignment = cell.HorizontalAlignment;
}
rtfElements = this.document.GetMapper().MapElement(element);
for (int i = 0; i < rtfElements.Length; i++) {
rtfElements[i].SetInTable(true);
this.content.Add(rtfElements[i]);
}
}
} catch (DocumentException) {
}
}
if (container != null) {
try {
IRtfBasicElement[] rtfElements = this.document.GetMapper().MapElement(container);
for (int i = 0; i < rtfElements.Length; i++) {
rtfElements[i].SetInTable(true);
//.........这里部分代码省略.........
示例6: OnSortByButtonClick
private void OnSortByButtonClick(object sender, RoutedEventArgs e)
{
if (SortByWordsCountRadioButton.IsChecked.Value)
{
var sortedSentences = _text.GetSentences().OrderBy(sentence => sentence.Count);
var text = new Text();
foreach(var sentence in sortedSentences)
{
var paragraph = new Paragraph();
paragraph.Add(sentence);
text.Add(paragraph);
}
TextContainer.ItemsSource = text;
}
else if (SortBySentenceCountRadioButton.IsChecked.Value)
{
var sortedParagraphs = _text.OrderBy(paragraph => paragraph.Count);
var text = new Text();
foreach(var paragraph in sortedParagraphs)
{
text.Add(paragraph);
text.Add(new Paragraph());
}
TextContainer.ItemsSource = text;
}
}
示例7: RtfHeaderFooter
/**
* Constructs a RtfHeaderFooter for a HeaderFooter.
*
* @param doc The RtfDocument this RtfHeaderFooter belongs to
* @param headerFooter The HeaderFooter to base this RtfHeaderFooter on
*/
protected internal RtfHeaderFooter(RtfDocument doc, Legacy.Text.HeaderFooter headerFooter)
: base(new Phrase(""), false)
{
this.document = doc;
Paragraph par = new Paragraph();
par.Alignment = headerFooter.Alignment;
if (headerFooter.Before != null) {
par.Add(headerFooter.Before);
}
if (headerFooter.IsNumbered()) {
par.Add(new FD.RtfPageNumber(this.document));
}
if (headerFooter.After != null) {
par.Add(headerFooter.After);
}
try {
this.content = new Object[1];
this.content[0] = doc.GetMapper().MapElement(par)[0];
((IRtfBasicElement) this.content[0]).SetInHeader(true);
} catch (DocumentException) {
}
}