コード例 #1
0
        /// <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);
        }