Ejemplo n.º 1
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        /// <returns>Size.Width and Size.Height are for the largest sub-section
        /// in each direction, fits is true if any section fits, and continued
        /// is true if any section is continued.</returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SectionSizeValues retval = new SectionSizeValues();

            if (this.sections.Count == 0)
            {
                retval.Fits = true;
            }
            else
            {
                // TODO: get rid of enumerator, eventually hide sections
                foreach (ReportSection section in this.sections)
                {
                    section.CalcSize(reportDocument, g, bounds);
                    retval.RequiredSize.Height = Math.Max(
                        retval.RequiredSize.Height, section.Size.Height);
                    retval.RequiredSize.Width = Math.Max(
                        retval.RequiredSize.Width, section.Size.Width);
                    if (section.Continued)
                    {
                        retval.Continued = true;
                    }
                    if (section.Fits)
                    {
                        retval.Fits = true;
                    }
                }
            }
            return(retval);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Called to calculate the size that this section requires on
 /// the next call to Print.  This method will be called exactly once
 /// prior to each call to Print.  It must update the values Size and
 /// Continued of the ReportSection base class.
 /// </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.</param>
 /// <returns>Size.Width and Size.Height are for the largest sub-section
 /// in each direction, fits is true if any section fits, and continued
 /// is true if any section is continued.</returns>
 protected override SectionSizeValues DoCalcSize(
     ReportDocument reportDocument,
     Graphics g,
     Bounds bounds
     )
 {
     SectionSizeValues retval = new SectionSizeValues();
     if (this.sections.Count == 0)
     {
         retval.Fits = true;
     }
     else
     {
         // TODO: get rid of enumerator, eventually hide sections
         foreach (ReportSection section in this.sections)
         {
             section.CalcSize (reportDocument, g, bounds);
             retval.RequiredSize.Height = Math.Max (
                 retval.RequiredSize.Height, section.Size.Height);
             retval.RequiredSize.Width = Math.Max (
                 retval.RequiredSize.Width, section.Size.Width);
             if (section.Continued)
             {
                 retval.Continued = true;
             }
             if (section.Fits)
             {
                 retval.Fits = true;
             }
         }
     }
     return retval;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Method called to Calculate the size required for
 /// the next Print.  Calling this method initializes
 /// the values Size and Continued.  Once these values
 /// are initialized, further calls to CalcSize have
 /// no affect, unless ResetSize() is called.
 /// </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.</param>
 public void CalcSize(
     ReportDocument reportDocument,
     Graphics g,
     Bounds bounds)
 {
     BeginPrint(g);
     if (this.requiresNonEmptyBounds && bounds.IsEmpty())
     {
         this.fits = false;
     }
     else if (!this.sized)
     {
         // two default values
         this.sizingBounds = LimitBounds(bounds);
         SectionSizeValues vals = DoCalcSize(reportDocument, g, this.sizingBounds);
         SetSize(vals.RequiredSize, bounds);
         if (this.keepTogether && vals.Continued)
         {
             this.fits = false;
         }
         else
         {
             this.fits = vals.Fits;
         }
         this.continued = vals.Continued;
         this.sized     = true;
     }
 }
Ejemplo n.º 4
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
            )
        {
            // Take offset into account...
            bounds.Position.X += OffsetLeft;
            bounds.Position.Y += OffsetTop;

            SectionSizeValues retval = new SectionSizeValues();

            // need to determine what to do with these values...
            retval.Fits      = true;
            retval.Continued = false;

            SizeF contentSize = new SizeF(0, 0);

            if (CurrentSection != null)
            {
                CurrentSection.CalcSize(reportDocument, g, GetMaxContentBounds(bounds));
                contentSize = CurrentSection.Size; // or could use RequiredSize?
            }

            this.borderBounds  = GetBorderBounds(bounds, contentSize);
            this.paddingBounds = border.GetInnerBounds(this.borderBounds);
            this.contentBounds = paddingBounds.GetBounds(PaddingTop, PaddingRight,
                                                         PaddingBottom, PaddingLeft);

            retval.RequiredSize = this.borderBounds.GetSizeF();
            return(retval);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        } // AdvancePointers

        /// <summary>
        /// Sizes all the sections that fit within a single row/column
        /// </summary>
        /// <param name="reportDocument">Parent ReportDocument</param>
        /// <param name="g">Graphics object for sizing / printing</param>
        /// <param name="bounds">The bounds the line must fit within</param>
        /// <param name="sizeOnly">Indicates that no printing should be done,
        /// just size the line</param>
        /// <param name="advanceSectionIndex">Advance the section index,
        /// so that it's ready for the next line</param>
        /// <returns>Size and flags for if it fits and if it's continued</returns>
        protected SectionSizeValues SizePrintLine(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds,
            bool sizeOnly,
            bool advanceSectionIndex
            )
        {
            SectionSizeValues retvals = new SectionSizeValues();

            retvals.Fits = false;

            int savedSectionIndex = this.sectionIndex;

//            Debug.WriteLine("\nEntering " + Direction + " section, sizeonly = " + sizeOnly);
//            Debug.WriteLine("   Bounds: " + bounds);

            // The following loop sizes all sections that fit on one line
            // If it runs out of room within the current bounds, it returns
            // and will continue where it left off on the next call.
            while (this.sectionIndex < this.SectionCount)
            {
                CurrentSection.CalcSize(reportDocument, g, bounds);
                if (CurrentSection.Fits)
                {
                    retvals.Fits = true;
                    if (!sizeOnly)
                    {
                        CurrentSection.Print(reportDocument, g, bounds);
                    }
                    AdvancePointers(CurrentSection.Size, ref bounds, ref retvals.RequiredSize);
                    if (CurrentSection.Continued)
                    {
                        break;
                    }
                    else
                    {
                        this.sectionIndex++;
                    }
                }
                else // it doesn't fit
                {
                    // reset size since we didn't print but need the size to be
                    // refigured next time
                    CurrentSection.ResetSize();
                    break;
                }
            } // while

//            Debug.WriteLine("Leaving " + Direction + " section");
//            Debug.WriteLine("   Size: " + RequiredSize);

            retvals.Continued = this.sectionIndex < this.SectionCount;
            if (!advanceSectionIndex)
            {
                this.sectionIndex = savedSectionIndex;
            }
            return(retvals);
        } // SizePrintLine
Ejemplo n.º 7
0
        /// <summary>
        /// This method is called after a size and before a print if
        /// the bounds have changed between the sizing and the printing.
        /// Override this function to update anything based on the new location
        /// </summary>
        /// <param name="originalBounds">Bounds originally passed for sizing</param>
        /// <param name="newBounds">New bounds for printing</param>
        /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
        /// <remarks>To simply have size recalled, implement the following:
        /// <code>
        ///    this.ResetSize();
        ///    return base.BoundsChanged (originalBounds, newBounds);
        /// </code>
        /// </remarks>
        protected virtual SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            SectionSizeValues retval = new SectionSizeValues();

            retval.Fits         = this.Fits;
            retval.Continued    = this.Continued;
            retval.RequiredSize = this.RequiredSize;
            return(retval);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This method is called after a size and before a print if
        /// the bounds have changed between the sizing and the printing.
        /// Override this function to update anything based on the new location
        /// </summary>
        /// <param name="originalBounds">Bounds originally passed for sizing</param>
        /// <param name="newBounds">New bounds for printing</param>
        /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
        /// <remarks>To simply have size recalled, implement the following:
        /// <code>
        ///    this.ResetSize();
        ///    return base.ChangeBounds (originalBounds, newBounds);
        /// </code>
        /// </remarks>
        protected override SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            SectionSizeValues retval = new SectionSizeValues();

            this.imageRect      = GetImageRect(newBounds);
            retval.RequiredSize = this.imageRect.Size;
            retval.Fits         = newBounds.SizeFits(retval.RequiredSize);
            retval.Continued    = false;
            return(retval);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// This method is called after a size and before a print if
        /// the bounds have changed between the sizing and the printing.
        /// Override this function to update anything based on the new location
        /// </summary>
        /// <param name="originalBounds">Bounds originally passed for sizing</param>
        /// <param name="newBounds">New bounds for printing</param>
        /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
        /// <remarks>To simply have size recalled, implement the following:
        /// <code>
        ///    this.ResetSize();
        ///    return base.ChangeBounds (originalBounds, newBounds);
        /// </code>
        /// </remarks>
        protected override SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            // don't really do anything... (this is the base implementation)
            SectionSizeValues retval = new SectionSizeValues();

            retval.Fits         = this.Fits;
            retval.Continued    = this.Continued;
            retval.RequiredSize = this.RequiredSize;
            return(retval);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Re-computes the line based on changed bounds
        /// </summary>
        /// <param name="originalBounds">Original bounds used for size</param>
        /// <param name="newBounds">New bounds</param>
        /// <returns>SectionSizeValues struct</returns>
        protected override SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            SetLinePoints(newBounds);

            SectionSizeValues retvals = new SectionSizeValues();

            retvals.Fits         = true;
            retvals.Continued    = false;
            retvals.RequiredSize = GetSizeF();
            return(retvals);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Called to actually print this section.
        /// The DoCalcSize method will be called once prior to each
        /// call of DoPrint.
        /// DoPrint is not called if DoCalcSize sets fits to false.
        /// It should obey the values of Size and Continued as set by
        /// DoCalcSize().
        /// </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.
        /// These bounds already take the margins into account.
        /// </param>
        protected override void DoPrint(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            //g.TextRenderingHint = TextRenderingHint.AntiAlias;
            SectionSizeValues results = DrawEditControl(g, bounds, false);

            SetContinued(results.Continued);
            SetFits(results.Fits);
            SetSize(results.RequiredSize, bounds);
        }
Ejemplo n.º 12
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
            )
        {
            SectionSizeValues retval = new SectionSizeValues();

            retval.Fits         = true;
            retval.RequiredSize = bounds.GetSizeF();
            //DrawEditControl(g, bounds, true);
            return(retval);
        }
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.
        /// Simply returns the full size (up to MaxWidth and MaxHeight
        /// </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.</param>
        /// <returns>size is the full size of the bounds given,
        /// fits is always true, and continued is always false from this
        /// routine.  Note that DoPrint may change the values of all these.
        /// </returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SectionSizeValues retvals = new SectionSizeValues();

            // assume worst-case size...
            retvals.RequiredSize = bounds.GetSizeF();
            retvals.Fits         = true;

            return(retvals);
        }
Ejemplo n.º 14
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
            )
        {
            SectionSizeValues retval = new SectionSizeValues();

            this.imageRect      = GetImageRect(bounds);
            retval.RequiredSize = this.imageRect.Size;
            retval.Fits         = bounds.SizeFits(retval.RequiredSize);
            retval.Continued    = false;
            return(retval);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SetDefaultPen(reportDocument);
            SetLinePoints(bounds);

            SectionSizeValues retvals = new SectionSizeValues();

            retvals.Fits         = true;
            retvals.Continued    = false;
            retvals.RequiredSize = GetSizeF();
            return(retvals);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        /// <returns>SectionSizeValues of requiredSize, fits, and continues.</returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            // Default values
            SectionSizeValues retvals = new SectionSizeValues();

            Bounds insideBorder = this.borderPens.GetInnerBounds(bounds);

            CalcHeaderSize(g, insideBorder);
            Bounds tableBounds      = GetTableBounds(insideBorder);
            PointF originalPosition = tableBounds.Position;

            if (SizePrintHeader(g, ref tableBounds, true))
            {
                if (this.currentHorizPage == 0)
                {
                    this.dataRowsFit        = FindDataRowsFit(g, ref tableBounds);
                    this.tableHeightForPage = tableBounds.Position.Y - originalPosition.Y;
                }
                if (this.TotalRows == 0) // special case of 0 rows
                {
                    retvals.Fits = true;
                }
                else if (this.dataRowsFit > 0)
                {
                    retvals.Fits = true;
                    if (this.currentHorizPage < this.infoForPages.Count - 1)
                    {
                        retvals.Continued = true;
                    }
                    else if (this.rowIndex + this.dataRowsFit < this.TotalRows)
                    {
                        retvals.Continued = true;
                    }
                }
            }

            retvals.RequiredSize = this.borderPens.AddBorderSize(
                new SizeF(GetPageInfo().Width, tableHeightForPage));

            return(retvals);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Method called to Print this ReportSection.
        /// If CalcSize has not already been called, it will call it.
        /// </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.</param>
        public void Print(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds)
        {
            Bounds printingBounds = LimitBounds(bounds);

            if (this.sized && (printingBounds != this.sizingBounds))
            {
                SectionSizeValues vals = BoundsChanged(this.sizingBounds, printingBounds);
                SetSize(vals.RequiredSize, bounds);
                this.fits      = vals.Fits;
                this.continued = vals.Continued;
            }

            CalcSize(reportDocument, g, bounds);
            if (this.fits)
            {
                DoPrint(reportDocument, g, printingBounds);
            }
            ResetSize();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </summary>
        /// <param name="reportDocument">Pparent ReportDocument that is printing.</param>
        /// <param name="g">Graphics object to print on.</param>
        /// <param name="bounds">Bounds of the area to print within.</param>
        /// <returns>SectionSizeValues</returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SectionSizeValues retval = new SectionSizeValues();

            textFont   = this.TextStyle.GetFont();
            textLayout = bounds.GetRectangleF();
            if (CheckTextLayout(g))
            {
                // Get a new string starting from where-ever we left off on the last page
                textToPrint = GetText(reportDocument);
                retval      = SetTextSize(reportDocument, g, bounds);
            }
            else
            {
                retval.Fits = false;
            }
            return(retval);
        }
        /// <summary>
        /// Called to actually print this section.
        /// The DoCalcSize method will be called exactly once prior to each
        /// call of DoPrint.
        /// It should obey the value or Size and Continued as set by
        /// DoCalcSize().
        /// </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.</param>
        protected override void DoPrint(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SizeF mySize = new SizeF(0, 0);

            if (ShowDividerFirst && (Divider != null))
            {
                divider.Print(reportDocument, g, bounds);
                AdvancePointers(divider.Size, ref bounds, ref mySize);
            }

            // size first
            SectionSizeValues oneCall = SizePrintLine(reportDocument, g, bounds, true, false);
            bool fits = oneCall.Fits;

            while (oneCall.Fits)
            {
                Bounds printBounds = bounds.GetBounds(oneCall.RequiredSize);
                SizePrintLine(reportDocument, g, printBounds, false, true);  // print
                AdvancePointers(oneCall.RequiredSize, ref bounds, ref mySize);
                // if this section is not continued, quit now
                if (!oneCall.Continued)
                {
                    break;
                }
                if (Divider != null)
                {
                    divider.Print(reportDocument, g, bounds);
                    AdvancePointers(divider.Size, ref bounds, ref mySize);
                }
                oneCall = SizePrintLine(reportDocument, g, bounds, true, false);  // size
            }
            SetSize(mySize, bounds);
            SetFits(fits);
            SetContinued(oneCall.Continued);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Sets the TextLayout rectangle to the correct size
        /// Also sets size, itFits, and continued of the base class
        /// </summary>
        /// <param name="doc">The parent ReportDocument</param>
        /// <param name="g">Graphics object</param>
        /// <param name="bounds">Bounds to draw within</param>
        /// <returns>SectionSizeValues</returns>
        SectionSizeValues SetTextSize(ReportDocument doc, Graphics g, Bounds bounds)
        {
            SectionSizeValues retval = new SectionSizeValues();

            retval.Fits = true;

            // Find the height of the actual string + margins to be drawn
            SizeF requiredSize = g.MeasureString(textToPrint, textFont,
                                                 textLayout.Size, GetStringFormat(), out charsFitted, out linesFitted);

            if (charsFitted < textToPrint.Length)
            {
                // it doesn't all fit.
                if (this.KeepTogether)
                {
                    // try on the next page.
                    // HACK: This is bad if the whole section doesn't
                    // ever fit on a page, since it will end up in an infinite loop.
                    retval.Fits = false;
                    charsFitted = 0;
                    linesFitted = 0;
                    return(retval);
                }
                retval.Continued = true;
            }

            // Get a new rectangle aligned within the bounds and margins
            textLayout = bounds.GetRectangleF(requiredSize,
                                              this.HorizontalAlignment, this.VerticalAlignment);
            retval.RequiredSize = textLayout.Size;

            if (debugEnabled)
            {
                Console.WriteLine("Layout for string '" + textToPrint + "' is " + textLayout);
            }

            return(retval);
        }
Ejemplo n.º 21
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
            )
        {
            SectionSizeValues retval = new SectionSizeValues();

            retval.Fits = true;
            int page = reportDocument.GetCurrentPage();

            if (this.firstTimeCalled)
            {
                this.pageNumber      = page;
                retval.Continued     = this.pageBreak;
                retval.RequiredSize  = bounds.GetSizeF();
                this.firstTimeCalled = false;
                if (this.setOrientation)
                {
                    reportDocument.SetPageOrientation(page + 1, this.newPageOrientation);
                }
            }
            else
            {
                if (this.pageBreak && (page == this.pageNumber))
                {
                    retval.Continued    = true;
                    retval.RequiredSize = bounds.GetSizeF();
                }
                else
                {
                    retval.Continued    = false;
                    retval.RequiredSize = new SizeF(0, 0);
                }
            }
            return(retval);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        /// <returns>SectionSizeValues of requiredSize, fits, and continues.</returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            // Default values
            SectionSizeValues retvals = new SectionSizeValues();

            Bounds insideBorder = this.borderPens.GetInnerBounds (bounds);
            CalcHeaderSize (g, insideBorder);
            Bounds tableBounds = GetTableBounds (insideBorder);
            PointF originalPosition = tableBounds.Position;

            if (SizePrintHeader (g, ref tableBounds, true))
            {
                if (this.currentHorizPage == 0)
                {
                    this.dataRowsFit = FindDataRowsFit (g, ref tableBounds);
                    this.tableHeightForPage = tableBounds.Position.Y - originalPosition.Y;
                }
                if (this.TotalRows == 0) // special case of 0 rows
                {
                    retvals.Fits = true;
                }
                else if (this.dataRowsFit > 0)
                {
                    retvals.Fits = true;
                    if (this.currentHorizPage < this.infoForPages.Count - 1)
                    {
                        retvals.Continued = true;
                    }
                    else if (this.rowIndex + this.dataRowsFit < this.TotalRows)
                    {
                        retvals.Continued = true;
                    }
                }
            }

            retvals.RequiredSize = this.borderPens.AddBorderSize (
                new SizeF (GetPageInfo().Width, tableHeightForPage));

            return retvals;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        /// <returns>SectionSizeValues of requiredSize, fits, and continues.</returns>
        protected override SectionSizeValues DoCalcSize(
			ReportDocument reportDocument,
			Graphics g,
			Bounds bounds
			)
        {
            // Default values
            SectionSizeValues retvals = new SectionSizeValues();

            DataSource.RowFilter = RowFilter;

            Bounds tableBounds = new Bounds(0, 0, 0, 0);
            if (TableHeader == null || rowIndex > 0)
                tableBounds = bounds;
            else
            {
                TableHeader.CalcSize(reportDocument, g, bounds);
                if ( TableHeader.Fits )
                    tableBounds = new Bounds(
                        bounds.Position.X, bounds.Position.Y + TableHeader.RequiredSize.Height,
                        bounds.Limit.X, bounds.Limit.Y);
            }
            if ( !tableBounds.IsEmpty() )
            {
                retvals = base.DoCalcSize(reportDocument, g, tableBounds);
                if ( retvals.Fits )
                {
                    if (TableHeader != null && rowIndex <= 0)
                        retvals.RequiredSize = new SizeF(retvals.RequiredSize.Width,
                            retvals.RequiredSize.Height + TableHeader.RequiredSize.Height);
                    if ( !retvals.Continued && TableFooter != null)
                    {
                        Bounds footerBounds = new Bounds(
                            tableBounds.Position.X, tableBounds.Position.Y + RequiredSize.Height,
                            tableBounds.Limit.X, tableBounds.Limit.Y);
                        TableFooter.CalcSize(reportDocument, g, footerBounds);
                        if ( TableFooter.Fits )
                            retvals.RequiredSize = new SizeF(retvals.RequiredSize.Width,
                                retvals.RequiredSize.Height + TableFooter.RequiredSize.Height);
                        else
                        {
                            if (this.dataRowsFit >= (2 * this.MinDataRowsFit))
                            {
                                this.dataRowsFit -= this.MinDataRowsFit;
                                retvals.Continued = true;
                                // should adjust RequiredSize.
                            }
                            else
                            {
                                retvals.Fits = false;
                            }
                        }
                    }
                }
            }
            return retvals;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Re-computes the line based on changed bounds
        /// </summary>
        /// <param name="originalBounds">Original bounds used for size</param>
        /// <param name="newBounds">New bounds</param>
        /// <returns>SectionSizeValues struct</returns>
        protected override SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            SetLinePoints (newBounds);

            SectionSizeValues retvals = new SectionSizeValues();
            retvals.Fits = true;
            retvals.Continued = false;
            retvals.RequiredSize = GetSizeF();
            return retvals;
        }
Ejemplo n.º 25
0
        SectionSizeValues DrawEditControl(Graphics g, Bounds bounds, bool sizeOnly)
        {
            SectionSizeValues retval = new SectionSizeValues();

            retval.RequiredSize = new SizeF(0, 0);

            // draw the control by selecting the first character
            // of each word, and getting its font / color
            float xPos = bounds.Position.X;
            float yPos = bounds.Position.Y;
            int   c;
            int   length = richTextBox1.Text.Length;

            for (c = this.lastCharIndex; c < length; c++)
            {
                richTextBox1.Select(c, 1);
                char nextChar = richTextBox1.Text[c];
                Debug.WriteIf(showchars, nextChar);
                Color theColor = richTextBox1.SelectionColor;
                Font  theFont  = richTextBox1.SelectionFont;
                if (theFont == null)
                {
                    Debug.WriteLine("Null font, using a default");
                    theFont = new Font(FontFamily.GenericSansSerif, 12);
                }
                float fontHeight = theFont.GetHeight(g);

                if (nextChar == '\n')
                {
                    retval.RequiredSize.Width = Math.Max(retval.RequiredSize.Width, xPos - bounds.Position.X);
                    xPos  = bounds.Position.X;
                    yPos += (fontHeight * verticalSpacing);
                    if (yPos > bounds.Limit.Y)
                    {
                        break;
                    }
                }
                else if (nextChar == ' ')
                {
                    xPos += fontHeight / 2;
                }
                else if (nextChar == '\t')
                {
                    xPos += fontHeight * 2;
                }
                else
                {
                    // match the words for same font / color
                    Match m;

                    StringBuilder nextWord    = new StringBuilder(30);
                    bool          reduceAtEnd = false;
                    m = wordSeparator.Match(nextChar.ToString());
                    if (m.Success)
                    {
                        reduceAtEnd = true;
                    }
                    else
                    {
                        nextWord.Append(nextChar);
                    }


                    while (m.Success)
                    {
                        nextWord.Append(nextChar);
                        c++;
                        if (c >= length)
                        {
                            break;
                        }
                        nextChar = richTextBox1.Text[c];
                        Debug.WriteIf(showchars, nextChar);
                        m = wordSeparator.Match(nextChar.ToString());
                    }
                    if (reduceAtEnd)
                    {
                        c--;
                    }
                    string word = nextWord.ToString();


                    PointF drawPoint = new PointF(xPos, yPos);
                    SizeF  drawSize  = g.MeasureString(word,
                                                       theFont, drawPoint, stringFormat);
                    xPos += drawSize.Width;
                    if (xPos > bounds.Limit.X)
                    {
                        yPos += (fontHeight * verticalSpacing);
                        if (yPos > bounds.Limit.Y)
                        {
                            // need to undo changes to c
                            break;
                        }
                        retval.RequiredSize.Width = Math.Max(retval.RequiredSize.Width, xPos - bounds.Position.X);
                        xPos        = bounds.Position.X + drawSize.Width;
                        drawPoint.X = bounds.Position.X;
                        drawPoint.Y = yPos;
                    }

                    if (!sizeOnly)
                    {
                        g.DrawString(word, theFont,
                                     new SolidBrush(theColor), drawPoint, stringFormat);
                    }
                }
            }

            retval.Fits      = c > this.lastCharIndex;
            retval.Continued = c < richTextBox1.Text.Length;
            if (!sizeOnly)
            {
                this.lastCharIndex = c;
            }
            return(retval);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.  This method will be called exactly once
        /// prior to each call to Print.  It must update the values Size and
        /// Continued of the ReportSection base class.
        /// </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.</param>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SetDefaultPen (reportDocument);
            SetLinePoints (bounds);

            SectionSizeValues retvals = new SectionSizeValues();
            retvals.Fits = true;
            retvals.Continued = false;
            retvals.RequiredSize = GetSizeF();
            return retvals;
        }
Ejemplo n.º 27
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
            )
        {
            SectionSizeValues retval = new SectionSizeValues();
            retval.Fits = true;
            int page = reportDocument.GetCurrentPage();

            if (this.firstTimeCalled)
            {
                this.pageNumber = page;
                retval.Continued = this.pageBreak;
                retval.RequiredSize = bounds.GetSizeF();
                this.firstTimeCalled = false;
                if (this.setOrientation)
                {
                    reportDocument.SetPageOrientation (page + 1, this.newPageOrientation);
                }
            }
            else
            {
                if (this.pageBreak && (page == this.pageNumber))
                {
                    retval.Continued = true;
                    retval.RequiredSize = bounds.GetSizeF();
                }
                else
                {
                    retval.Continued = false;
                    retval.RequiredSize = new SizeF (0, 0);
                }
            }
            return retval;
        }
Ejemplo n.º 28
0
 /// <summary>
 /// This method is called after a size and before a print if
 /// the bounds have changed between the sizing and the printing.
 /// Override this function to update anything based on the new location
 /// </summary>
 /// <param name="originalBounds">Bounds originally passed for sizing</param>
 /// <param name="newBounds">New bounds for printing</param>
 /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
 /// <remarks>To simply have size recalled, implement the following:
 /// <code>
 ///    this.ResetSize();
 ///    return base.ChangeBounds (originalBounds, newBounds);
 /// </code>
 /// </remarks>
 protected override SectionSizeValues BoundsChanged(
     Bounds originalBounds,
     Bounds newBounds)
 {
     SectionSizeValues retval = new SectionSizeValues();
     this.imageRect = GetImageRect(newBounds);
     retval.RequiredSize = this.imageRect.Size;
     retval.Fits = newBounds.SizeFits(retval.RequiredSize);
     retval.Continued = false;
     return retval;
 }
Ejemplo n.º 29
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
     )
 {
     SectionSizeValues retval = new SectionSizeValues();
     this.imageRect = GetImageRect(bounds);
     retval.RequiredSize = this.imageRect.Size;
     retval.Fits = bounds.SizeFits(retval.RequiredSize);
     retval.Continued = false;
     return retval;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Called to calculate the size that this section requires on
 /// the next call to Print.  This method will be called exactly once
 /// prior to each call to Print.  It must update the values Size and
 /// Continued of the ReportSection base class.
 /// </summary>
 /// <param name="reportDocument">Pparent ReportDocument that is printing.</param>
 /// <param name="g">Graphics object to print on.</param>
 /// <param name="bounds">Bounds of the area to print within.</param>
 /// <returns>SectionSizeValues</returns>
 protected override SectionSizeValues DoCalcSize(
     ReportDocument reportDocument,
     Graphics g,
     Bounds bounds
     )
 {
     SectionSizeValues retval = new SectionSizeValues();
     textFont = this.TextStyle.GetFont();
     textLayout = bounds.GetRectangleF();
     if (CheckTextLayout(g))
     {
         // Get a new string starting from where-ever we left off on the last page
         textToPrint = GetText(reportDocument);
         retval = SetTextSize (reportDocument, g, bounds);
     }
     else
     {
         retval.Fits = false;
     }
     return retval;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// This method is called after a size and before a print if
 /// the bounds have changed between the sizing and the printing.
 /// Override this function to update anything based on the new location
 /// </summary>
 /// <param name="originalBounds">Bounds originally passed for sizing</param>
 /// <param name="newBounds">New bounds for printing</param>
 /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
 /// <remarks>To simply have size recalled, implement the following:
 /// <code>
 ///    this.ResetSize();
 ///    return base.ChangeBounds (originalBounds, newBounds);
 /// </code>
 /// </remarks>
 protected override SectionSizeValues BoundsChanged(
     Bounds originalBounds,
     Bounds newBounds)
 {
     // don't really do anything... (this is the base implementation)
     SectionSizeValues retval = new SectionSizeValues();
     retval.Fits = this.Fits;
     retval.Continued = this.Continued;
     retval.RequiredSize = this.RequiredSize;
     return retval;
 }
        /// <summary>
        /// Called to calculate the size that this section requires on
        /// the next call to Print.
        /// Simply returns the full size (up to MaxWidth and MaxHeight
        /// </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.</param>
        /// <returns>size is the full size of the bounds given,
        /// fits is always true, and continued is always false from this
        /// routine.  Note that DoPrint may change the values of all these.
        /// </returns>
        protected override SectionSizeValues DoCalcSize(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds
            )
        {
            SectionSizeValues retvals = new SectionSizeValues();

            // assume worst-case size...
            retvals.RequiredSize = bounds.GetSizeF();
            retvals.Fits = true;

            return retvals;
        }
Ejemplo n.º 33
0
        SectionSizeValues DrawEditControl(Graphics g, Bounds bounds, bool sizeOnly)
        {
            SectionSizeValues retval = new SectionSizeValues();
            retval.RequiredSize = new SizeF (0,0);

            // draw the control by selecting the first character
            // of each word, and getting its font / color
            float xPos = bounds.Position.X;
            float yPos = bounds.Position.Y;
            int c;
            int length = richTextBox1.Text.Length;
            for (c = this.lastCharIndex; c < length; c++)
            {
                richTextBox1.Select (c,1);
                char nextChar = richTextBox1.Text[c];
                Debug.WriteIf (showchars, nextChar);
                Color theColor = richTextBox1.SelectionColor;
                Font theFont = richTextBox1.SelectionFont;
                if (theFont == null)
                {
                    Debug.WriteLine ("Null font, using a default");
                    theFont = new Font (FontFamily.GenericSansSerif, 12);

                }
                float fontHeight = theFont.GetHeight(g);

                if (nextChar == '\n')
                {
                    retval.RequiredSize.Width = Math.Max (retval.RequiredSize.Width, xPos - bounds.Position.X);
                    xPos = bounds.Position.X;
                    yPos += (fontHeight * verticalSpacing);
                    if (yPos > bounds.Limit.Y)
                    {
                        break;
                    }
                }
                else if (nextChar == ' ')
                {
                   xPos += fontHeight / 2;
                }
                else if (nextChar == '\t')
                {
                    xPos += fontHeight * 2;
                }
                else
                {
                    // match the words for same font / color
                    Match m;

                    StringBuilder nextWord = new StringBuilder (30);
                    bool reduceAtEnd = false;
                    m = wordSeparator.Match(nextChar.ToString());
                    if (m.Success)
                    {
                        reduceAtEnd = true;
                    }
                    else
                    {
                        nextWord.Append (nextChar);
                    }

                    while (m.Success)
                    {
                        nextWord.Append (nextChar);
                        c++;
                        if (c >= length) break;
                        nextChar = richTextBox1.Text[c];
                        Debug.WriteIf (showchars, nextChar);
                        m = wordSeparator.Match (nextChar.ToString());
                    }
                    if (reduceAtEnd)
                    {
                        c--;
                    }
                    string word = nextWord.ToString();

                    PointF drawPoint = new PointF (xPos, yPos);
                    SizeF drawSize = g.MeasureString(word,
                        theFont, drawPoint, stringFormat);
                    xPos += drawSize.Width;
                    if (xPos > bounds.Limit.X)
                    {
                        yPos += (fontHeight * verticalSpacing);
                        if (yPos > bounds.Limit.Y)
                        {
                            // need to undo changes to c
                            break;
                        }
                        retval.RequiredSize.Width = Math.Max (retval.RequiredSize.Width, xPos - bounds.Position.X);
                        xPos = bounds.Position.X + drawSize.Width;
                        drawPoint.X = bounds.Position.X;
                        drawPoint.Y = yPos;
                    }

                    if (!sizeOnly)
                    {
                        g.DrawString(word, theFont,
                            new SolidBrush(theColor), drawPoint, stringFormat);
                    }
                }
            }

            retval.Fits = c > this.lastCharIndex;
            retval.Continued = c < richTextBox1.Text.Length;
            if (!sizeOnly) this.lastCharIndex = c;
            return retval;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Sets the TextLayout rectangle to the correct size
        /// Also sets size, itFits, and continued of the base class
        /// </summary>
        /// <param name="doc">The parent ReportDocument</param>
        /// <param name="g">Graphics object</param>
        /// <param name="bounds">Bounds to draw within</param>
        /// <returns>SectionSizeValues</returns>
        SectionSizeValues SetTextSize(ReportDocument doc, Graphics g, Bounds bounds)
        {
            SectionSizeValues retval = new SectionSizeValues();
            retval.Fits = true;

            // Find the height of the actual string + margins to be drawn
            SizeF requiredSize = g.MeasureString(textToPrint, textFont,
                textLayout.Size, GetStringFormat(), out charsFitted, out linesFitted);

            if (charsFitted < textToPrint.Length)
            {
                // it doesn't all fit.
                if (this.KeepTogether)
                {
                    // try on the next page.
                    // HACK: This is bad if the whole section doesn't
                    // ever fit on a page, since it will end up in an infinite loop.
                    retval.Fits = false;
                    charsFitted = 0;
                    linesFitted = 0;
                    return retval;
                }
                retval.Continued = true;
            }

            if (this.HorizontalAlignment != HorizontalAlignment.Left)
                requiredSize.Width = textLayout.Size.Width;

            // Get a new rectangle aligned within the bounds and margins
            textLayout = bounds.GetRectangleF(requiredSize,
                this.HorizontalAlignment, this.VerticalAlignment);
            retval.RequiredSize = textLayout.Size;

            if (debugEnabled)
            {
                Console.WriteLine ("Layout for string '" + textToPrint + "' is " + textLayout);
            }

            return retval;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Sizes all the sections that fit within a single row/column
        /// </summary>
        /// <param name="reportDocument">Parent ReportDocument</param>
        /// <param name="g">Graphics object for sizing / printing</param>
        /// <param name="bounds">The bounds the line must fit within</param>
        /// <param name="sizeOnly">Indicates that no printing should be done,
        /// just size the line</param>
        /// <param name="advanceSectionIndex">Advance the section index, 
        /// so that it's ready for the next line</param>
        /// <returns>Size and flags for if it fits and if it's continued</returns>
        protected SectionSizeValues SizePrintLine(
            ReportDocument reportDocument,
            Graphics g,
            Bounds bounds,
            bool sizeOnly,
            bool advanceSectionIndex
            )
        {
            SectionSizeValues retvals = new SectionSizeValues();
            retvals.Fits = false;

            int savedSectionIndex = this.sectionIndex;
            //            Debug.WriteLine("\nEntering " + Direction + " section, sizeonly = " + sizeOnly);
            //            Debug.WriteLine("   Bounds: " + bounds);

            // The following loop sizes all sections that fit on one line
            // If it runs out of room within the current bounds, it returns
            // and will continue where it left off on the next call.
            while (this.sectionIndex < this.SectionCount)
            {
                CurrentSection.CalcSize (reportDocument, g, bounds);
                if (CurrentSection.Fits)
                {
                    retvals.Fits = true;
                    if (!sizeOnly) CurrentSection.Print (reportDocument, g, bounds);
                    AdvancePointers(CurrentSection.Size, ref bounds, ref retvals.RequiredSize);
                    if (CurrentSection.Continued)
                    {
                        break;
                    }
                    else
                    {
                        this.sectionIndex++;
                    }
                }
                else // it doesn't fit
                {
                    // reset size since we didn't print but need the size to be
                    // refigured next time
                    CurrentSection.ResetSize();
                    break;
                }
            } // while

            //            Debug.WriteLine("Leaving " + Direction + " section");
            //            Debug.WriteLine("   Size: " + RequiredSize);

            retvals.Continued = this.sectionIndex < this.SectionCount;
            if (this.sectionIndex == savedSectionIndex && !retvals.Continued) retvals.Fits = true;
            if (!advanceSectionIndex) this.sectionIndex = savedSectionIndex;
            return retvals;
        }
Ejemplo n.º 36
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
            )
        {
            // Take offset into account...
            bounds.Position.X += OffsetLeft;
            bounds.Position.Y += OffsetTop;

            SectionSizeValues retval = new SectionSizeValues();
            // need to determine what to do with these values...
            retval.Fits = true;
            retval.Continued = false;

            SizeF contentSize = new SizeF (0,0);
            if (CurrentSection != null)
            {
                CurrentSection.CalcSize (reportDocument, g, GetMaxContentBounds(bounds));
                contentSize = CurrentSection.Size; // or could use RequiredSize?
            }

            this.borderBounds  = GetBorderBounds (bounds, contentSize);
            this.paddingBounds = border.GetInnerBounds (this.borderBounds);
            this.contentBounds = paddingBounds.GetBounds (PaddingTop, PaddingRight,
                PaddingBottom, PaddingLeft);

            retval.RequiredSize = this.borderBounds.GetSizeF();
            return retval;
        }
Ejemplo n.º 37
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;
        }
Ejemplo n.º 38
0
 /// <summary>
 /// This method is called after a size and before a print if
 /// the bounds have changed between the sizing and the printing.
 /// Override this function to update anything based on the new location
 /// </summary>
 /// <param name="originalBounds">Bounds originally passed for sizing</param>
 /// <param name="newBounds">New bounds for printing</param>
 /// <returns>SectionSizeValues for the new values of size, fits, continued</returns>
 /// <remarks>To simply have size recalled, implement the following:
 /// <code>
 ///    this.ResetSize();
 ///    return base.BoundsChanged (originalBounds, newBounds);
 /// </code>
 /// </remarks>
 protected virtual SectionSizeValues BoundsChanged(
     Bounds originalBounds,
     Bounds newBounds)
 {
     SectionSizeValues retval = new SectionSizeValues();
     retval.Fits = this.Fits;
     retval.Continued = this.Continued;
     retval.RequiredSize = this.RequiredSize;
     return retval;
 }
Ejemplo n.º 39
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
     )
 {
     SectionSizeValues retval = new SectionSizeValues();
     retval.Fits = true;
     retval.RequiredSize = bounds.GetSizeF();
     //DrawEditControl(g, bounds, true);
     return retval;
 }