Example #1
0
 public Rectangle CalculateSafeArea(Rectangle parentBoundaries,IStylingRule style, AlignmentContext context)
 {
     var width = style.Width ?? parentBoundaries.Width;
     var height = style.Height ?? parentBoundaries.Height;
     var safeArea =  new Rectangle(
        parentBoundaries.X + (parentBoundaries.Width - context.XAxis.SpaceAvailable)
        , parentBoundaries.Y + (parentBoundaries.Height - context.YAxis.SpaceAvailable)
        , width
        , height);
     return safeArea;
 }
Example #2
0
        public void RenderElement(INode<IGuiElement> element, INode<IGuiElement> parent)
        {
            var elementStyle = styleProvider(element.Data);
            alignmentContext = (previousParent == parent) ?
                alignmentContext : CalculateAlignmentContext(element);

            var renderRectangle = elementStyle.Alignment.CalculateSafeArea(parent.Data.OccupiedScreenRectangle, elementStyle, alignmentContext);
            element.Data.OccupiedScreenRectangle = renderRectangle;

            renderContext.SafeArea =
                     new Rectangle(0, 0, renderRectangle.Width, renderRectangle.Height);

            RenderInSafeArea(renderRectangle, () => element.Data.Render(renderContext, elementStyle));
            elementStyle.Border.Render(renderContext);
            alignmentContext.Update(element.Data);
        }