protected override void PrintGroupRow(int rowHandle, int level) { Rectangle r = Rectangle.Empty; r.X = Indent + level * ViewViewInfo.LevelIndent; r.Width = this.fMaxRowWidth - r.Left; r.Y = Y; r.Height = CurrentRowHeight; int textWidth; ImageBrick ib; Bitmap bmp = new Bitmap(r.Width, r.Height); GraphicsCache cache = new GraphicsCache(Graphics.FromImage(bmp)); RowObjectCustomDrawEventArgs args = View.GetRowObjectCustomDrawEventArgs(cache, rowHandle, r, out textWidth); if (args == null) { base.PrintGroupRow(rowHandle, level); return; } ib = new ImageBrick(); ib.Rect = r; ib.Image = bmp; ib.BackColor = Color.Transparent; _graph.DrawBrick(ib, ib.Rect); r.Width = textWidth; // if (View.OptionsPrint.UsePrintStyles) SetDefaultBrickStyle(Graph, Bricks["GroupRow"]); // else { AppearanceObject rowAppearance = View.GetLevelStyle(level, true); BrickStyle tempStyle = new BrickStyle(Bricks["GroupRow"].Sides, Bricks["GroupRow"].BorderWidth, Color.Transparent /*rowAppearance.BorderColor*/, rowAppearance.BackColor, rowAppearance.ForeColor, rowAppearance.Font, Bricks["GroupRow"].StringFormat); tempStyle.TextAlignment = DevExpress.XtraPrinting.Native.TextAlignmentConverter.ToTextAlignment(rowAppearance.TextOptions.HAlignment, rowAppearance.TextOptions.VAlignment); SetDefaultBrickStyle(Graph, tempStyle); } string groupText = View.GetGroupRowDisplayText(rowHandle); ITextBrick textBrick = DrawTextBrick(Graph, groupText, r, true); textBrick.Text = textBrick.Text.Replace(Environment.NewLine, ""); textBrick.BackColor = Color.Transparent; textBrick.TextValue = View.GetGroupRowPrintValue(rowHandle); Y += r.Height; }
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 = ""; } } } } }
protected virtual void DrawGroupTextBrick(IBrickGraphics graph, Rectangle bounds, int rowHandle) { string prefFormat = View.GroupFormat; View.GroupFormat = "{0}:{1}"; string groupText = View.GetGroupRowDisplayText(rowHandle); View.GroupFormat = prefFormat; Rectangle groupTextBounds = new Rectangle(bounds.X + Indent, bounds.Y, ((PrintColumnInfo)Columns[0]).Bounds.Width / 2 - Indent, bounds.Height); DrawTextBrick(graph, groupText, groupTextBounds, false); for (int i = 0; i < Columns.Count; i++) { PrintColumnInfo col = (PrintColumnInfo)Columns[i]; Rectangle groupCellBounds = col.Bounds; groupCellBounds.Y = bounds.Y; groupCellBounds.Height = bounds.Height; if (i == 0) { groupCellBounds.X = groupCellBounds.Width / 2; groupCellBounds.Width -= groupCellBounds.Width / 2; } GridGroupSummaryItem summary; string summaryText = string.Empty; if (printSummaryInfo.TryGetValue(col.Column.FieldName, out summary)) { summaryText = View.GetGroupSummaryDisplayText(rowHandle, summary); } ITextBrick summaryBrick = (ITextBrick)DrawTextBrick(graph, summaryText, groupCellBounds, false); if (summary != null && View.Columns[summary.FieldName].VisibleIndex == 0) { summaryBrick.HorzAlignment = HorzAlignment.Far; } summaryBrick.Padding = new PaddingInfo(5, 2, 0, 0); } }
public override void PrintHeader(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 = col.Column.GetTextCaption(); if (!ColumnsInfo[Columns.IndexOf(col)].Column.OptionsColumn.ShowCaption) { caption = string.Empty; } DevExpress.XtraGrid.Drawing.GridColumnInfoArgs columnsInfo = ColumnsInfo[Columns.IndexOf(col)]; DrawElementInfoCollection innerElements = columnsInfo.InnerElements; DrawElementInfo columnImageInfo = null; GlyphElementInfoArgs elementInfo = null; this.ViewViewInfo.Painter.ElementsPainter.Column.CalcObjectBounds(columnsInfo); for (int i = 0; i < innerElements.Count; i++) { if (innerElements[i].ElementInfo is DevExpress.Utils.Drawing.GlyphElementInfoArgs) { columnImageInfo = innerElements[i]; elementInfo = columnImageInfo.ElementInfo as GlyphElementInfoArgs; break; } } ITextBrick tBrick = null; if (elementInfo.Glyph == null && elementInfo.ImageIndex < 0) { tBrick = DrawTextBrick(graph, caption, r); } else { IPanelBrick panelBrick = new XETextPanelBrick(graph.DefaultBrickStyle); float offsetForBorder = panelBrick.BorderWidth; if (columnImageInfo.Alignment != StringAlignment.Center) { tBrick = new TextBrick(); tBrick.Rect = new RectangleF(offsetForBorder, offsetForBorder, r.Width, r.Height); tBrick.Text = caption; tBrick.Style = graph.DefaultBrickStyle; tBrick.Sides = BorderSide.None; panelBrick.Bricks.Add(tBrick); } panelBrick.Value = caption; Rectangle columnRect = r; Rectangle imageRect = new Rectangle(new Point((int)offsetForBorder, (int)offsetForBorder), elementInfo.GlyphSize); imageRect.Y = r.Y + columnImageInfo.ElementInterval; switch (columnImageInfo.Alignment) { case StringAlignment.Near: tBrick.Rect = new RectangleF(new PointF(imageRect.Location.X + imageRect.Size.Width, tBrick.Rect.Y), tBrick.Rect.Size); MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder); break; case StringAlignment.Center: { imageRect.X += (r.Width - imageRect.Width) / 2; } break; case StringAlignment.Far: tBrick.Rect = new RectangleF(tBrick.Rect.Location, new SizeF(tBrick.Rect.Width - imageRect.Width, tBrick.Rect.Height)); MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder); imageRect.X = (int)tBrick.Rect.Right; break; } ImageBrick iBrick = GetImageBrick(imageRect, columnImageInfo); if (iBrick != null) { panelBrick.Bricks.Add(iBrick); } graph.DrawBrick(panelBrick, columnRect); } if (tBrick == null) { continue; } if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles) { using (Graphics g = this.View.GridControl.CreateGraphics()) { SizeF s = g.MeasureString(tBrick.Text, tBrick.Font, 1000, tBrick.StringFormat.Value); if (s.Width + 5 >= r.Width) { tBrick.Text = ""; tBrick.TextValue = ""; } } } } }
private void MakeInflate(ref ITextBrick itb, float offsetByHorizontalAxis, float offsetByVerticalAxis) { itb.Rect = new RectangleF(itb.Rect.Location, new SizeF(itb.Rect.Width - offsetByHorizontalAxis, itb.Rect.Height - offsetByVerticalAxis)); }
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 HeaderPrintEventArgs(ITextBrick brick, PrintColumnInfo columnInfo) { Brick = brick; ColumnInfo = columnInfo; }