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