/// <summary> /// Gets a rectangle for the image /// </summary> RectangleF GetImageRect(Bounds bounds, Image image, TextStyle textStyle) { SizeF maxSize = bounds.GetSizeF(); SizeF imgSize = new SizeF(ImageWidth, ImageHeight); return(bounds.GetRectangleF(imgSize, SectionText.ConvertAlign(textStyle.StringAlignment), textStyle.VerticalAlignment)); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Gets a rectangle for the image /// </summary> RectangleF GetImageRect(Bounds bounds) { SizeF maxSize = bounds.GetSizeF(); float scaleW = maxSize.Width / Image.Width; float scaleH = maxSize.Height / Image.Height; if (PreserveAspectRatio) { float scale = Math.Min(scaleW, scaleH); scaleW = scale; scaleH = scale; } float width = scaleW * Image.Width; float height = scaleH * Image.Height; SizeF imgSize = new SizeF(width, height); return(bounds.GetRectangleF(imgSize, this.HorizontalAlignment, this.VerticalAlignment)); }
/// <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 virtual SizeF SizePaintCell ( Graphics g, bool headerRow, bool alternatingRow, bool summaryRow, DataRowView drv, float x, float y, float width, float height, bool sizeOnly) { // TODO: Break up this function SizeF stringSize = new SizeF(width, height); string text = GetString(headerRow, summaryRow, drv); TextStyle textStyle = GetTextStyle(headerRow, alternatingRow, summaryRow); 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); }
/// <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); }
/// <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; }
/// <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; }
/// <summary> /// Gets a rectangle for the image /// </summary> RectangleF GetImageRect(Bounds bounds) { SizeF maxSize = bounds.GetSizeF(); float scaleW = maxSize.Width / Image.Width; float scaleH = maxSize.Height / Image.Height; if (PreserveAspectRatio) { float scale = Math.Min(scaleW, scaleH); scaleW = scale; scaleH = scale; } float width = scaleW * Image.Width; float height = scaleH * Image.Height; SizeF imgSize = new SizeF (width, height); return bounds.GetRectangleF (imgSize, this.HorizontalAlignment, this.VerticalAlignment); }
/// <summary> /// Gets a rectangle for the image /// </summary> RectangleF GetImageRect(Bounds bounds, Image image, TextStyle textStyle) { SizeF maxSize = bounds.GetSizeF(); SizeF imgSize = new SizeF (ImageWidth, ImageHeight); return bounds.GetRectangleF (imgSize, SectionText.ConvertAlign (textStyle.StringAlignment), textStyle.VerticalAlignment); }
/// <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; }
/// <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; }