public static WordToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { WordToPrint nextWord = new WordToPrint(); // match the words for same font / color Match m; CharToPrint nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); if (m.Success) { while (m.Success) { nextWord.Append(nextChar); index++; if (index >= rtb.Text.Length) { break; } nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); } // TODO: do what with .,/: and other punctuation at the end of a word. } else { nextWord.Append(nextChar); } return(nextWord); }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called once /// prior to each call to Print. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// The bounds passed already takes the margins into account - so you cannot /// print or do anything within these margins. /// </param> /// <returns>The values for RequireSize, Fits and Continues for this section.</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { this.linesToPrint = new ArrayList(100); SectionSizeValues retval = new SectionSizeValues(); WordToPrint nextWord = null; int nextIndex; while (charIndex < this.richTextBox1.Text.Length) { LineToPrint line = LineToPrint.Get(charIndex, g, bounds.Position, bounds.Width, this.richTextBox1, ref nextWord, out nextIndex); if (line.Size.Height + bounds.Position.Y < bounds.Limit.Y) { linesToPrint.Add(line); charIndex = nextIndex; retval.RequiredSize.Width = Math.Max(retval.RequiredSize.Width, line.Size.Width); retval.RequiredSize.Height += line.Size.Height; bounds.Position.Y += line.Size.Height; } else { retval.Continued = true; break; } } retval.Fits = true; return(retval); }
public static LineToPrint Get(int index, Graphics g, PointF pos, float width, RichTextBox rtb, ref WordToPrint nextWord, out int nextIndex) { LineToPrint line = new LineToPrint(); if (nextWord != null) { line.Append(nextWord); pos.X += nextWord.Size.Width; } nextWord = null; int i = index; while (i < rtb.Text.Length) { WordToPrint word = WordToPrint.Get(i, g, pos, rtb); i += word.Length; if (word.IsLineBreak) { // throw it away? break; } else if (word.Size.Width + line.Size.Width < width) { line.Append(word); pos.X += word.Size.Width; } else { nextWord = word; break; } } nextIndex = i; return(line); }
public void Append(WordToPrint aWord) { wordsToPrint.Add(aWord); Size.Width += aWord.Size.Width; Size.Height = Math.Max(Size.Height, aWord.Size.Height); }
public static WordToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { WordToPrint nextWord = new WordToPrint(); // match the words for same font / color Match m; CharToPrint nextChar = CharToPrint.Get (index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); if (m.Success) { while (m.Success) { nextWord.Append (nextChar); index++; if (index >= rtb.Text.Length) break; nextChar = CharToPrint.Get (index, g, pos, rtb); m = wordSeparator.Match (nextChar.Text.ToString()); } // TODO: do what with .,/: and other punctuation at the end of a word. } else { nextWord.Append (nextChar); } return nextWord; }
public void Append(WordToPrint aWord) { wordsToPrint.Add (aWord); Size.Width += aWord.Size.Width; Size.Height = Math.Max (Size.Height, aWord.Size.Height); }
public static LineToPrint Get(int index, Graphics g, PointF pos, float width, RichTextBox rtb, ref WordToPrint nextWord, out int nextIndex) { LineToPrint line = new LineToPrint(); if (nextWord != null) { line.Append (nextWord); pos.X += nextWord.Size.Width; } nextWord = null; int i = index; while (i < rtb.Text.Length) { WordToPrint word = WordToPrint.Get (i, g, pos, rtb); i += word.Length; if (word.IsLineBreak) { // throw it away? break; } else if (word.Size.Width + line.Size.Width < width) { line.Append (word); pos.X += word.Size.Width; } else { nextWord = word; break; } } nextIndex = i; return line; }