本文整理汇总了C#中System.Windows.Forms.Document.GetLine方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetLine方法的具体用法?C# Document.GetLine怎么用?C# Document.GetLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Document
的用法示例。
在下文中一共展示了Document.GetLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecalculateLine
/// <summary>
/// Go through all tags on a line and recalculate all size-related values;
/// returns true if lineheight changed
/// </summary>
internal bool RecalculateLine (Graphics g, Document doc)
{
LineTag tag;
int pos;
int len;
SizeF size;
float w;
int prev_offset;
bool retval;
bool wrapped;
Line line;
int wrap_pos;
int prev_height;
int prev_ascent;
pos = 0;
len = this.text.Length;
tag = this.tags;
prev_offset = this.offset; // For drawing optimization calculations
prev_height = this.height;
prev_ascent = this.ascent;
this.height = 0; // Reset line height
this.ascent = 0; // Reset the ascent for the line
tag.Shift = 0; // Reset shift (which should be stored as pixels, not as points)
if (ending == LineEnding.Wrap)
widths[0] = document.left_margin + hanging_indent;
else
widths[0] = document.left_margin + indent;
this.recalc = false;
retval = false;
wrapped = false;
wrap_pos = 0;
while (pos < len) {
while (tag.Length == 0) { // We should always have tags after a tag.length==0 unless len==0
//tag.Ascent = 0;
tag.Shift = (tag.Line.ascent - tag.Ascent) / 72;
tag = tag.Next;
}
size = tag.SizeOfPosition (g, pos);
w = size.Width;
if (Char.IsWhiteSpace (text[pos]))
wrap_pos = pos + 1;
if (doc.wrap) {
if ((wrap_pos > 0) && (wrap_pos != len) && (widths[pos] + w) + 5 > (doc.viewport_width - this.right_indent)) {
// Make sure to set the last width of the line before wrapping
widths[pos + 1] = widths[pos] + w;
pos = wrap_pos;
len = text.Length;
doc.Split (this, tag, pos);
ending = LineEnding.Wrap;
len = this.text.Length;
retval = true;
wrapped = true;
} else if (pos > 1 && (widths[pos] + w) > (doc.viewport_width - this.right_indent)) {
// No suitable wrap position was found so break right in the middle of a word
// Make sure to set the last width of the line before wrapping
widths[pos + 1] = widths[pos] + w;
doc.Split (this, tag, pos);
ending = LineEnding.Wrap;
len = this.text.Length;
retval = true;
wrapped = true;
}
}
// Contract all wrapped lines that follow back into our line
if (!wrapped) {
pos++;
widths[pos] = widths[pos - 1] + w;
if (pos == len) {
line = doc.GetLine (this.line_no + 1);
if ((line != null) && (ending == LineEnding.Wrap || ending == LineEnding.None)) {
// Pull the two lines together
doc.Combine (this.line_no, this.line_no + 1);
len = this.text.Length;
retval = true;
}
}
}
if (pos == (tag.Start - 1 + tag.Length)) {
// We just found the end of our current tag
//.........这里部分代码省略.........
示例2: RecalculateLine
//.........这里部分代码省略.........
if ((wrap_pos > 0) && (wrap_pos != len) && (newWidth + 5) > (doc.viewport_width - this.right_indent)) {
// Make sure to set the last width of the line before wrapping
widths[pos + 1] = newWidth;
pos = wrap_pos;
len = text.Length;
doc.Split (this, tag, pos);
ending = LineEnding.Wrap;
len = this.text.Length;
retval = true;
wrapped = true;
} else if (pos > 1 && newWidth > (doc.viewport_width - this.right_indent)) {
// No suitable wrap position was found so break right in the middle of a word
// Make sure to set the last width of the line before wrapping
widths[pos + 1] = newWidth;
doc.Split (this, tag, pos);
ending = LineEnding.Wrap;
len = this.text.Length;
retval = true;
wrapped = true;
}
}
// Contract all wrapped lines that follow back into our line
if (!wrapped) {
pos++;
widths[pos] = newWidth;
if (pos == len) {
line = doc.GetLine (this.line_no + 1);
if ((line != null) && (ending == LineEnding.Wrap || ending == LineEnding.None)) {
// Pull the two lines together
doc.Combine (this.line_no, this.line_no + 1);
len = this.text.Length;
retval = true;
}
}
}
if (pos == (tag.Start - 1 + tag.Length)) {
// We just found the end of our current tag
tag.Height = tag.MaxHeight ();
// Check if we're the tallest on the line (so far)
if (tag.Height > this.height)
this.height = tag.Height; // Yep; make sure the line knows
if (tag.Ascent > this.ascent) {
LineTag t;
// We have a tag that has a taller ascent than the line;
t = tags;
while (t != null && t != tag) {
t.Shift = (tag.Ascent - t.Ascent) / 72;
t = t.Next;
}
// Save on our line
this.ascent = tag.Ascent;
} else {
tag.Shift = (this.ascent - tag.Ascent) / 72;
}