예제 #1
0
        public RenderFragment Render() => builder =>
        {
            int seq = -1;

            builder.OpenElement(++seq, "div");
            builder.AddAttribute(++seq, "class", _classes);

            ++seq;
            if (_maxWidth != null)
            {
                builder.AddAttribute(seq, "style", $"max-width: {_maxWidth.Invoke()}px;");
            }

            if (_doHighlight)
            {
                builder.OpenComponent <TriggerWrapper>(++seq);
                builder.AddAttribute(++seq, "Trigger", _locationChangedTrigger);
                builder.AddAttribute(++seq, "ChildContent",
                                     new RenderFragment(b => b.AddContent(++seq, _layout.Render())));
                builder.CloseComponent();
            }
            else
            {
                builder.AddContent(++seq, _layout.Render());
            }

            builder.CloseElement();
        };
예제 #2
0
        public void RendersItsChildren()
        {
            var t1           = Substitute.For <GUIWidget>();
            var t2           = Substitute.For <GUIWidget>();
            var t3           = Substitute.For <GUIWidget>();
            var fakeRenderer = Substitute.For <RenderSystem>();

            var layout = new LinearLayout(LayoutDirection.Horizontal, Vector2.Zero, Vector2f.Center);

            layout.Add(t1);
            layout.Add(t2);
            layout.Add(t3);
            layout.Render(fakeRenderer);

            fakeRenderer.Received().Render(t1);
            fakeRenderer.Received().Render(t2);
            fakeRenderer.Received().Render(t3);
        }