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; } }); }
protected virtual void SpeedTest(Xwt.Drawing.Context ctx) { var p = new ReferencePainter(); p.Font = Toolkit.CreateFrontend <Font>(this.Font); p.Bounds = this.Bounds.ToXwt(); p.SpeedTest(ctx, 0, 0); }
//Action<Context> icon = c => iconMethod.Invoke(font, new object[] { c }); //var ix = Expression.Constant(font); //var ic = Expression.Parameter(typeof(Context), "it"); //icon = Expression.Lambda<Action<Context>>( // Expression.Call(ix, iconMethod,ic), ic).Compile(); protected virtual void XwtSample(Xwt.Drawing.Context ctx) { var p = new ReferencePainter(); p.Font = Toolkit.CreateFrontend <Font>(this.Font); p.Bounds = this.Bounds.ToXwt(); p.All(ctx); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); var p = new ReferencePainter(); p.All(ctx); }
protected override void OnDraw(Android.Graphics.Canvas canvas) { base.OnDraw(canvas); canvas.DrawColor(Colors.White.ToDroid()); using (var ctx = canvas.XwtContext()) { var p = new ReferencePainter(); p.Font = this.Font; if (true) { p.Figures(ctx, 5, 5); p.Transforms(ctx, 5, 150); p.Texts(ctx, 5, 250); p.PatternsAndImages(ctx, 205, 5); } else { TestDrawing(ctx, 5, 5); } } }
private void Compose() { var panel1 = new System.Windows.Forms.Panel { Dock = DockStyle.Left, Width = 100 }; var htmlViewer = new HtmlContentViewer(); var browser = ((GeckoWebBrowserBackend)htmlViewer.Backend).Control; browser.Dock = DockStyle.Fill; htmlViewer.Clear(); Action <string, string> showInBrowser = (htmlstring, uri) => { var r = new WebResponse(); var s = new MemoryStream(); var writer = new StreamWriter(s); writer.Write(htmlstring); writer.Flush(); s.Position = 0; var content = new Content <Stream> (s, CompressionType.None, ContentTypes.HTML); content.ContentType = ContentTypes.HTML; r.AbsoluteUri = uri; htmlViewer.SetContent(r, content); }; //works, but throws some errors in GeckoWebBrowsre (Uristring too long) Action <string, string> showInBrowser1 = (htmlstring, uri) => { browser.LoadHtml(htmlstring); browser.WaitFor(() => !browser.IsBusy); }; var serverUri = htmlViewer.WebServer.Uri; var butt1 = new System.Windows.Forms.Button { Text = "Hello", Dock = DockStyle.Top }; butt1.Click += (s, e) => showInBrowser("<html><body> Hello world.............................................. </body></html>", serverUri + "helloworld.html"); var butt2 = new System.Windows.Forms.Button { Text = "static line", Dock = DockStyle.Top }; butt2.Click += (s, e) => showInBrowser(TestDataOne.SimpleLine, "http://localhost/simpleline"); var renderer = new Html5PageWriter { CanvasSize = new Size(1000, 2000) }; var butt3 = new System.Windows.Forms.Button { Text = "lineTest", Dock = DockStyle.Top }; Action <Context> linetest = ctx => { ctx.NewPath(); ctx.MoveTo(100, 150); ctx.LineTo(450, 50); ctx.Stroke(); }; butt3.Click += (s, e) => showInBrowser(renderer.Page(linetest), "http://localhost/LineTest"); var refPainter = new ReferencePainter(); var butt4 = new System.Windows.Forms.Button { Text = "Figures", Dock = DockStyle.Top }; Action <Context> Figures = ctx => { var x = 10; var y = 10; refPainter.Figures(ctx, 10, 10);; //refPainter.SimpleRectangles(ctx, x, y); //refPainter.RectangleWithHole(ctx, x+50, y); //refPainter.RoundetRectangle(ctx, x+120, y); //refPainter.Curves1(ctx, x, y + 60); //refPainter.Curves2(ctx, x + 100, y + 60); //refPainter.FontAwesome(ctx, 32, c => font.IconAdjust(c)); }; butt4.Click += (s, e) => showInBrowser(renderer.Page(Figures), "http://localhost/Figures"); var butt5 = new System.Windows.Forms.Button { Text = "Transforms", Dock = DockStyle.Top }; Action <Context> Transforms = ctx => { refPainter.Transforms(ctx, 10, 10); }; butt5.Click += (s, e) => showInBrowser(renderer.Page(Transforms), "http://localhost/Transforms"); var butt6 = new System.Windows.Forms.Button { Text = "Texts", Dock = DockStyle.Top }; Action <Context> Texts = ctx => { refPainter.Texts(ctx, 10, 10); }; butt6.Click += (s, e) => showInBrowser(renderer.Page(Texts), "http://localhost/Texts"); var butt7 = new System.Windows.Forms.Button { Text = "VisualScene", Dock = DockStyle.Top }; var maxExample = new SceneExamples().Examples.Count; var example = 0; Action <Context> VisualScene = ctx => { PaintScene(ctx, 10, 10, example++); if (example >= maxExample) { example = 0; } }; butt7.Click += (s, e) => showInBrowser(renderer.Page(VisualScene), "http://localhost/VisualScene"); panel1.Controls.AddRange(new[] { butt7, butt6, butt5, butt4, butt3, butt2, butt1, }); this.Controls.AddRange(new Control[] { browser, panel1 }); ClearResources(); ApplyResources(); refPainter.Font = Xwt.Drawing.Font.FromName("Default 10"); this.FormClosing += (s, e) => htmlViewer.Dispose(); }