Esempio n. 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
            )
        {
            // 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);
        }
Esempio n. 2
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