PurplePen.SymbolText.ReadXml C# (CSharp) Method

ReadXml() public method

public ReadXml ( XmlInput xmlinput ) : void
xmlinput XmlInput
return void
        public void ReadXml(XmlInput xmlinput)
        {
            this.Lang = xmlinput.GetAttributeString("lang");
            this.Plural = xmlinput.GetAttributeBool("plural", false);
            this.Gender = xmlinput.GetAttributeString("gender", "");
            this.Case = xmlinput.GetAttributeString("case", "");
            this.CaseOfModified = xmlinput.GetAttributeString("modified-case", "");
            this.Text = xmlinput.GetContentString();
        }

Usage Example

Example #1
0
        /// <summary>
        /// Read the state of this symbol from XML. The xmlinput must be on a
        /// symbol node.
        /// </summary>
        public void ReadXml(XmlInput xmlinput)
        {
            xmlinput.CheckElement("symbol");

            this.kind          = xmlinput.GetAttributeString("kind")[0];
            this.id            = xmlinput.GetAttributeString("id");
            this.replacementId = xmlinput.GetAttributeString("replacement-id", null);
            this.sizeIsDepth   = xmlinput.GetAttributeBool("size-is-depth", false);

            string standardStrings = xmlinput.GetAttributeString("standard", "");

            if (standardStrings != "")
            {
                this.standards = standardStrings.Split(',');
            }

            bool first = true;
            List <SymbolStroke> strokes = new List <SymbolStroke>();

            while (xmlinput.FindSubElement(first, new string[] { "name", "text", "filled-circle", "circle", "polygon", "filled-polygon", "lines", "beziers", "filled-beziers" }))
            {
                SymbolStroke stroke   = new SymbolStroke();
                bool         isStroke = true;

                switch (xmlinput.Name)
                {
                case "name":
                    xmlinput.CheckElement("name");
                    string language = xmlinput.GetAttributeString("lang");
                    name.Add(language, xmlinput.GetContentString());
                    isStroke = false;
                    break;

                case "text":
                    xmlinput.CheckElement("text");
                    SymbolText symtext = new SymbolText();
                    symtext.ReadXml(xmlinput);
                    texts.Add(symtext);
                    isStroke = false;
                    break;

                case "filled-circle":
                    xmlinput.CheckElement("filled-circle");
                    stroke.kind   = SymbolStrokes.Disc;
                    stroke.radius = xmlinput.GetAttributeFloat("radius");
                    break;

                case "circle":
                    xmlinput.CheckElement("circle");
                    stroke.kind      = SymbolStrokes.Circle;
                    stroke.thickness = xmlinput.GetAttributeFloat("thickness");
                    stroke.radius    = xmlinput.GetAttributeFloat("radius");
                    break;

                case "polygon":
                    xmlinput.CheckElement("polygon");
                    stroke.kind      = SymbolStrokes.Polygon;
                    stroke.thickness = xmlinput.GetAttributeFloat("thickness");
                    stroke.corners   = ToLineJoin(xmlinput.GetAttributeString("corners", "round"), xmlinput);
                    break;

                case "filled-polygon":
                    xmlinput.CheckElement("filled-polygon");
                    stroke.kind = SymbolStrokes.FilledPolygon;
                    break;

                case "lines":
                    xmlinput.CheckElement("lines");
                    stroke.kind      = SymbolStrokes.Polyline;
                    stroke.thickness = xmlinput.GetAttributeFloat("thickness");
                    stroke.ends      = ToLineCap(xmlinput.GetAttributeString("ends", "round"), xmlinput);
                    stroke.corners   = ToLineJoin(xmlinput.GetAttributeString("corners", "round"), xmlinput);
                    break;

                case "beziers":
                    xmlinput.CheckElement("beziers");
                    stroke.kind      = SymbolStrokes.PolyBezier;
                    stroke.thickness = xmlinput.GetAttributeFloat("thickness");
                    stroke.ends      = ToLineCap(xmlinput.GetAttributeString("ends", "round"), xmlinput);
                    break;

                case "filled-beziers":
                    xmlinput.CheckElement("filled-beziers");
                    stroke.kind = SymbolStrokes.FilledPolyBezier;
                    break;
                }

                if (isStroke)
                {
                    stroke.points = ReadPoints(xmlinput);
                    strokes.Add(stroke);
                }

                first = false;
            }

            if (this.name == null)
            {
                xmlinput.BadXml("Missing name element");
            }
            if (texts.Count == 0)
            {
                xmlinput.BadXml("Missing text element");
            }

            this.strokes = strokes.ToArray();
        }
All Usage Examples Of PurplePen.SymbolText::ReadXml