private void AwesomeIcons(Context ctx) { var p = new ReferencePainter(); p.Font = this.Toolkit.CreateFrontend <Font>(this.Font); p.Bounds = this.Bounds.ToXwt(); var awesomeIcons = new AwesomeIconeria { Fill = true, FillColor = Colors.Black }; var size = 24; var border = 24; var x = border * 2; var y = border * 2; var textSize = 8; var textLayout = new TextLayout(ctx); textLayout.Font = p.Font.WithSize(8); awesomeIcons.ForEach((icon, name, id) => { var img = awesomeIcons.AsImage(icon, size); ctx.DrawImage(img, x, y); textLayout.Text = name.Remove(0, 5); ctx.DrawTextLayout(textLayout, x, y + size); x += size + border; if (x >= p.Bounds.Width - border) { x = border * 2; y += size + border + textSize; } }); }
public void TestPaintDocumentNaviatator() { var engine = ReportPainter.Switch(); var bounds = new Rectangle(10, 10, 500, 100); var iconeria = new AwesomeIconeria { Fill = true, FillColor = Colors.Black }; var utils = Registry.Pooled <IDrawingUtils>(); var style = Registry.Pooled <StyleSheets>().DefaultStyleSheet.ItemStyle.DefaultStyle.Clone() as IStyle; // points = pixels * 72 / g.DpiX; style.Font = Font.FromName(style.Font.Family).WithSize((bounds.Height - bounds.Height / 10) * 72 / utils.ScreenResolution().Width); var pageNr = "XXXX"; var pageNrSize = utils.GetTextDimension(pageNr, style); ReportPainter.PushPaint(ctx => { ctx.SetLineWidth(1); ctx.SetColor(Colors.Blue); ContextPainterExtensions.DrawRoundedRect(ctx, bounds, 45); ctx.ClosePath(); ctx.Stroke(); var iconSize = bounds.Height; iconeria.PaintIcon(ctx, iconSize, bounds.X + iconSize / 2, bounds.Y, c => { c.Scale(-1, 1); iconeria.FaPlay(c); }); iconeria.PaintIcon(ctx, iconSize, bounds.Right - ((iconSize * .7)), bounds.Y, c => { iconeria.FaPlay(c); }); var textBounds = new Rectangle(new Point(), pageNrSize); textBounds.Location = new Point( bounds.Location.X + (bounds.Width - textBounds.Width) / 2, bounds.Location.Y + (bounds.Height - textBounds.Height) / 2); ContextPainterExtensions.DrawText(ctx, textBounds, "123", style.Font, style.TextColor); ctx.SetColor(Colors.Aqua); ctx.Rectangle(textBounds); ctx.Stroke(); }); WritePainter(); ReportPainter.Restore(engine); }