public override IVisualBrick GetBrick(PrintCellHelperInfo info) { TextBrick contentBrick = (TextBrick)base.GetBrick(info); ImageBrick imgBrick = new ImageBrick(); IPanelBrick panelBrick = new XETextPanelBrick(CreateBrickStyle(info, "panel")); SetCommonBrickProperties(panelBrick, info); panelBrick.Bricks.Add(imgBrick); panelBrick.Bricks.Add(contentBrick); imgBrick.Image = GetImage(); imgBrick.Size = ContentImageSize; panelBrick.Style = contentBrick.Style; contentBrick.Location = new PointFloat(imgBrick.Location.X + imgBrick.Size.Width, 0); contentBrick.Sides = BorderSide.None; contentBrick.Size = new SizeF(info.Rectangle.Size.Width - imgBrick.Size.Width, info.Rectangle.Size.Height); panelBrick.Rect = new RectangleF(0, 0, contentBrick.Rect.Width + imgBrick.Size.Width, contentBrick.Rect.Height); return(panelBrick); }
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 = ""; } } } } }