Ejemplo n.º 1
0
        public static ProjImage ParseBody(XmlElement body)
        {
            RainbowDrawer drawer = new RainbowDrawer();

            foreach (var c in body.ChildNodes)
            {
                var proj = c as XmlElement;
                switch (proj.Name)
                {
                case "line":
                    drawer.DrawLine(ParseMPointF(proj.Attributes["start"].InnerText), ParseMPointF(proj.Attributes["end"].InnerText));
                    break;

                case "point":
                    drawer.DrawPoint(ParseMPointF(proj.Attributes["location"].InnerText), Convert.ToSingle(proj.Attributes["direction"].InnerText, CultureInfo.InvariantCulture));
                    break;

                case "arc":
                    drawer.DrawArc(ParseMPointF(proj.Attributes["center"].InnerText),
                                   Convert.ToSingle(proj.Attributes["radius"].InnerText, CultureInfo.InvariantCulture),
                                   Convert.ToSingle(proj.Attributes["start_radian"].InnerText, CultureInfo.InvariantCulture),
                                   Convert.ToSingle(proj.Attributes["end_radian"].InnerText, CultureInfo.InvariantCulture));
                    break;

                case "arcf":
                    drawer.DrawArc(ParseMPointF(proj.Attributes["center"].InnerText),
                                   Convert.ToSingle(proj.Attributes["radius"].InnerText, CultureInfo.InvariantCulture),
                                   (float)Math.PI * Convert.ToSingle(proj.Attributes["start_radian_factor"].InnerText, CultureInfo.InvariantCulture),
                                   (float)Math.PI * Convert.ToSingle(proj.Attributes["end_radian_factor"].InnerText, CultureInfo.InvariantCulture));
                    break;

                default:
                    break;
                }
            }
            return(drawer.Image);
        }
Ejemplo n.º 2
0
 public RainbowTextDrawer(RainbowDrawer sourceDrawer, Dictionary <char, ProjImage> Characters)
 {
     SourceDrawer      = sourceDrawer ?? throw new ArgumentNullException(nameof(sourceDrawer));
     DefinedCharacters = Characters ?? new Dictionary <char, ProjImage>();
 }