private void report_FillEmptySpace(object sender, BandEventArgs e) { if (!(bool)DrawZBelowTheTableParameter.Value) { FillEmptySpace -= report_FillEmptySpace; return; } int bandHeight = GraphicsUnitConverter.Convert(e.Band.Height, ReportUnit.ToDpi(), ReportUnit.HundredthsOfAnInch.ToDpi()); if (bandHeight <= 30) { return; } Size size = new Size(612, bandHeight - 30); Size sizeInPixels = XRConvert.Convert(size, GraphicsDpi.HundredthsOfAnInch, GraphicsDpi.Pixel); Bitmap zBitmap = new Bitmap(sizeInPixels.Width, sizeInPixels.Height); Graphics gr = Graphics.FromImage(zBitmap); using (Pen pen = new Pen(Color.FromArgb(205, 205, 205), 4)) { Point[] points = new Point[] { new Point(0, 4), new Point(sizeInPixels.Width, 4), new Point(0, sizeInPixels.Height - 4), new Point(sizeInPixels.Width, sizeInPixels.Height - 4) }; gr.DrawLines(pen, points); } XRPictureBox pictureBox = new XRPictureBox(); pictureBox.BackColor = Color.Transparent; pictureBox.Size = size; pictureBox.Location = new Point(19, 15); pictureBox.Image = zBitmap; e.Band.Controls.Add(pictureBox); }
protected override void SyncDpi(float dpi) { float prevDpi = this.Dpi; base.SyncDpi(dpi); NodeIndent = GraphicsUnitConverter.Convert(NodeIndent, prevDpi, dpi); }
private float ConvertFromPixelsToReportUnit(int value) { GraphicsUnit unit = (this.ReportUnit == ReportUnit.HundredthsOfAnInch ? GraphicsUnit.Inch : GraphicsUnit.Millimeter); float multiplier = (unit == GraphicsUnit.Inch ? 100 : 10); return(GraphicsUnitConverter.Convert(value, GraphicsUnit.Pixel, unit) * multiplier); }
private int ConvertFromReportUnitToPixels(float value) { GraphicsUnit unit = (this.ReportUnit == ReportUnit.HundredthsOfAnInch ? GraphicsUnit.Inch : GraphicsUnit.Millimeter); float multiplier = (unit == GraphicsUnit.Inch ? 100 : 10); return((int)Math.Round(GraphicsUnitConverter.Convert(value, unit, GraphicsUnit.Pixel) / multiplier)); }
protected override void AfterReportPrint() { if (DetailHeight != 0) { return; } foreach (DevExpress.XtraPrinting.Page p in this.Pages) { foreach (Brick b in p) { if (b is TableBrick) { DetailHeight = Math.Max(DetailHeight, b.Size.Height); } } } switch (this.ReportUnit) { case ReportUnit.HundredthsOfAnInch: DetailHeight = 100 * GraphicsUnitConverter.Convert(DetailHeight, GraphicsUnit.Document, GraphicsUnit.Inch); break; case ReportUnit.TenthsOfAMillimeter: DetailHeight = 10 * GraphicsUnitConverter.Convert(DetailHeight, GraphicsUnit.Document, GraphicsUnit.Millimeter); break; } }
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { string customerID = GetCurrentColumnValue("CustomerID").ToString(); if (((XtraReport)xrSubreport1.ReportSource).Parameters.Count > 0) { ((XtraReport)xrSubreport1.ReportSource).Parameters[0].Value = customerID; } xrSubreport1.ReportSource.FillDataSource(); xrSubreport1.ReportSource.ApplyFiltering(); if (xrSubreport1.ReportSource.RowCount == 0) { e.Cancel = true; return; } if (!documentBuilt) { return; } if (!sections.ContainsKey(customerID)) { System.Diagnostics.Debug.WriteLine(customerID + " not found."); // Not executed. } else { xrLabel1.HeightF = 100 * GraphicsUnitConverter.Convert(sections[customerID], GraphicsUnit.Document, GraphicsUnit.Inch); ((DetailBand)sender).HeightF = 100 * GraphicsUnitConverter.Convert(sections[customerID], GraphicsUnit.Document, GraphicsUnit.Inch); } }
protected override void SyncDpi(float dpi) { float prevDpi = dpi; base.SyncDpi(dpi); fCellHeight = GraphicsUnitConverter.Convert(fCellHeight, prevDpi, dpi); }
protected Size MeasureTextSize(string text, float width, float dpi, BrickStyle style, PrintingSystemBase ps) { float convertedWidth = GraphicsUnitConverter.Convert(width, dpi, GraphicsDpi.Document); style.Padding.DeflateWidth(convertedWidth); ps.Graph.PageUnit = GraphicsUnit.Document; ps.Graph.Font = style.Font; SizeF size = ps.Graph.MeasureString(text, (int)convertedWidth, style.StringFormat.Value); size.Height += GraphicsUnitConverter.Convert((float)2f, GraphicsDpi.Pixel, GraphicsDpi.Document); return(Size.Ceiling(GraphicsUnitConverter.Convert(style.Padding.Inflate(size, GraphicsDpi.Document), GraphicsDpi.Document, dpi))); }
protected float GetBrickHeight(VisualBrick valueBrick, float columnWidth, bool isHeader) { float brickHeight; if ((!isHeader && TableControl.CellAutoHeight) || (isHeader && TableControl.HeaderAutoHeight)) { SizeF tempSize = this.MeasureTextSize(valueBrick.Text, columnWidth, TableControl.Dpi, valueBrick.Style, TableControl.RootReport.PrintingSystem); brickHeight = tempSize.Height; } else { brickHeight = GraphicsUnitConverter.Convert(isHeader ? TableControl.HeaderHeight : TableControl.CellHeight, GraphicsDpi.HundredthsOfAnInch, TableControl.Dpi); } return(brickHeight); }
public override void CreateList(AutoWidthCalculatorArgs e) { DataControlAutoWidthCalculatorArgs args = e as DataControlAutoWidthCalculatorArgs; this.Objects.Clear(); IList list = args.VisibleColumns; int count = list.Count; for (int i = 0; i < count; i++) { XRResizableFieldHeader column = (XRResizableFieldHeader)list[i]; int minWidth = (int)GraphicsUnitConverter.Convert(2, GraphicsDpi.HundredthsOfAnInch, containerControl.Dpi); int maxWidth = (int)containerControl.WidthF - (containerControl.VisibleHeaders.Count - 2) * (int)GraphicsUnitConverter.Convert(2, GraphicsDpi.HundredthsOfAnInch, containerControl.Dpi); this.Objects.Add(new AutoWidthObjectInfo(column, minWidth, maxWidth, (int)column.Width, (int)column.Width, false)); } }
private void FillColumnCellWidthCollection(DevExpress.XtraReports.UI.XtraReport xtraReport) { foreach (PSPage page in xtraReport.Pages) { NestedBrickIterator iterator = new NestedBrickIterator(page.InnerBricks); while (iterator.MoveNext()) { if (iterator.CurrentBrick is VisualBrick && ((VisualBrick)iterator.CurrentBrick).BrickOwner is XRTableCell) { string text = ((VisualBrick)iterator.CurrentBrick).Text; XRTableCell cell = ((VisualBrick)iterator.CurrentBrick).BrickOwner as XRTableCell; float actualWidth = BrickGraphics.MeasureString(text, cell.GetEffectiveFont(), 0, (StringFormat)StringFormat.GenericTypographic.Clone(), GraphicsUnit.Document).Width; switch (xtraReport.ReportUnit) { case ReportUnit.HundredthsOfAnInch: actualWidth = GraphicsUnitConverter.Convert(actualWidth, GraphicsUnit.Document, GraphicsUnit.Inch) * 100; break; case ReportUnit.TenthsOfAMillimeter: actualWidth = GraphicsUnitConverter.Convert(actualWidth, GraphicsUnit.Document, GraphicsUnit.Millimeter) * 10; break; case ReportUnit.Pixels: actualWidth = GraphicsUnitConverter.Convert(actualWidth, GraphicsUnit.Document, GraphicsUnit.Pixel); break; } actualWidth += 1; //the returned text metrics are slighly off regarding what it actually takes to render the text if (!cellColumnWidthCollection.ContainsKey(cell)) { cellColumnWidthCollection.Add(cell, actualWidth); } else { float value = cellColumnWidthCollection[cell]; if (actualWidth > value) { cellColumnWidthCollection[cell] = actualWidth; } } } } } }
public static void GenerateSinglePageReport(XtraReport report, bool createDocument, int additionHeight) { float sumHeight = 0; if (createDocument) { report.CreateDocument(); } XtraPageSettingsBase pageSettings = report.PrintingSystem.PageSettings; XtraPageSettingsBase.ApplyPageSettings(pageSettings, PaperKind.Custom, new Size(pageSettings.Bounds.Width, pageSettings.Bounds.Height * report.Pages.Count), pageSettings.Margins, pageSettings.MinMargins, pageSettings.Landscape); NestedBrickIterator iterator = new NestedBrickIterator(report.Pages[0].InnerBricks); while (iterator.MoveNext()) { if (iterator.CurrentBrick is VisualBrick) { VisualBrick brick = (VisualBrick)iterator.CurrentBrick; float bottomPos = brick.Rect.Bottom; if (bottomPos > sumHeight) { sumHeight = bottomPos; } } } sumHeight = GraphicsUnitConverter.Convert(sumHeight, GraphicsUnit.Document, GraphicsUnit.Inch) * 100; int totalPageHeight = pageSettings.Margins.Top + pageSettings.Margins.Bottom + Convert.ToInt32(sumHeight); totalPageHeight += additionHeight; XtraPageSettingsBase.ApplyPageSettings(pageSettings, PaperKind.Custom, new Size(pageSettings.Bounds.Width, totalPageHeight), pageSettings.Margins, pageSettings.MinMargins, pageSettings.Landscape); }
protected void CorrectBrickBounds(DataRecordBrick recordBrick, List <VisualBrick> childBricks, float indent, float actualHeight) { float recordHeight = GraphicsUnitConverter.Convert(2f, GraphicsDpi.HundredthsOfAnInch, TableControl.Dpi); for (int i = 0; i < childBricks.Count; i++) { if (recordHeight < childBricks[i].Rect.Height) { recordHeight = childBricks[i].Rect.Height; } } for (int i = 0; i < childBricks.Count; i++) { childBricks[i].Rect = new RectangleF(childBricks[i].Rect.X, childBricks[i].Rect.Y, childBricks[i].Rect.Width, recordHeight); VisualBrickHelper.SetBrickBounds((VisualBrick)childBricks[i], ((VisualBrick)childBricks[i]).Rect, TableControl.Dpi); recordBrick.Bricks.Add(childBricks[i]); } recordBrick.Rect = new RectangleF(indent, actualHeight, TableControl.WidthF, recordHeight); }
public float GetTopIndent() { float sumHeight = 0; XtraReportMain mainReport = documentViewer1.DocumentSource as XtraReportMain; NestedBrickIterator iterator = new NestedBrickIterator(mainReport.Pages[mainReport.Pages.Count - 1].InnerBricks); while (iterator.MoveNext()) { if (iterator.CurrentBrick is VisualBrick) { VisualBrick brick = (VisualBrick)iterator.CurrentBrick; float bottomPos = brick.Rect.Bottom; if (bottomPos > sumHeight) { sumHeight = bottomPos; } } } sumHeight = GraphicsUnitConverter.Convert(sumHeight, GraphicsUnit.Document, GraphicsUnit.Inch) * 100; return(sumHeight); }
protected override void SyncDpi(float dpi) { float prevDpi = this.Dpi; base.SyncDpi(dpi); System.Collections.Generic.List <XRFieldHeader> visibleHeaders = this.VisibleHeaders; if (visibleHeaders.Count > 0) { this.BeginInit(); float totalWidth = 0; for (int i = 0; i < visibleHeaders.Count - 1; i++) { ((XRResizableFieldHeader)visibleHeaders[i]).Width = GraphicsUnitConverter.Convert(((XRResizableFieldHeader)visibleHeaders[i]).Width, prevDpi, dpi); totalWidth += ((XRResizableFieldHeader)visibleHeaders[i]).Width; } ((XRResizableFieldHeader)visibleHeaders[visibleHeaders.Count - 1]).Width = this.WidthF - totalWidth; this.EndInit(); } }
//Modified at 2009-1-7 14:27:57@Scott public override void DrawContent(IGraphics gr, RectangleF rectf) { base.DrawContent(gr, rectf); if (this.PrintingTable != null) { WebbTableCell m_Cell = this.PrintingTable.GetCell(0, 0) as WebbTableCell; if (m_Cell != null) { if (this.ThreeD) { int nSpace = (int)GraphicsUnitConverter.Convert(5, GraphicsUnit.Pixel, GraphicsUnit.Document); rectf.Width -= nSpace; rectf.Height -= nSpace; rectf.Offset(nSpace, nSpace); m_Cell.DrawShadowContent(gr, rectf); rectf.Offset(-nSpace, -nSpace); m_Cell.DrawContent(gr, rectf); m_Cell.DrawBorderContent(gr, rectf); } else { m_Cell.DrawContent(gr, rectf); m_Cell.DrawBorderContent(gr, rectf); } } } }
private float CalculateWidth(XRControl control) { XtraReport report = control.RootReport; return(GraphicsUnitConverter.Convert(report.PageWidth - report.Margins.Left - report.Margins.Right, report.Dpi, GraphicsDpi.HundredthsOfAnInch)); }
Size CalculateSize(PrintingSystemBase printingSystem) { SizeF size = printingSystem.Pages[0].PageSize.ToSize(); return(GraphicsUnitConverter.Convert(size, GraphicsUnit.Document.ToDpi(), GraphicsUnit.Point.ToDpi()).ToSize()); }
protected PointF TranslatePointF(PointF point) { point = GraphicsUnitConverter.Convert(point, GraphicsDpi.Pixel, GraphicsDpi.Document); return(point); }