protected void ASPxGridViewExporter1_RenderBrick(object sender, ASPxGridViewExportRenderingEventArgs e) { StringFormat sFormat = new StringFormat(StringFormatFlags.NoWrap); BrickStringFormat brickSFormat = new BrickStringFormat(sFormat); e.XlsxFormatString = sFormat.ToString(); }
public void DrawString(string s, Font printFont, Color brush, Single x, Single y, Single w, Single h, StringFormat sf, BrickGraphics _G) { RectangleF r = new RectangleF(); r.X = x; r.Y = y; r.Width = w; r.Height = h; _G.Font = printFont; BrickStringFormat xformat = new BrickStringFormat(sf); _G.StringFormat = xformat; _G.ForeColor = brush; _G.DrawString(s, brush, r, BorderSide.None); }
public override void PrintHeader(DevExpress.XtraPrinting.IBrickGraphics graph) { if (!View.OptionsPrint.PrintHeader) { return; } Point indent = new Point(Indent, HeaderY); Rectangle r = Rectangle.Empty; bool usePrintStyles = View.OptionsPrint.UsePrintStyles; SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]); foreach (PrintColumnInfo col in Columns) { if (!usePrintStyles) { AppearanceObject temp = new AppearanceObject(); AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel }); SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1)); } r = col.Bounds; r.Offset(indent); string caption = GetTextCaptionForPrinting(col.Column); if (!col.Column.OptionsColumn.ShowCaption) { caption = string.Empty; } ITextBrick itb = DrawTextBrick(graph, caption, r); (View as MyGridView).RaiseHeaderPrintEvent(this, new HeaderPrintEventArgs(itb, col)); if (caption.Contains(Environment.NewLine)) { itb.Style.StringFormat = BrickStringFormat.Create(itb.Style.TextAlignment, true); } if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles) { using (Graphics g = this.View.GridControl.CreateGraphics()) { SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value); if (s.Width + 5 >= r.Width) { itb.Text = ""; itb.TextValue = ""; } } } } }
private void xrCheckBox1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { string neighborCellText = GetCurrentColumnValue("Content").ToString(); Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); int neighborCellWidthPixels = ConvertFromReportUnitToPixels(xrTableCell2.WidthF); SizeF neighborCellSizePixels = graphics.MeasureString(neighborCellText, xrTableCell2.Font, neighborCellWidthPixels, BrickStringFormat.Create(xrTableCell2.TextAlignment, xrTableCell2.WordWrap).Value); graphics.Dispose(); float neighborCellHeightReportUnits = ConvertFromPixelsToReportUnit((int)Math.Round(neighborCellSizePixels.Height)); xrCheckBox1.LocationF = new PointF(xrCheckBox1.LocationF.X, neighborCellHeightReportUnits / 2 - xrCheckBox1.SizeF.Height / 2); }
public static BrickStyle GetResultingStyle(bool isSingleFileMode, BrickStyle originalStyle, XRDataCellPosition position) { BrickStyle style = new BrickStyle(originalStyle); style.StringFormat = BrickStringFormat.Create(style.TextAlignment, style.StringFormat.WordWrap); BorderSide sides = originalStyle.Sides; if (sides.HasFlag(BorderSide.Right) && !position.HasFlag(XRDataCellPosition.RightMost)) { style.Sides &= ~BorderSide.Right; } if (sides.HasFlag(BorderSide.Bottom) && sides.HasFlag(BorderSide.Top) && !position.HasFlag(XRDataCellPosition.Header)) { style.Sides &= ~BorderSide.Top; } if (position.HasFlag(XRDataCellPosition.HigherLevel) && sides.HasFlag(BorderSide.Top)) { style.Sides |= BorderSide.Top; } if (position.HasFlag(XRDataCellPosition.LowerLevel) && sides.HasFlag(BorderSide.Bottom) && sides.HasFlag(BorderSide.Top)) { style.Sides &= ~BorderSide.Bottom; } if (!isSingleFileMode) { if (position.HasFlag(XRDataCellPosition.FirstOnPage)) { style.Sides &= ~BorderSide.Top; } if (position.HasFlag(XRDataCellPosition.LastOnPage) && sides.HasFlag(BorderSide.Bottom)) { style.Sides |= BorderSide.Bottom; } } return(style); }
private void button1_Click(object sender, EventArgs e) { // Start report generation. printingSystem1.Begin(); // Obtain the Printing System's graphics. BrickGraphics gr = printingSystem1.Graph; // Specify graphics settings. gr.Modifier = BrickModifier.Detail; gr.BackColor = Color.FromArgb(26, 26, 154); gr.BorderColor = Color.FromArgb(254, 202, 2); // Insert a text brick. string s = "XtraPrinting Library"; TextBrick textBrick = new TextBrick(); textBrick = gr.DrawString(s, Color.FromArgb(67, 145, 252), new RectangleF(0, 0, 286, 80), BorderSide.All); textBrick.Font = new Font("Arial", 20, FontStyle.Bold | FontStyle.Italic); BrickStringFormat bsf = new BrickStringFormat(StringAlignment.Center, StringAlignment.Center); textBrick.StringFormat = bsf; // Insert a page break. printingSystem1.InsertPageBreak(81); // Insert an image brick. Image img = Image.FromFile(@"..\..\logo.png"); ImageBrick imageBrick = new ImageBrick(); imageBrick = gr.DrawImage(img, new RectangleF(0, 81, 286, 81)); // Finish report generation. printingSystem1.End(); // Display the Print Preview form. printingSystem1.PreviewFormEx.Show(); }
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 btn_ChangeFormatFlags_Click(object sender, EventArgs e) { VisualBrick visBrick; BrickGraphics brickGraph = printingSystem1.Graph; string s = "Developer Express Inc."; BrickStringFormat brickSFormat = new BrickStringFormat(); // Start the report generation. printingSystem1.Begin(); // Specify a page area. brickGraph.Modifier = BrickModifier.Detail; // Create a rectangle. RectangleF rect = new RectangleF(new PointF(0, 0), new SizeF(180, 75)); // Add a brick to the report. visBrick = brickGraph.DrawString(s, Color.MidnightBlue, rect, BorderSide.All); // Change the text alignment within the brick brickSFormat = visBrick.Style.StringFormat.ChangeFormatFlags(StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft); brickGraph.StringFormat = brickSFormat; // Create a second rectangle. RectangleF rect1 = new RectangleF(new PointF(0, 75), new SizeF(180, 75)); // Add the next brick to the report. visBrick = brickGraph.DrawString(s, Color.MidnightBlue, rect1, BorderSide.All); // Finish the report generation. printingSystem1.End(); // Preview the report. printingSystem1.PreviewFormEx.Show(); }
protected virtual BrickStyle GetActualBrickStyle(DataContainerBrick parentBrick, bool isHeader) { XRControlStyle resultingStyle; if (isHeader) { resultingStyle = new XRControlStyle(ContainerControl.fDefaultHeaderStyle); if (((XRDataContainerStyles)ContainerControl.Styles).HeaderStyle != null) { ApplyStyleProperties(((XRDataContainerStyles)ContainerControl.Styles).HeaderStyle, resultingStyle); } } else { resultingStyle = new XRControlStyle(ContainerControl.fDefaultCellStyle); if (((XRDataContainerStyles)ContainerControl.Styles).CellStyle != null) { ApplyStyleProperties(((XRDataContainerStyles)ContainerControl.Styles).CellStyle, resultingStyle); } if (parentBrick.PrintCache.RecordsCache.Count % 2 == 0 && ((XRDataContainerStyles)ContainerControl.Styles).OddCellStyle != null) { ApplyStyleProperties(((XRDataContainerStyles)ContainerControl.Styles).OddCellStyle, resultingStyle); } if (parentBrick.PrintCache.RecordsCache.Count % 2 != 0 && ((XRDataContainerStyles)ContainerControl.Styles).EvenCellStyle != null) { ApplyStyleProperties(((XRDataContainerStyles)ContainerControl.Styles).EvenCellStyle, resultingStyle); } } resultingStyle.StringFormat = BrickStringFormat.Create(resultingStyle.TextAlignment, ContainerControl.WordWrap); return(resultingStyle); }
public override void PrintHeader(IBrickGraphics graph) { vert = new BrickStyle(Bricks["HeaderPanel"]); vert.StringFormat = vert.StringFormat.ChangeFormatFlags(StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft); base.PrintHeader(graph); if (!View.OptionsPrint.PrintHeader) { return; } Point indent = new Point(Indent, HeaderY); Rectangle r = Rectangle.Empty; bool usePrintStyles = View.OptionsPrint.UsePrintStyles; SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]); int HeaderHeight = (this.View as CustomBandedGridView).HeaderHeightOnExport; Dictionary <PrintColumnInfo, ITextBrick> columnBricks = new Dictionary <PrintColumnInfo, ITextBrick>(); foreach (PrintColumnInfo col in Columns) { if (!usePrintStyles) { AppearanceObject temp = new AppearanceObject(); AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel }); SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1)); } r = col.Bounds; r = new Rectangle(r.Location, new Size(r.Width, HeaderHeight)); r.Offset(indent); MethodInfo mi = typeof(GridColumn).GetMethod("GetTextCaptionForPrinting", BindingFlags.NonPublic | BindingFlags.Instance); string caption = (string)mi.Invoke(col.Column, new object[] { });//col.Column.GetTextCaptionForPrinting(); if (!col.Column.OptionsColumn.ShowCaption) { caption = string.Empty; } ITextBrick itb = DrawTextBrick(graph, caption, r); if ((col.Column is CustomBandedColumn) && ((col.Column as CustomBandedColumn).CaptionVerticalOnExport)) { itb.Style = vert; } else { SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]); } if (caption.Contains(Environment.NewLine)) { itb.Style.StringFormat = BrickStringFormat.Create(itb.Style.TextAlignment, true); } if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles) { using (Graphics g = this.View.GridControl.CreateGraphics()) { SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value); if (s.Width + 5 >= r.Width) { itb.Text = ""; itb.TextValue = ""; } } } columnBricks.Add(col, itb); using (Graphics g = this.View.GridControl.CreateGraphics()) { SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value); if (s.Height + 5 >= r.Height) { itb.Text = ""; itb.TextValue = ""; } } } }
public bool DrawRows(BrickGraphics g) { int lastRowBottom = TopMargin; try { //SolidBrush ForeBrush = new SolidBrush(System.Drawing.Color.Black); Color ForeBrush = System.Drawing.Color.Black; Color BackBrush = System.Drawing.Color.White; Pen TheLinePen = new Pen(System.Drawing.Color.Gray, 1); StringFormat cellformat = new StringFormat(); cellformat.Trimming = StringTrimming.EllipsisCharacter; cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit; BrickStringFormat brickCellFormat = new BrickStringFormat(cellformat); RectangleF RowBounds = new RectangleF(0, 0, 0, 0); Font _font_label = new Font("Arial", 8F, FontStyle.Bold, GraphicsUnit.Point, ((System.Byte)(0))); Font _font_value = new Font("Arial", 8F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0))); // int X = 10; bool IsRichText = false; //bool LastIsRichText = false; if (LastPos <= 0) { for (int i = LastIndex; i < arrLabel.Count; i++) { if (arrLabel[i].ToString() == "------") { if (arrValue[i].ToString() == "RICHTEXT") IsRichText = true; DrawHorizontalLines(g, X); } else { if (IsRichText) { this.DrawString(arrLabel[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight,new StringFormat(), g); //g.DrawString(arrLabel[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 20; string s = arrValue[i].ToString(); int CarriageReturnCnt = 0; foreach (char c in s) { if (c == '\n') CarriageReturnCnt++; } this.DrawString(arrValue[i].ToString(), _font_value, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += CarriageReturnCnt * 11; IsRichText = false; } else { this.DrawString(arrLabel[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } } X += 20; //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 0; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 1; boolContinue = false; } } if (arrValue1 != null) { if (((LastPos == 1) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) LastIndex = 0; if (arrValue1.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("Initial Test Event >>",_font_label,Color.Black,50,X,TextWidth,TextHeight,new StringFormat(), g); //g.DrawString("Initial Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString(), _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue1[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue1[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 1; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 2; boolContinue = false; } } else LastPos = 2; } if (arrValue2 != null) { if (((LastPos == 2) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) LastIndex = 0; if (arrValue2.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("MidTerm Test Event >>", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString("MidTerm Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue2[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue2[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 2; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 3; boolContinue = false; } } } else LastPos = 3; } if (arrValue3 != null) { if (((LastPos == 3) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) LastIndex = 0; if (arrValue3.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("Final Test Event >>", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString("Final Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue3[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue3[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 3; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 3; boolContinue = false; } } } } } return false; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); return false; } }
public bool DrawRows(BrickGraphics g) { int lastRowBottom = TopMargin; try { //SolidBrush ForeBrush = new SolidBrush(System.Drawing.Color.Black); Color ForeBrush = System.Drawing.Color.Black; Color BackBrush = System.Drawing.Color.White; Pen TheLinePen = new Pen(System.Drawing.Color.Gray, 1); StringFormat cellformat = new StringFormat(); cellformat.Trimming = StringTrimming.EllipsisCharacter; cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit; BrickStringFormat brickCellFormat = new BrickStringFormat(cellformat); RectangleF RowBounds = new RectangleF(0, 0, 0, 0); Font _font_label = new Font("Arial", 8F, FontStyle.Bold, GraphicsUnit.Point, ((System.Byte)(0))); Font _font_value = new Font("Arial", 8F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0))); // int X = 10; bool IsRichText = false; //bool LastIsRichText = false; if (LastPos <= 0) { for (int i = LastIndex; i < arrLabel.Count; i++) { if (arrLabel[i].ToString() == "------") { if (arrValue[i].ToString() == "RICHTEXT") { IsRichText = true; } DrawHorizontalLines(g, X); } else { if (IsRichText) { this.DrawString(arrLabel[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 20; string s = arrValue[i].ToString(); int CarriageReturnCnt = 0; foreach (char c in s) { if (c == '\n') { CarriageReturnCnt++; } } this.DrawString(arrValue[i].ToString(), _font_value, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += CarriageReturnCnt * 11; IsRichText = false; } else { this.DrawString(arrLabel[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } } X += 20; //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 0; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 1; boolContinue = false; } } if (arrValue1 != null) { if (((LastPos == 1) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) { LastIndex = 0; } if (arrValue1.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("Initial Test Event >>", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString("Initial Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString(), _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue1[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue1[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 1; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 2; boolContinue = false; } } else { LastPos = 2; } } if (arrValue2 != null) { if (((LastPos == 2) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) { LastIndex = 0; } if (arrValue2.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("MidTerm Test Event >>", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString("MidTerm Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue2[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue2[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 2; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 3; boolContinue = false; } } } else { LastPos = 3; } } if (arrValue3 != null) { if (((LastPos == 3) && (boolContinue)) || (!boolContinue)) { if (!boolContinue) { LastIndex = 0; } if (arrValue3.Count > 0) { for (int i = LastIndex; i < arrLabel1.Count; i++) { if (arrLabel1[i].ToString() == "------") { DrawHorizontalLines(g, X); X += 15; this.DrawString("Final Test Event >>", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString("Final Test Event >>", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); X += 10; } else { this.DrawString(arrLabel1[i].ToString() + " : ", _font_label, Color.Black, 50, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrLabel1[i].ToString() + " : ", _font_label, new SolidBrush(System.Drawing.Color.Black), 50, X, new StringFormat()); this.DrawString(arrValue3[i].ToString(), _font_value, Color.Black, 210, X, TextWidth, TextHeight, new StringFormat(), g); //g.DrawString(arrValue3[i].ToString(), _font_value, new SolidBrush(System.Drawing.Color.Black), 210, X, new StringFormat()); } if ((arrLabel1[i].ToString() == "Instructor Change Reason") || (arrLabel1[i].ToString() == "Exception Reason") || (arrLabel1[i].ToString() == "Description") || (arrLabel1[i].ToString() == "Note")) { X += 30; } else { X += 20; } //if (X > (PageHeight * PageNumber) - (BottomMargin + TopMargin)) //{ // boolContinue = true; // LastPos = 3; // LastIndex = i; // LastIsRichText = IsRichText; // return true; //} //else LastPos = 3; boolContinue = false; } } } } } return(false); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); return(false); } }
/// <summary> /// Change page. Reset page properties /// </summary> /// <param name="g">Graphics object</param> public void NewPage(BrickGraphics g) { _G = g; _PageNumber += 1; _UsablePageHeight = _realPageHeight; if (_pageNumbering) { Single fontHeightForPageNumbering = FontHeight(_FontForPageNumering); //_UsablePageHeight -= (Single)(fontHeightForPageNumbering * 1.5); // Compute rectangular space for page number RectangleF _recForPageNumbering = new RectangleF(); _recForPageNumbering.X = _realPageLeft; _recForPageNumbering.Y = _realPageTop + _realPageHeight - fontHeightForPageNumbering; _recForPageNumbering.Width = _realPageRight - _realPageLeft; _recForPageNumbering.Height = fontHeightForPageNumbering; // impression StringFormat drawFormat = new StringFormat(); drawFormat.Alignment = StringAlignment.Far; _G.Font = _FontForPageNumering; _G.ForeColor = Color.Black; BrickStringFormat xformat = new BrickStringFormat(drawFormat); _G.StringFormat = xformat; //_G.DrawString(String.Format(_PageNumberingFormat, _PageNumber), Color.Black, _recForPageNumbering, BorderSide.None); //_G.DrawString(String.Format(_PageNumberingFormat, _PageNumber), _FontForPageNumering, Brushes.Black, _recForPageNumbering, drawFormat); } _CurrentPageTop = _UsablePageHeight * (_PageNumber - 1); _CurrentPageBottom = _CurrentPageTop + _UsablePageHeight; _PageOverflow = false; }
public void DrawString(string s, Font printFont, Color brush, Single x, Single y, Single w, Single h, StringFormat sf) { if (PrintUnitIsInCurrentPage()) { Single yPage = _ConvertToPage(y); RectangleF r = new RectangleF(); r.X = x; r.Y = yPage; r.Width = w; r.Height = h; _G.Font = printFont; BrickStringFormat xformat = new BrickStringFormat(sf); _G.StringFormat = xformat; _G.ForeColor = brush; _G.DrawString(s,brush,r, BorderSide.None); //_G.DrawString(s, printFont, brush, r, sf); } }
private void Link_CreateDetailArea(object sender, CreateAreaEventArgs e) { // Specify required settings for the brick graphics. BrickGraphics brickGraphics = e.Graph; BrickStringFormat format = new BrickStringFormat(StringAlignment.Near, StringAlignment.Center); brickGraphics.StringFormat = format; brickGraphics.BorderColor = SystemColors.ControlDark; // Declare bricks. ImageBrick imageBrick; TextBrick textBrick; CheckBoxBrick checkBrick; Brick brick; // 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."; // Define the image to display. // Image img = Image.FromFile(@"..\..\angelfish.png"); Image img = new Bitmap(1, 1);//= Properties.Resources.excel32; // Start creation of a non-separable group of bricks. brickGraphics.BeginUnionRect(); // Display the image. imageBrick = brickGraphics.DrawImage(img, new RectangleF(0, 0, 250, 150), BorderSide.All, Color.Transparent); imageBrick.Hint = "Blue Angelfish"; textBrick = brickGraphics.DrawString("1", Color.Blue, new RectangleF(5, 5, 30, 15), BorderSide.All); textBrick.StringFormat = textBrick.StringFormat.ChangeAlignment(StringAlignment.Center); // Display a checkbox. checkBrick = brickGraphics.DrawCheckBox(new RectangleF(5, 145, 10, 10), BorderSide.All, Color.White, true); // Create a set of bricks, representing a column with species names. brickGraphics.BackColor = Color.FromArgb(153, 204, 255); brickGraphics.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 = brickGraphics.DrawRect(new RectangleF(256, 32 * i, 120, 32), BorderSide.All, Color.Transparent, Color.Empty); // Draw the TextBrick with species names. textBrick = brickGraphics.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. brickGraphics.Font = new Font("Arial", 11, FontStyle.Bold); brickGraphics.BackColor = Color.White; for (int i = 0; i < 5; i++) { brick = brickGraphics.DrawRect(new RectangleF(376, 32 * i, brickGraphics.ClientPageSize.Width - 376, 32), BorderSide.All, Color.Transparent, brickGraphics.BorderColor); // Draw a TextBrick with species characteristics. textBrick = brickGraphics.DrawString(desc[i], Color.Indigo, new RectangleF(378, 32 * i + 2, brickGraphics.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. brickGraphics.Font = new Font("Arial", 8); brickGraphics.BackColor = Color.Cornsilk; textBrick = brickGraphics.DrawString(note, Color.Black, new RectangleF(new PointF(0, 160), new SizeF(brickGraphics.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. brickGraphics.EndUnionRect(); }
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(); }