Esempio n. 1
0
        public static fp_text Parse(SNodeBase node)
        {
            fp_text result = new fp_text();

            if ((node is SExpression) && ((node as SExpression).Name == "fp_text"))
            {
                SExpression expr = node as SExpression;

                result.Type  = (expr.Items[0] as SNodeAtom).Value;
                result.Value = (expr.Items[1] as SNodeAtom).Value;

                int index = 2;

                while (index < expr.Items.Count)
                {
                    if (expr.Items[index] is SExpression)
                    {
                        SExpression sub = expr.Items[index] as SExpression;
                        if (sub.Name == "at")
                        {
                            result.position = Position.Parse(sub);
                        }
                        else if (sub.Name == "effects")
                        {
                            result.effects = TextEffects.Parse(sub);
                        }
                        else if (sub.Name == "layer")
                        {
                            result.layer = Layer.ParseLayer(sub);
                        }
                    }
                    else
                    {
                        SNodeAtom atom = expr.Items[index] as SNodeAtom;

                        if (atom.Value == "hide")
                        {
                            result.visible = false;
                        }
                    }

                    index++;
                }
                return(result);
            }
            else
            {
                return(null);  // error
            }
        }
Esempio n. 2
0
        //
        public static TextEffects Parse(SNodeBase node)
        {
            if ((node is SExpression) && ((node as SExpression).Name == "effects"))
            {
                SExpression expr   = node as SExpression;
                TextEffects result = new TextEffects();

                int index = 0;
                while (index < expr.Items.Count)
                {
                    SExpression sexpr = expr.Items[index] as SExpression;

                    // justify: horiz_align, mirror
                    switch (sexpr.Name)
                    {
                    case "font":
                        result.font = FontAttributes.Parse(expr.Items[0] as SExpression);
                        break;

                    case "justify":
                        foreach (SNodeBase s2 in sexpr.Items)
                        {
                            if (s2 is SNodeAtom)
                            {
                                SNodeAtom atom = s2 as SNodeAtom;
                                switch (atom.Value)
                                {
                                case "mirror":
                                    result.mirror = true;
                                    break;

                                case "left":
                                    result.horiz_align = TextJustify.left;
                                    break;

                                case "right":
                                    result.horiz_align = TextJustify.right;
                                    break;

                                case "top":
                                    result.vert_align = VerticalAlign.top;
                                    break;

                                case "bottom":
                                    result.vert_align = VerticalAlign.bottom;
                                    break;
                                }
                            }
                        }
                        break;
                    }

                    index++;
                }

                return(result);
            }
            else
            {
                return(null);  // error
            }
        }