private void btn_MeasureString3_Click(object sender, EventArgs e) { VisualBrick visBrick; BrickGraphics brickGraph = printingSystem1.Graph; string s = "Developer Express Inc."; // Specify the vertical alignment StringFormat sFormat = new StringFormat(StringFormatFlags.DirectionVertical); // Measure the string with the specified format and maximum width SizeF sz = brickGraph.MeasureString(s, 75, sFormat); // Start the report generation printingSystem1.Begin(); // Specify a page area brickGraph.Modifier = BrickModifier.Detail; // Set default vertical alignment for the text in bricks. brickGraph.DefaultBrickStyle.StringFormat = new BrickStringFormat(sFormat); // Create a rectangle of the calculated size plus the border dimensions RectangleF rect = new RectangleF(new PointF(0, 0), sz); rect = brickGraph.DefaultBrickStyle.InflateBorderWidth(rect, GraphicsDpi.Pixel); rect.Offset(-rect.X, -rect.Y); // Add a text brick to the report visBrick = brickGraph.DrawString(s, Color.Black, rect, BorderSide.All); // Finish the report generation printingSystem1.End(); // Preview the report printingSystem1.PreviewFormEx.Show(); }
private void btn_MeasureString1_Click(object sender, EventArgs e) { VisualBrick visBrick; BrickGraphics brickGraph = printingSystem1.Graph; string s = "Developer Express Inc."; // Determine the visual dimensions of the string SizeF sz = brickGraph.MeasureString(s); // Start the report generation printingSystem1.Begin(); // Specify a page area brickGraph.Modifier = BrickModifier.Detail; // Create a rectangle of the calculated size plus the border dimensions RectangleF rect = new RectangleF(new PointF(0, 0), sz); rect = brickGraph.DefaultBrickStyle.InflateBorderWidth(rect, GraphicsDpi.Pixel); rect.Offset(-rect.X, -rect.Y); // Add a brick to the report visBrick = brickGraph.DrawString(s, Color.Black, rect, BorderSide.All); // Finish the report generation printingSystem1.End(); // Preview the report printingSystem1.PreviewFormEx.Show(); }
//测量字符的打印范围(多行) private SizeF MeasureString(string text, Font font, int width) { SizeF size = BrickGraphics.MeasureString(text, font, width, null, GraphicsUnit.Pixel); size.Width = size.Width; size.Height = size.Height; return(size); }
protected override void CreateDetail(BrickGraphics graph) { base.CreateDetail(graph); SizeF textSize = graph.MeasureString(Text, (int)Math.Round(graph.ClientPageSize.Width)); RectangleF rect = new RectangleF(0, 0, graph.ClientPageSize.Width, textSize.Height); graph.DrawString(text, rect); }
//protected override void CreateInnerPageHeader(BrickGraphics graph) //{ // base.CreateInnerPageHeader(graph); // int TopMargin = ps.PageSettings.Margins.Top; // Font _font = // new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); // //g.DrawString("Class Information", _font, new SolidBrush(label1.ForeColor), 20, 40, new StringFormat()); // this.DrawString("Class Information", _font, Label1ForeColor, 20, 40, TextWidth, TextHeight, new StringFormat(), graph); // //Graphics g = e.Graphics; // //DrawTopLabel(g); // //bool more = nm.DrawDataGrid(g); // //if (more == true) // //{ // // e.HasMorePages = true; // // nm.PageNumber++; // //} //} protected override void CreateMarginalHeader(BrickGraphics graph) { base.CreateMarginalHeader(graph); int TopMargin = ps.PageSettings.Margins.Top; Font _font = new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); //g.DrawString("Class Information", _font, new SolidBrush(label1.ForeColor), 20, 40, new StringFormat()); graph.Font = _font; SizeF size = graph.MeasureString(RTitle); int x = PageWidth / 2; x = x - Convert.ToInt32(size.Width / 2); this.DrawString(RTitle, _font, Label1ForeColor, x, 10, TextWidth, TextHeight, new StringFormat(), graph); }
private void Link_CreateMarginalHeaderArea(object sender, CreateAreaEventArgs e) { // Specify required settings for the brick graphics. BrickGraphics brickGraphics = e.Graph; brickGraphics.BackColor = Color.White; brickGraphics.Font = new Font("Arial", 8); // Declare bricks. PageInfoBrick pageInfoBrick; PageImageBrick pageImageBrick; // Declare text strings. string devexpress = "XtraPrintingSystem by Developer Express Inc."; // Define the image to display. //Image pageImage = Image.FromFile(@"..\..\logo.png"); Image pageImage = new Bitmap(1, 1);//= Properties.Resources.excel32; // Display the DevExpress text string. SizeF size = brickGraphics.MeasureString(devexpress); pageInfoBrick = brickGraphics.DrawPageInfo(PageInfo.None, devexpress, Color.Black, new RectangleF(new PointF(/*343 -*/ 100 - (size.Width - pageImage.Width) / 2, pageImage.Height + 3), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; // Display the PageImageBrick containing the DevExpress logo. pageImageBrick = brickGraphics.DrawPageImage(pageImage, new RectangleF(1, 0, pageImage.Width, pageImage.Height), BorderSide.None, Color.Transparent); //pageImageBrick.Alignment = BrickAlignment.Center; // Set the rectangle for a page info brick. RectangleF r = RectangleF.Empty; r.Height = 20; // Display the PageInfoBrick containing date-time information. Date-time information is displayed // in the left part of the MarginalHeader section using the FullDateTimePattern. pageInfoBrick = brickGraphics.DrawPageInfo(PageInfo.DateTime, "{0:F}", Color.Black, r, BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Near; // Display the PageInfoBrick containing the page number among total pages. The page number // is displayed in the right part of the MarginalHeader section. pageInfoBrick = brickGraphics.DrawPageInfo(PageInfo.NumberOfTotal, "Page {0} of {1}", Color.Black, r, BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Far; }
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; } } } } } }
private void PrintableComponentLink_CreateReportHeaderArea(object sender, DevExpress.XtraPrinting.CreateAreaEventArgs e) { // Specify required settings for the brick graphics. BrickGraphics brickGraphics = e.Graph; brickGraphics.BackColor = Color.White; brickGraphics.Font = new Font("Times New Roman", 8); // Declare bricks. PageInfoBrick pageInfoBrick; PageImageBrick pageImageBrick; // Define the image to display. Image pageImage = TaxesSystem.Properties.Resources.logo_option2; // Display the PageImageBrick containing the DevExpress logo. pageImageBrick = brickGraphics.DrawPageImage(pageImage, new Rectangle(856, 0, 100, 120), BorderSide.None, Color.Transparent); pageImageBrick.Alignment = BrickAlignment.Far; // Display the PageInfoBrick containing date-time information. Date-time information is displayed // in the left part of the MarginalHeader section using the FullDateTimePattern. //{0:F} pageInfoBrick = brickGraphics.DrawPageInfo(PageInfo.DateTime, "{0:MM/dd/yyyy hh:mm tt}", Color.Black, new Rectangle(840, 130, 120, 50), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Far; // Declare text strings. string devexpress = title; // Specify required settings for the brick graphics. BrickGraphics brickGraphics2 = e.Graph; brickGraphics2.BackColor = Color.White; brickGraphics2.Font = new Font("Times New Roman", 16, FontStyle.Bold); // Display the DevExpress text string. SizeF size = brickGraphics2.MeasureString(devexpress); pageInfoBrick = brickGraphics2.DrawPageInfo(PageInfo.None, devexpress, Color.Black, new RectangleF(new PointF(440, 50), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; pageInfoBrick.HorzAlignment = DevExpress.Utils.HorzAlignment.Center; }
private void btn_BrickStringFormat_Click(object sender, EventArgs e) { VisualBrick visBrick; BrickGraphics brickGraph = printingSystem1.Graph; string s = "Developer Express Inc."; // Specify the string format. StringFormat sFormat = new StringFormat(StringFormatFlags.DirectionVertical); sFormat.Alignment = StringAlignment.Center; sFormat.LineAlignment = StringAlignment.Center; // Create the BrickStringFormat object. BrickStringFormat brickSFormat = new BrickStringFormat(sFormat); // Measure the string according to the specified format SizeF sz = brickGraph.MeasureString(s, 30, sFormat); // Start the report generation. printingSystem1.Begin(); // Set the brick string format brickGraph.StringFormat = brickSFormat; // Create a rectangle. RectangleF rect = new RectangleF(new PointF(0, 0), new SizeF(30, 150)); // Specify a page area. brickGraph.Modifier = BrickModifier.Detail; // Add a brick to the report. visBrick = brickGraph.DrawString(s, Color.MidnightBlue, rect, BorderSide.All); // Finish the report generation. printingSystem1.End(); // Preview the report. printingSystem1.PreviewFormEx.Show(); }
private void PrintableComponentLink_CreateReportHeaderArea(object sender, DevExpress.XtraPrinting.CreateAreaEventArgs e) { // Specify required settings for the brick graphics. BrickGraphics brickGraphics = e.Graph; Height = 100; brickGraphics.BackColor = Color.White; brickGraphics.Font = new Font("Neo Sans Arabic", 10); // Declare bricks. PageInfoBrick pageInfoBrickFrom; PageInfoBrick pageInfoBrickTo; PageInfoBrick pageInfoBrick; PageInfoBrick pageInfo; PageInfoBrick pageInfo1; PageImageBrick pageImageBrick; // Define the image to display. Image pageImage = TaxesSystem.Properties.Resources.logo_option2; // Display the PageImageBrick containing the DevExpress logo. pageImageBrick = brickGraphics.DrawPageImage(pageImage, new Rectangle(10, 0, 80, 100), BorderSide.None, Color.Transparent); pageImageBrick.Alignment = BrickAlignment.Far; // Display the PageInfoBrick containing date-time information. Date-time information is displayed // in the left part of the MarginalHeader section using the FullDateTimePattern. //{0:F} pageInfoBrickFrom = brickGraphics.DrawPageInfo(PageInfo.None, ":من", Color.Black, new Rectangle(180, 110, 60, 80), BorderSide.None); pageInfoBrickFrom.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickFrom = brickGraphics.DrawPageInfo(PageInfo.None, d.dateFrom, Color.Black, new Rectangle(40, 110, 140, 80), BorderSide.None); pageInfoBrickFrom.Alignment = BrickAlignment.Near; pageInfoBrickFrom.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, ":الي", Color.Black, new Rectangle(180, 130, 60, 80), BorderSide.None); pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, d.dateTo, Color.Black, new Rectangle(40, 130, 140, 80), BorderSide.None); pageInfoBrickTo.Alignment = BrickAlignment.Near; pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); BrickGraphics brickGraphics1 = e.Graph; pageInfo = brickGraphics1.DrawPageInfo(PageInfo.None, d.delegateName, Color.Black, new Rectangle(525, 110, 180, 70), BorderSide.None); pageInfo.Alignment = BrickAlignment.Near; pageInfo.Font = new Font("Tahoma", 10, FontStyle.Bold); BrickGraphics brickGraphics3 = e.Graph; pageInfo1 = brickGraphics3.DrawPageInfo(PageInfo.None, d.company, Color.Black, new Rectangle(528, 130, 180, 70), BorderSide.None); pageInfo1.Alignment = BrickAlignment.Near; pageInfo1.Font = new Font("Tahoma", 10, FontStyle.Bold); if (d.company_profit_list != null) { pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, "الشركة", Color.Black, new Rectangle(525, 110, 100, 80), BorderSide.None); pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, "قيمة ربح المندوب", Color.Black, new Rectangle(528, 130, 150, 80), BorderSide.None); pageInfoBrickTo.Alignment = BrickAlignment.Far; pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); int y = 130; PageInfoBrick pageInfoBrick3; foreach (company_profit item in d.company_profit_list) { y += 20; pageInfoBrick3 = brickGraphics.DrawPageInfo(PageInfo.None, item.companyName, Color.Black, new Rectangle(725, y, 140, 80), BorderSide.None); pageInfoBrick3.Font = new Font("Tahoma", 10, FontStyle.Regular); pageInfoBrick3 = brickGraphics.DrawPageInfo(PageInfo.None, item.delegateProfit, Color.Black, new Rectangle(528, y, 140, 80), BorderSide.None); pageInfoBrick3.Alignment = BrickAlignment.Far; pageInfoBrick3.Font = new Font("Tahoma", 10, FontStyle.Regular); } pageInfoBrick3 = brickGraphics.DrawPageInfo(PageInfo.None, d.delegateProfit + ":اجمالي ربح المندوب ", Color.Black, new Rectangle(685, y + 40, 230, 80), BorderSide.None); pageInfoBrick3.Alignment = BrickAlignment.Far; pageInfoBrick3.Font = new Font("Tahoma", 11, FontStyle.Bold); } // Declare text strings. string devexpress = title; // Specify required settings for the brick graphics. BrickGraphics brickGraphics2 = e.Graph; brickGraphics2.BackColor = Color.White; brickGraphics2.Font = new Font("Times New Roman", 14, FontStyle.Bold); // Display the DevExpress text string. SizeF size = brickGraphics2.MeasureString(devexpress); pageInfoBrick = brickGraphics2.DrawPageInfo(PageInfo.None, devexpress, Color.Black, new RectangleF(new PointF(320, 50), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; if (branchName != "") { SizeF sizea = brickGraphics2.MeasureString(branchName); pageInfoBrick = brickGraphics2.DrawPageInfo(PageInfo.None, branchName, Color.Black, new RectangleF(new PointF(370, 70), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; } e.Graph.PrintingSystem.Document.PrintingSystem.PageMargins.Bottom = 0; }
private void CreateReport(PrintingSystem ps, DataView dv, int[] w, string[] s, ImageList iList, int selectColumn, string reportName, Image imgTitle) { Brick brick; BrickGraphics gr = ps.Graph; ps.Begin(); gr.StringFormat = gr.StringFormat.ChangeLineAlignment(StringAlignment.Center); gr.Font = new Font("Arial", 8, FontStyle.Bold); int imgW = 0, imgH = 0; if (iList != null) { imgW = iList.ImageSize.Width; imgH = iList.ImageSize.Height; } int h = gr.Font.Height + 2; //header int leftCell = 0; int headerwidth; gr.Modifier = BrickModifier.DetailHeader; gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Center); gr.BackColor = SystemColors.Highlight; for (int j = 0; j < s.Length; j++) { headerwidth = w[j]; if (j == 0) { headerwidth += imgW + imgW / 4; } gr.DrawString(dv.Table.Columns[s[j]].Caption, SystemColors.HighlightText, new RectangleF(leftCell, 0, headerwidth, h), BorderSide.All); leftCell += headerwidth; } //strings h = Math.Max(h, imgH + imgH / 2); gr.Modifier = BrickModifier.Detail; gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Near); gr.Font = new Font("Arial", 8); int hGeneral = 0; int hRow = 0; for (int i = 0; i < dv.Count; i++) { DataRow row = dv[i].Row; leftCell = imgW + imgW / 4; hRow = 0; for (int j = 0; j < s.Length; j++) { hRow = Math.Max(hRow, CalcRowHeight(gr, row[s[j]].ToString(), w[j], h)); } if (iList != null) { brick = gr.DrawImage(iList.Images[0], new RectangleF(0, hGeneral + (hRow - imgH) / 2, imgW, imgH), BorderSide.None, Color.Transparent); brick.ID = row[s[1]].ToString(); brick.Url = "empty"; brick.Value = 0; } for (int j = 0; j < s.Length; j++) { if ("+Byte+Decimal+Double+Int16+Int32+Int64+SByte+Single+UInt16++UInt32+UInt64+".IndexOf("+" + dv.Table.Columns[s[j]].DataType.Name + "+") > -1) { gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Far); } else { gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Near); } if (j == selectColumn) { gr.BackColor = (iList != null) ? Color.SkyBlue : Color.Yellow; } else { gr.BackColor = SystemColors.Window; } gr.DrawString(row[s[j]].ToString(), SystemColors.WindowText, new RectangleF(leftCell, hGeneral, w[j], hRow), BorderSide.All); leftCell += w[j]; } hGeneral += hRow; } //hyperlink if (iList == null) { gr.Font = new Font("Arial", 8, FontStyle.Underline); gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Near); gr.BackColor = Color.Transparent; string hLink = "Show Main Report..."; brick = gr.DrawString(hLink, Color.Blue, new RectangleF(0, hGeneral + h, gr.MeasureString(hLink).Width + 5, h), BorderSide.None); brick.Value = brick.ID = "Main"; brick.Url = "empty"; brick.Printed = false; } CreatePageHeader(gr, reportName, imgTitle, (iList != null) ? Color.Blue : Color.Red); CreatePageFooter(gr); ps.End(); }
private int CalcRowHeight(BrickGraphics gr, string s, int w, int h) { return(Math.Max((int)gr.MeasureString(s, w).Height, h)); }
private void PrintableComponentLink_CreateReportHeaderArea(object sender, DevExpress.XtraPrinting.CreateAreaEventArgs e) { // Specify required settings for the brick graphics. BrickGraphics brickGraphics = e.Graph; brickGraphics.BackColor = Color.White; brickGraphics.Font = new Font("Neo Sans Arabic", 10); // Declare bricks. PageInfoBrick pageInfoBrickFrom; PageInfoBrick pageInfoBrickTo; PageInfoBrick pageInfoBrick; PageInfoBrick pageInfo; PageInfoBrick pageInfo1; PageImageBrick pageImageBrick; // Define the image to display. Image pageImage = TaxesSystem.Properties.Resources.logo_option2; // Display the PageImageBrick containing the DevExpress logo. pageImageBrick = brickGraphics.DrawPageImage(pageImage, new Rectangle(10, 0, 150, 150), BorderSide.None, Color.Transparent); pageImageBrick.Alignment = BrickAlignment.Far; // Display the PageInfoBrick containing date-time information. Date-time information is displayed // in the left part of the MarginalHeader section using the FullDateTimePattern. //{0:F} pageInfoBrickFrom = brickGraphics.DrawPageInfo(PageInfo.None, ":العميل", Color.Black, new Rectangle(180, 160, 60, 80), BorderSide.None); pageInfoBrickFrom.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickFrom = brickGraphics.DrawPageInfo(PageInfo.None, d.dateFrom, Color.Black, new Rectangle(40, 160, 120, 80), BorderSide.None); pageInfoBrickFrom.Alignment = BrickAlignment.Near; pageInfoBrickFrom.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, ":تلفون العميل", Color.Black, new Rectangle(180, 180, 160, 80), BorderSide.None); pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, d.dateTo, Color.Black, new Rectangle(40, 180, 120, 80), BorderSide.None); pageInfoBrickTo.Alignment = BrickAlignment.Far; pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); BrickGraphics brickGraphics1 = e.Graph; pageInfo = brickGraphics1.DrawPageInfo(PageInfo.None, d.dateFrom, Color.Black, new Rectangle(825, 160, 120, 70), BorderSide.None); pageInfo.Alignment = BrickAlignment.Near; pageInfo.Font = new Font("Tahoma", 10, FontStyle.Bold); BrickGraphics brickGraphics3 = e.Graph; pageInfo1 = brickGraphics3.DrawPageInfo(PageInfo.None, d.dateTo, Color.Black, new Rectangle(828, 180, 120, 70), BorderSide.None); pageInfo1.Alignment = BrickAlignment.Near; pageInfo1.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, ":تاريخ الاسترجاع", Color.Black, new Rectangle(825, 240, 100, 80), BorderSide.None); pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); pageInfoBrickTo = brickGraphics.DrawPageInfo(PageInfo.None, ":سبب الاسترجاع", Color.Black, new Rectangle(628, 240, 150, 80), BorderSide.None); pageInfoBrickTo.Alignment = BrickAlignment.Far; pageInfoBrickTo.Font = new Font("Tahoma", 10, FontStyle.Bold); int y = 240; PageInfoBrick pageInfoBrick3; pageInfoBrick3 = brickGraphics.DrawPageInfo(PageInfo.None, d.delegateName, Color.Black, new Rectangle(825, y, 120, 80), BorderSide.None); pageInfoBrick3.Font = new Font("Tahoma", 10, FontStyle.Regular); pageInfoBrick3 = brickGraphics.DrawPageInfo(PageInfo.None, d.delegateProfit, Color.Black, new Rectangle(628, y, 150, 80), BorderSide.None); pageInfoBrick3.Alignment = BrickAlignment.Far; pageInfoBrick3.Font = new Font("Tahoma", 10, FontStyle.Regular); // Declare text strings. string devexpress = "أذن مرتجع"; // Specify required settings for the brick graphics. BrickGraphics brickGraphics2 = e.Graph; brickGraphics2.BackColor = Color.White; brickGraphics2.Font = new Font("Tahoma", 14, FontStyle.Bold); // Display the DevExpress text string. SizeF size = brickGraphics2.MeasureString(devexpress); pageInfoBrick = brickGraphics2.DrawPageInfo(PageInfo.None, devexpress, Color.Black, new RectangleF(new PointF(420, 50), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; size = brickGraphics2.MeasureString(ReturnPermissionNum.ToString()); pageInfoBrick = brickGraphics2.DrawPageInfo(PageInfo.None, ReturnPermissionNum.ToString(), Color.Black, new RectangleF(new PointF(480, 80), size), BorderSide.None); pageInfoBrick.Alignment = BrickAlignment.Center; }
private static SizeF GetSizeOfText(string text, Font font) { return(BrickGraphics.MeasureString(text, font, 1000, StringFormat.GenericTypographic, GraphicsUnit.Display)); }
private void button1_Click(object sender, EventArgs e) { BrickGraphics gr = printingSystem1.Graph; BrickStringFormat bsf = new BrickStringFormat(StringAlignment.Near, StringAlignment.Center); gr.StringFormat = bsf; gr.BorderColor = SystemColors.ControlDark; // Declare bricks. ImageBrick imagebrick; TextBrick textbrick; CheckBoxBrick checkbrick; Brick brick; PageInfoBrick pageinfobr; PageImageBrick pageimagebr; // Declare text strings. string[] rows = { "Species No:", "Length (cm):", "Category:", "Common Name:", "Species Name:" }, desc = { "90070", "30", "Angelfish", "Blue Angelfish", "Pomacanthus nauarchus" }; string note = "Habitat is around boulders, caves, coral ledges and crevices in shallow waters. " + "Swims alone or in groups. Its color changes dramatically from juvenile to adult. The mature " + "adult fish can startle divers by producing a powerful drumming or thumping sound intended " + "to warn off predators. Edibility is good. Range is the entire Indo-Pacific region.", devexpress = "XtraPrintingSystem by Developer Express Inc."; // Define the images to display. Image img = Image.FromFile(@"..\..\angelfish.png"), pageimage = Image.FromFile(@"..\..\logo.png"); printingSystem1.PageSettings.Landscape = false; printingSystem1.Begin(); // Detail section creation. gr.Modifier = BrickModifier.Detail; // Start creation of a non-separable group of bricks. gr.BeginUnionRect(); // Display the image. imagebrick = gr.DrawImage(img, new RectangleF(0, 0, 250, 150), BorderSide.All, Color.Transparent); imagebrick.Hint = "Blue Angelfish"; textbrick = gr.DrawString("1", Color.Blue, new RectangleF(5, 5, 30, 15), BorderSide.All); textbrick.StringFormat = textbrick.StringFormat.ChangeAlignment(StringAlignment.Center); // Display a checkbox. checkbrick = gr.DrawCheckBox(new RectangleF(5, 145, 10, 10), BorderSide.All, Color.White, true); // Create a set of bricks, representing a column with species names. gr.BackColor = Color.FromArgb(153, 204, 255); gr.Font = new Font("Arial", 10, FontStyle.Italic | FontStyle.Bold | FontStyle.Underline); for (int i = 0; i < 5; i++) { // Draw a VisualBrick representing borders for the following TextBrick. brick = gr.DrawRect(new RectangleF(256, 32 * i, 120, 32), BorderSide.All, Color.Transparent, Color.Empty); // Draw the TextBrick with species names. textbrick = gr.DrawString(rows[i], Color.Black, new RectangleF(258, 32 * i + 2, 116, 28), BorderSide.All); } // Create a set of bricks representing a column with the species characteristics. gr.Font = new Font("Arial", 11, FontStyle.Bold); gr.BackColor = Color.White; for (int i = 0; i < 5; i++) { brick = gr.DrawRect(new RectangleF(376, 32 * i, gr.ClientPageSize.Width - 376, 32), BorderSide.All, Color.Transparent, gr.BorderColor); // Draw a TextBrick with species characteristics. textbrick = gr.DrawString(desc[i], Color.Indigo, new RectangleF(378, 32 * i + 2, gr.ClientPageSize.Width - 380, 28), BorderSide.All); // For text bricks containing numeric data, set text alignment to Far. if (i < 2) { textbrick.StringFormat = textbrick.StringFormat.ChangeAlignment(StringAlignment.Far); } } // Drawing the TextBrick with notes. gr.Font = new Font("Arial", 8); gr.BackColor = Color.Cornsilk; textbrick = gr.DrawString(note, Color.Black, new RectangleF(new PointF(0, 160), new SizeF(gr.ClientPageSize.Width, 40)), BorderSide.All); textbrick.StringFormat = textbrick.StringFormat.ChangeLineAlignment(StringAlignment.Near); textbrick.Hint = note; // Finish the creation of a non-separable group of bricks. gr.EndUnionRect(); // Create a MarginalHeader section. gr.Modifier = BrickModifier.MarginalHeader; RectangleF r = RectangleF.Empty; r.Height = 20; gr.BackColor = Color.White; // Display the DevExpress text string. SizeF sz = gr.MeasureString(devexpress); pageinfobr = gr.DrawPageInfo(PageInfo.None, devexpress, Color.Black, new RectangleF(new PointF(343 - (sz.Width - pageimage.Width) / 2, pageimage.Height + 3), sz), BorderSide.None); pageinfobr.Alignment = BrickAlignment.Center; // Display the PageImageBrick containing the Developer Express logo. pageimagebr = gr.DrawPageImage(pageimage, new RectangleF(343, 0, pageimage.Width, pageimage.Height), BorderSide.None, Color.Transparent); pageimagebr.Alignment = BrickAlignment.Center; // Display the PageInfoBrick containing date-time information. Date-time information is displayed // in the left part of the MarginalHeader section using the FullDateTimePattern. pageinfobr = gr.DrawPageInfo(PageInfo.DateTime, "{0:F}", Color.Black, r, BorderSide.None); pageinfobr.Alignment = BrickAlignment.Near; // Display the PageInfoBrick containing the page number among total pages. The page number // is displayed in the right part of the MarginalHeader section. pageinfobr = gr.DrawPageInfo(PageInfo.NumberOfTotal, "Page {0} of {1}", Color.Black, r, BorderSide.None); pageinfobr.Alignment = BrickAlignment.Far; printingSystem1.End(); printingSystem1.PreviewFormEx.Show(); }