public void It_should_render_rounded_panels() { var renderer = new BitmapRenderer(); var vbox = new HBox(); var borders = new[] { new [] { "10 0 0 0", "0 10 0 0", "0 0 10 0", "0 0 0 10" }, new [] { "10 10 0 0", "10 0 10 0", "10 0 0 10", "0 0 10 10" }, new [] { "10 10 10 0", "10 0 10 10", "10 10 0 10", "10 10 10 10" } }; foreach (var boxLine in borders) { var hbox = new HBox(); foreach (var border in boxLine) { hbox.AddComponent(new Panel { Margin = new Spacer(1), BackgroundColor = Color.Blue, Width = 22, Height = 22, BorderRadius = BorderRadius.Parse(border) }); } vbox.AddComponent(hbox); } var bmp = new Bitmap(300, 40); renderer.Render(new Form(vbox), bmp); BitmapComparer.CompareBitmaps("panels_rounded", bmp); }
public void Parse_should_properly_parse_the_border_radius() { BorderRadius.Parse("").ShouldBe(BorderRadius.None); BorderRadius.Parse("10").ShouldBe(new BorderRadius(10)); BorderRadius.Parse("15 20").ShouldBe(new BorderRadius(15, 20)); BorderRadius.Parse("15 20 30 40").ShouldBe(new BorderRadius(15, 20, 30, 40)); BorderRadius.Parse(" 15 20 30 40 ").ShouldBe(new BorderRadius(15, 20, 30, 40)); Assert.Throws <ArgumentException>(() => BorderRadius.Parse("x")).Message.ShouldStartWith("Provided value is not a valid BorderRadius: x"); Assert.Throws <ArgumentException>(() => BorderRadius.Parse("10 20 30")).Message.ShouldStartWith("Provided value is not a valid BorderRadius: 10 20 30"); }
public void It_should_render_rounded_panels_with_borders() { var renderer = new PdfRenderer(); var vbox = new VBox(); var borders = new[] { new [] { "10 0 0 0", "0 10 0 0", "0 0 10 0", "0 0 0 10" }, new [] { "10 10 0 0", "10 0 10 0", "10 0 0 10", "0 0 10 10" }, new [] { "10 10 10 0", "10 0 10 10", "10 10 0 10", "10 10 10 10" } }; foreach (var boxLine in borders) { var hbox = new HBox(); foreach (var border in boxLine) { hbox.AddComponent(new Panel { Margin = new Spacer(1), BackgroundColor = Color.Orange, Width = 24, Height = 24, Border = Border.Parse("1 black"), BorderRadius = BorderRadius.Parse(border) }); } vbox.AddComponent(hbox); } var doc = new PdfDocument(); var page = doc.AddPage(); renderer.Render(new Form(vbox), page, new PdfRendererOptions { AdjustPageSize = true }); PdfImageComparer.ComparePdfs("panels_rounded_border", doc); }
public void It_should_render_viewports() { var renderer = new PdfRenderer(); var stack = new Stack(); stack.AddComponent(new Panel { Width = 100, Height = 100, Border = Border.Parse("1 #808080"), BackgroundColor = Color.LightBlue, BorderRadius = BorderRadius.Parse("25") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center left"), Width = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center right") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("top center"), Height = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("bottom center") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center right"), Width = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center left") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("bottom center"), Height = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("top center") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center center"), ClipMargin = Spacer.Parse("3 1"), Inner = new Panel { Width = 40, Height = 40, BackgroundColor = Color.White, Border = Border.Parse("1 #808080"), BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center center") }); var form = new Form(stack); var doc = new PdfDocument(); renderer.Render(form, doc.AddPage(), new PdfRendererOptions { AdjustPageSize = true }); PdfImageComparer.ComparePdfs("viewport", doc); }
public void It_should_render_viewports() { var renderer = new BitmapRenderer(); var stack = new Stack(); stack.AddComponent(new Panel { Width = 100, Height = 100, Border = Border.Parse("1 #808080"), BackgroundColor = Color.LightBlue, BorderRadius = BorderRadius.Parse("25") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center left"), Width = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center right") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("top center"), Height = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("bottom center") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center right"), Width = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center left") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("bottom center"), Height = 10, Inner = new Panel { Width = 40, Height = 40, Border = Border.Parse("1 #808080"), BackgroundColor = Color.White, BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("top center") }); stack.AddComponent(new Viewport { Alignment = Alignment.Parse("center center"), ClipMargin = Spacer.Parse("3 1"), Inner = new Panel { Width = 40, Height = 40, BackgroundColor = Color.White, Border = Border.Parse("1 #808080"), BorderRadius = BorderRadius.Parse("20") }, ContentAlignment = Alignment.Parse("center center") }); var form = new Form(stack); var bmp = renderer.Render(form); BitmapComparer.CompareBitmaps("viewport", bmp); }