Example #1
0
    public static Color AsColor(this UssValue v)
    {
        v = v.Unwrap();

        if (v.GetType() == typeof(UssColorValue))
        {
            return(((UssColorValue)v).value);
        }
        if (v.GetType() == typeof(UssStringValue))
        {
            var str = v.AsString();
            if (str == "black")
            {
                return(Color.black);
            }
            else if (str == "green")
            {
                return(Color.green);
            }
            else if (str == "red")
            {
                return(Color.red);
            }
            else if (str == "blue")
            {
                return(Color.blue);
            }
        }

        throw new InvalidOperationException("Value cannot be color: " + v.GetType());
    }
Example #2
0
    public void ApplyOverflowY(Text obj, UssValue value)
    {
        var v = value.AsString();

        if (v == "visible")
        {
            obj.verticalOverflow = VerticalWrapMode.Overflow;
        }
        else if (v == "hidden")
        {
            obj.verticalOverflow = VerticalWrapMode.Truncate;
        }
    }
Example #3
0
    public void ApplyVisibility(Graphic g, UssValue value)
    {
        var keywd = value.AsString();

        if (keywd == "visible")
        {
            g.enabled = true;
        }
        else
        {
            g.enabled = false;
        }
    }
Example #4
0
    public void ApplyOverflowX(Text obj, UssValue value)
    {
        var v = value.AsString();

        if (v == "visible")
        {
            obj.horizontalOverflow = HorizontalWrapMode.Overflow;
        }
        else if (v == "wrap")
        {
            obj.horizontalOverflow = HorizontalWrapMode.Wrap;
        }
    }
Example #5
0
    public void ApplyFontStyle(Text g, UssValue value)
    {
        var style = value.AsString();

        if (style == "normal")
        {
            g.fontStyle = FontStyle.Normal;
        }
        else if (style == "bold")
        {
            g.fontStyle = FontStyle.Bold;
        }
        else if (style == "italic")
        {
            g.fontStyle = FontStyle.Italic;
        }
    }