Пример #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;
 }
Пример #2
0
        /// <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
			)
        {
            base.DoPrint(reportDocument, g, bounds);
            this.sectionIndex = 0;
            Reset();
        }
Пример #3
0
        /// <summary>
        /// Paints or measures the object passed in according 
        /// to the formatting rules of this column.
        /// </summary>
        /// <param name="g">the graphics to paint the value onto</param>
        /// <param name="headerRow">True if this is a header row</param>
        /// <param name="alternatingRow">True if this row is an "alternating" row (even row most likely)</param>
        /// <param name="summaryRow">True if this row is a summary row</param>
        /// <param name="drv">DataRowView to grab the cell from</param>
        /// <param name="x">the x coordinate to start the paint</param>
        /// <param name="y">the y coordinate to start the paint</param>
        /// <param name="width">the width of the cell</param>
        /// <param name="height">The max height of this cell (when in sizeOnly mode)</param>
        /// <param name="sizeOnly">only calculate the sizes</param>
        /// <returns>A sizeF representing the measured size of the string + margins</returns>
        public override SizeF SizePaintCell( 
			Graphics g, bool headerRow, bool alternatingRow, bool summaryRow,
			DataRowView drv, float x, float y, float width,
			float height, bool sizeOnly)
        {
            if (headerRow || summaryRow)
            {
                return base.SizePaintCell (g, headerRow, alternatingRow, summaryRow, drv, x, y, width, height, sizeOnly);
            }

            // else it's a data row...
            // TODO: Update cell count and sum???
            SizeF cellSize = new SizeF(width, height);
            Image image = GetImage (drv);
            TextStyle textStyle = GetTextStyle (headerRow, alternatingRow, summaryRow);

            float sideMargins = textStyle.MarginNear + textStyle.MarginFar + RightPenWidth;
            float topBottomMargins = textStyle.MarginTop + textStyle.MarginBottom;
            Bounds bounds = new Bounds (x, y, x + width, y + height);
            Bounds innerBounds = bounds.GetBounds (textStyle.MarginTop,
                textStyle.MarginFar + RightPenWidth, textStyle.MarginBottom, textStyle.MarginNear);
            SizeF maxSize = innerBounds.GetSizeF();

            if (sizeOnly)
            {
                if (image == null)
                {
                    cellSize.Width = 0;
                    cellSize.Height = 0;
                }
                else
                {
                    cellSize.Width = ImageWidth;
                    cellSize.Height = ImageHeight;
                }
            }
            else
            {
                // draw background
                if (textStyle.BackgroundBrush != null)
                {
                    g.FillRectangle (textStyle.BackgroundBrush, bounds.GetRectangleF());
                }
                // draw image
                if (image != null)
                {
                    RectangleF cellLayout = GetImageRect (innerBounds, image, textStyle);
                    g.DrawImage (image, cellLayout);
                }
            }
            return cellSize;
        }
Пример #4
0
 /// <summary>
 /// Sets the size variable based on the requiredSize provided.
 /// The requiredSize should not include margins since
 /// those are added by SetSize().  
 /// It also takes into account FullWidth and FullHeight and
 /// uses the values from bounds if required.
 /// </summary>
 /// <param name="requiredSize">The size required for the section</param>
 /// <param name="bounds">The full bounds allowed</param>
 protected virtual void SetSize(SizeF requiredSize, Bounds bounds)
 {
     this.requiredSize = requiredSize;
     this.size = new SizeF (0,0); // just to get rid of a compiler warning
     if (this.UseFullWidth)
     {
         this.size.Width = bounds.Width;
     }
     else
     {
         this.size.Width = requiredSize.Width + this.MarginLeft + this.MarginRight;
     }
     if (this.UseFullHeight)
     {
         this.size.Height = bounds.Height;
     }
     else
     {
         this.size.Height = requiredSize.Height + this.MarginTop + this.MarginBottom;
     }
     if (this.MaxWidth > 0)
     {
         this.size.Width  = Math.Min (this.size.Width,  this.MaxWidth);
     }
     if (this.MaxHeight > 0)
     {
         this.size.Height = Math.Min (this.size.Height, this.MaxHeight);
     }
 }
Пример #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 abstract SectionSizeValues DoCalcSize(
     ReportDocument reportDocument,
     Graphics g,
     Bounds bounds
     );
Пример #6
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 ();
        }
Пример #7
0
 /// <summary>
 /// Gets an inner bounds based on the widths of each pen
 /// </summary>
 /// <param name="bounds">Bounds inside the border</param>
 /// <returns>Bounds that takes the border into accound</returns>
 public Bounds GetInnerBounds(Bounds bounds)
 {
     if (Top != null)
     {
         bounds.Position.Y += Top.Width;
     }
     if (Right != null)
     {
         bounds.Limit.X -= Right.Width;
     }
     if (Bottom != null)
     {
         bounds.Limit.Y -= Bottom.Width;
     }
     if (Left != null)
     {
         bounds.Position.X += Left.Width;
     }
     return bounds;
 }
        /// <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
                // or if this was the last column/row on this page, quit now
                if (!oneCall.Continued || bounds.IsEmpty())
                {
                    break;
                }
                oneCall = SizePrintLine (reportDocument, g, bounds, true, false); // size
                if ( oneCall.Fits && Divider != null)
                {
                    divider.Print (reportDocument, g, bounds);
                    AdvancePointers (divider.Size, ref bounds, ref mySize);
                }
            }
            SetSize (mySize, bounds);
            SetFits (fits);
            SetContinued (oneCall.Continued);
        }
Пример #9
0
        /// <summary>
        /// If width / height is not specified, then it subtracts
        /// the border and padding bounds to create the returned bounds.
        /// If width / height is specified, then result is based
        /// on that width / height minux margins, border and padding.
        /// </summary>
        /// <param name="bounds">The bounds inside margins</param>
        /// <returns>The bounds outside the content area</returns>
        Bounds GetMaxContentBounds(Bounds bounds)
        {
            bounds.Position.X += border.LeftWidth + PaddingLeft;
            bounds.Position.Y += border.TopWidth + PaddingTop;
            if (Width > 0)
            {
                float contentWidth = Width
                    - MarginLeft - MarginRight
                    - border.LeftWidth - border.RightWidth
                    - PaddingLeft - PaddingRight;
                bounds.Limit.X = bounds.Position.X + contentWidth;
            }
            else if (WidthPercent > 0)
            {
                float contentWidth = (bounds.Width * WidthPercent / 100)
                    - MarginLeft - MarginRight
                    - border.LeftWidth - border.RightWidth
                    - PaddingLeft - PaddingRight;
                bounds.Limit.X = bounds.Position.X + contentWidth;
            }
            else
            {
                bounds.Limit.X -= border.RightWidth + PaddingRight;
            }

            if (Height > 0)
            {
                float contentHeight = Height
                    - MarginTop - MarginBottom
                    - border.TopWidth - border.BottomWidth
                    - PaddingTop - PaddingBottom;
                bounds.Limit.Y = bounds.Position.Y + contentHeight;
            }
            else if (HeightPercent > 0)
            {
                float contentHeight = (bounds.Height * HeightPercent / 100)
                    - MarginTop - MarginBottom
                    - border.TopWidth - border.BottomWidth
                    - PaddingTop - PaddingBottom;
                bounds.Limit.Y = bounds.Position.Y + contentHeight;
            }
            else
            {
                bounds.Limit.Y -= border.BottomWidth + PaddingBottom;
            }
            return bounds;
        }
Пример #10
0
        /// <summary>
        /// The 
        /// </summary>
        /// <param name="pageRectangle"></param>
        /// <param name="desiredMargins"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public Bounds GetBounds(Rectangle pageRectangle, Rectangle desiredMargins,
            float scale)
        {
            // take the hard margins into account by using them simply
            // as an offset that the print would apply...
            float leftMargin = desiredMargins.Left - hardLeftMargin;
            float topMargin = desiredMargins.Top - hardTopMargin;
            float rightMargin = desiredMargins.Right - hardLeftMargin;
            float bottomMargin = desiredMargins.Bottom - hardTopMargin;

            leftMargin *= scale;
            topMargin *= scale;
            rightMargin *= scale;
            bottomMargin *= scale;

            Bounds pageBounds = new Bounds(leftMargin, topMargin, rightMargin, bottomMargin);
            return pageBounds;
        }
Пример #11
0
        /// <summary>
        /// Paints or measures the object passed in according 
        /// to the formatting rules of this column.
        /// </summary>
        /// <param name="g">the graphics to paint the value onto</param>
        /// <param name="text">the text to paint</param>
        /// <param name="textStyle">the textStyle to use to paint the text</param>
        /// <param name="x">the x coordinate to start the paint</param>
        /// <param name="y">the y coordinate to start the paint</param>
        /// <param name="width">the width of the cell</param>
        /// <param name="height">The max height of this cell (when in sizeOnly mode)</param>
        /// <param name="sizeOnly">only calculate the sizes</param>
        /// <returns>A sizeF representing the measured size of the string + margins</returns>
        public virtual SizeF SizePaintCell( 
			Graphics g, string text, TextStyle textStyle,
			float x, float y, float width,
			float height, bool sizeOnly)
        {
            SizeF stringSize = new SizeF(width, height);
            Font font = textStyle.GetFont();
            StringFormat stringFormat = textStyle.GetStringFormat();

            float sideMargins = textStyle.MarginNear + textStyle.MarginFar + RightPenWidth;
            float topBottomMargins = textStyle.MarginTop + textStyle.MarginBottom;
            Bounds bounds = new Bounds (x, y, x + width, y + height);
            Bounds innerBounds = bounds.GetBounds (textStyle.MarginTop,
                textStyle.MarginFar + RightPenWidth, textStyle.MarginBottom, textStyle.MarginNear);
            SizeF maxSize = innerBounds.GetSizeF();

            if (sizeOnly)
            {
                // Find the height of the actual string to be drawn
                stringSize = g.MeasureString(text, font, maxSize, stringFormat);
                stringSize.Width += sideMargins;
                stringSize.Height += topBottomMargins;
                // Don't go bigger than maxHeight
                stringSize.Height = Math.Min (stringSize.Height, height);
            }
            else
            {
                // draw background & text
                if (textStyle.BackgroundBrush != null)
                {
                    g.FillRectangle (textStyle.BackgroundBrush, bounds.GetRectangleF());
                }
                RectangleF textLayout = innerBounds.GetRectangleF (stringSize,
                    SectionText.ConvertAlign (textStyle.StringAlignment),
                    textStyle.VerticalAlignment);
                g.DrawString(text, font, textStyle.Brush, textLayout, stringFormat);
            }
            return stringSize;
        }
Пример #12
0
 /// <summary>
 /// Sizes or prints the header, if it is enabled
 /// </summary>
 /// <param name="g"></param>
 /// <param name="bounds"></param>
 /// <param name="sizeOnly"></param>
 /// <returns>True if it fits, false if it doesn't</returns>
 bool SizePrintHeader(Graphics g, ref Bounds bounds, bool sizeOnly)
 {
     bool headerFits = true;
     if (!this.SuppressHeaderRow && this.RepeatHeaderRow)
     {
         // if it fits, print it
         if (bounds.SizeFits(this.HeaderSize))
         {
             if (!sizeOnly)
             {
                 SizePrintRow (g, HeaderRowNumber, bounds.Position.X, bounds.Position.Y,
                     this.GetPageInfo().Width, this.headerRowHeight, false, false);
             }
             bounds.Position.Y += this.headerRowHeight;
         }
         else
         {
             headerFits = false;
         }
     }
     return headerFits;
 }
Пример #13
0
        /// <summary>
        /// Prints rows of a table based on current rowIndex and dataRowsFit variables
        /// Also, bounds is incremented as each row is printed.
        /// </summary>
        /// <param name="g">Graphics object used for printing</param>
        /// <param name="bounds">Bounds allowed for table</param>
        /// <returns>True if at least one row fits</returns>
        void PrintRows(Graphics g, ref Bounds bounds)
        {
            // print all the rows that we already decided fit on the page...
            for (int rowCount = 0; rowCount < this.dataRowsFit; rowCount++, this.rowIndex++ )
            {
                float height = (float) rowHeights[rowCount];
                bool showLine = false; //rowCount != this.dataRowsFit - 1;
                SizePrintRow (g, this.rowIndex, bounds.Position.X,
                    bounds.Position.Y, bounds.Width, height, false, showLine);
                bounds.Position.Y += height;

                Debug.Assert (bounds.Position.Y - bounds.Limit.Y < 0.005f, // TODO: Bad magic number
                    "Row doesn't really fit, but we thought it did. Delta: " + (bounds.Position.Y - bounds.Limit.Y));
            }
        }
Пример #14
0
        void PrintAllRowLines(Graphics g, Bounds bounds, bool includeHeader)
        {
            float x = bounds.Position.X;
            float y = bounds.Position.Y;
            float rowWidth = bounds.Width;
            if (includeHeader)
            {
                RowLine (g, x, y + this.headerRowHeight, rowWidth, true, false);
                y += this.headerRowHeight;
            }

            for (int rowCount = 0; rowCount < this.dataRowsFit - 1; rowCount++ )
            {
                float height = (float) rowHeights[rowCount];
                bool showLine = rowCount != this.dataRowsFit - 1;
                RowLine (g, x, y + height, rowWidth, false, false);
                y += height;
            }
        }
Пример #15
0
        void PrintAllColumnLines(Graphics g, Bounds bounds)
        {
            PageInfo info = GetPageInfo();
            float x = bounds.Position.X;
            float y = bounds.Position.Y;

            for (int colNumber = info.FirstColumn; colNumber <= info.LastColumn - 1; colNumber++)
            {
                IDataColumn col = GetColumn(colNumber);
                x += col.Width;
                col.DrawRightLine (g, x, y, bounds.Height);
            }
        }
Пример #16
0
 /// <summary>
 /// Called to actually print this section.  
 /// </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
     )
 {
     if ( !reportDocument.NoPrint )
         border.DrawBorder (g, this.borderBounds);
     if (Background != null)
     {
         if ( !reportDocument.NoPrint )
             g.FillRectangle (Background, this.paddingBounds.GetRectangleF());
     }
     if (CurrentSection != null)
     {
         CurrentSection.Print (reportDocument, g, this.contentBounds);
     }
 }
Пример #17
0
        /// <summary>
        /// Gets the BorderBounds based on the bounds inside
        /// the margins,
        /// using Width and Height, UseFullWidth and UseFullHeight, 
        /// and optinally the contentSize (if non-zero)
        /// </summary>
        Bounds GetBorderBounds(Bounds bounds, SizeF contentSize)
        {
            SizeF borderSize = bounds.GetSizeF();
            if (SizeToContentsWidth)
            {
                borderSize.Width = contentSize.Width + PaddingLeft + PaddingRight
                    + this.border.LeftWidth + this.border.RightWidth;
            }
            else
            {
                float widthToUse = Width;
                if (WidthPercent > 0)
                {
                    widthToUse = bounds.Width * (WidthPercent / 100);
                }
                borderSize.Width = widthToUse - MarginLeft - MarginRight;
            }

            if (SizeToContentsHeight)
            {
                borderSize.Height = contentSize.Height + PaddingTop + PaddingBottom
                    + this.border.LeftWidth + this.border.RightWidth;
            }
            else
            {
                float heightToUse = Height;
                if (HeightPercent > 0)
                {
                    heightToUse = bounds.Height * (HeightPercent / 100);
                }
                borderSize.Height = heightToUse - MarginTop - MarginBottom;
            }

            Bounds borderBounds =  bounds.GetBounds (borderSize,
                this.HorizontalAlignment, this.VerticalAlignment);

            return borderBounds;
        }
Пример #18
0
        /// <summary>
        /// Notification that the bounds has changed between
        /// the size and the print.  
        /// 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>New required size</returns>
        protected override SectionSizeValues BoundsChanged(
            Bounds originalBounds,
            Bounds newBounds)
        {
            // Find the cases where a resizing is not-necessary.
            // For now, we can handle a change in the size of the
            // bounds as long as the placement doesn't change relative to
            // our "aligned" corner, and the size is still big enough.
            bool resize = true;
            int corner = GetOrigin();
            if (corner >= 0)
            {
                if (GetPoint(originalBounds, corner) == GetPoint(newBounds, corner))
                {
                    if (newBounds.SizeFits(this.RequiredSize))
                    {
                        resize = false;
                    }
                }
            }

            if (resize)
            {
                this.ResetSize();
            }
            return base.BoundsChanged (originalBounds, newBounds);
        }
        /// <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;
        }
Пример #20
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;
 }
Пример #21
0
 /// <summary>
 /// Draws a border inside the given bounds
 /// </summary>
 /// <param name="g">Graphics object to print on</param>
 /// <param name="bounds">Outer bounds of the border</param>
 public void DrawBorder(Graphics g, Bounds bounds)
 {
     RectangleF rect = bounds.GetRectangleF();
     DrawBorder (g, rect);
 }
Пример #22
0
        /// <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
            )
        {
            if ( !reportDocument.NoPrint )
            {
                // draw background and text
                if (this.TextStyle.BackgroundBrush != null)
                {
                    RectangleF backgroundRect = textLayout;
                    if (this.UseFullWidth)
                    {
                        backgroundRect.X = bounds.Position.X;
                        backgroundRect.Width = bounds.Width;
                    }
                    if (this.UseFullHeight)
                    {
                        backgroundRect.Y = bounds.Position.Y;
                        backgroundRect.Height = bounds.Height;
                    }

                    g.FillRectangle (this.TextStyle.BackgroundBrush, backgroundRect);
                }
                g.DrawString(textToPrint, textFont, this.TextStyle.Brush, textLayout, GetStringFormat());
                if (debugEnabled)
                {
                    Console.WriteLine ("Draw string '" + textToPrint + "' at " + textLayout);
                }
            }

            // Increment the character pointer...
            this.CharIndex += charsFitted;
        }
Пример #23
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;
     }
 }
Пример #24
0
 /// <summary>
 /// Gets a Point from a bounds based on a given corner 0-3
 /// </summary>
 PointF GetPoint(Bounds bounds, int corner)
 {
     Debug.Assert (corner >= 0 && corner <= 3, "Illegal origin value.");
     float x = 0;
     float y = 0;
     if ((corner & 1) == 0)
     {
         x = bounds.Position.X;
     }
     else
     {
         x = bounds.Limit.X;
     }
     if ((corner & 2) == 0)
     {
         y = bounds.Position.Y;
     }
     else
     {
         y = bounds.Limit.Y;
     }
     return new PointF (x,y);
 }
Пример #25
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;
 }
Пример #26
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;
        }
Пример #27
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 abstract void DoPrint(
     ReportDocument reportDocument,
     Graphics g,
     Bounds bounds
     );
Пример #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)
 {
     // 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;
 }
Пример #29
0
        /// <summary>
        /// Limits a bounds down to MaxWidth and MaxHeight
        /// </summary>
        Bounds LimitBounds(Bounds bounds)
        {
            if ((this.MaxWidth > 0) && (bounds.Width > this.MaxWidth))
            {
                bounds.Limit.X = bounds.Position.X + this.MaxWidth;
            }
            if ((this.MaxHeight > 0) && (bounds.Height > this.MaxHeight))
            {
                bounds.Limit.Y = bounds.Position.Y + this.MaxHeight;
            }

            // Take margins into account
            bounds = bounds.GetBounds (this.MarginTop,
                this.MarginRight, this.MarginBottom, this.MarginLeft);
            return bounds;
        }
Пример #30
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;
        }