Exemplo n.º 1
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            renderingContext.PushTransform(Transform);

            switch (Character)
            {
            case Shape s:
                var geometry = Context.GetGeometry(s.Geometry, Character);
                if (RenderCallback != null)
                {
                    RenderCallback(renderingContext, geometry, Texture);
                }
                else
                {
                    renderingContext.RenderGeometry(geometry, Texture);
                }

                if (Highlight)
                {
                    renderingContext.RenderOutline(geometry);
                }
                break;

            case Text t:
                renderingContext.RenderText(t, TextValue.Localized);
                break;
            }

            renderingContext.PopTransform();
        }
Exemplo n.º 2
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            renderingContext.PushTransform(Transform);

            switch (Character)
            {
            case Shape s:
                var geometry = Context.GetGeometry(s.Geometry, Character);
                if (RenderCallback != null)
                {
                    RenderCallback(renderingContext, geometry, Texture);
                }
                else
                {
                    renderingContext.RenderGeometry(geometry, Texture);
                }

                if (Highlight)
                {
                    renderingContext.RenderOutline(geometry);
                }
                break;

            case Text t:
                if (t.Value.Length > 0)
                {
                    var val = ScriptObject.ResolveValue(t.Value, ScriptObject);
                    if (val.Type != ValueType.Undefined)
                    {
                        t.Content = val.ToString();
                    }
                }

                //localize our content
                t.Content = t.Content.Replace("$", "APT:");     // All string values begin with $
                t.Content = t.Content.Split('&').First();       // Query strings after ampersand
                t.Content = t.Content.Translate();

                renderingContext.RenderText(t);
                break;
            }

            renderingContext.PopTransform();
        }
Exemplo n.º 3
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            //calculate the transform for this element
            renderingContext.PushTransform(Transform);

            var clipMask  = (Texture)null;
            var clipDepth = 0;

            //render all subItems
            foreach (var(depth, item) in Content.Items)
            {
                item.Render(renderingContext);

                if (depth > clipDepth && clipMask != null)
                {
                    renderingContext.SetClipMask(null);
                    clipDepth = 0;
                }

                if (item.ClipDepth != null)
                {
                    renderingContext.SetClipMask(item.ClipMask);
                    clipDepth = item.ClipDepth.Value;
                }
            }

            // In case the clipMask wans't cleared inside the loop
            if (clipDepth > 0)
            {
                renderingContext.SetClipMask(null);
            }
            renderingContext.PopTransform();
        }