コード例 #1
0
ファイル: SymbolDB.cs プロジェクト: osorensen/PurplePen
        // Read the state of this language from XML.
        public void ReadXml(XmlInput xmlinput)
        {
            xmlinput.CheckElement("language");

            this.LangId          = xmlinput.GetAttributeString("lang");
            this.PluralNouns     = xmlinput.GetAttributeBool("plural-nouns", false);
            this.PluralModifiers = xmlinput.GetAttributeBool("plural-modifiers", false);
            this.GenderModifiers = xmlinput.GetAttributeBool("gender-modifiers", false);
            this.CaseModifiers   = xmlinput.GetAttributeBool("case-modifiers", false);

            string genders = xmlinput.GetAttributeString("genders", "");

            if (genders != "")
            {
                this.Genders = genders.Split(new char[] { ',' });
            }

            string cases = xmlinput.GetAttributeString("cases", "");

            if (cases != "")
            {
                this.Cases = cases.Split(new char[] { ',' });
            }

            this.Name = xmlinput.GetContentString();
        }
コード例 #2
0
ファイル: SymbolDB.cs プロジェクト: osorensen/PurplePen
        private void ReadSymbolFile(string filename)
        {
            int sortOrder = 1;

            using (XmlInput xmlinput = new XmlInput(filename)) {
                xmlinput.CheckElement("symbols");

                bool first = true;
                while (xmlinput.FindSubElement(first, new string[] { "symbol", "language" }))
                {
                    if (xmlinput.Name == "symbol")
                    {
                        Symbol symbol = new Symbol(this, sortOrder);
                        ++sortOrder;

                        symbol.ReadXml(xmlinput);

                        if (symbols.ContainsKey(symbol.Id))
                        {
                            symbols[symbol.Id].Add(symbol);
                        }
                        else
                        {
                            symbols[symbol.Id] = new List <Symbol>()
                            {
                                symbol
                            };
                        }
                    }
                    else if (xmlinput.Name == "language")
                    {
                        SymbolLanguage language = new SymbolLanguage();

                        language.ReadXml(xmlinput);
                        languages.Add(language.LangId, language);
                    }

                    first = false;
                }
            }
        }
コード例 #3
0
ファイル: SymbolDB.cs プロジェクト: osorensen/PurplePen
        /// <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.id2018        = xmlinput.GetAttributeString("id-2018", 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();
        }