// 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(); }
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(); }
/// <summary> /// Convert attribute of line join from a string. /// </summary> LineJoin ToLineJoin(string s, XmlInput xmlinput) { switch (s) { case "round": return(LineJoin.Round); case "sharp": return(LineJoin.Miter); default: xmlinput.BadXml("Invalid line end value '{0}'", s); return(LineJoin.Round); } }
/// <summary> /// Convert attribute of line cap from a string. /// </summary> LineCap ToLineCap(string s, XmlInput xmlinput) { switch (s) { case "round": return(LineCap.Round); case "flat": return(LineCap.Flat); default: xmlinput.BadXml("Invalid line end value '{0}'", s); return(LineCap.Round); } }
/// <summary> /// Read points array from XML. /// </summary> /// <returns></returns> PointF[] ReadPoints(XmlInput xmlinput) { List <PointF> points = new List <PointF>(); bool first = true; while (xmlinput.FindSubElement(first, new string[] { "point" })) { points.Add(new PointF(xmlinput.GetAttributeFloat("x"), xmlinput.GetAttributeFloat("y"))); xmlinput.Skip(); first = false; } return(points.ToArray()); }
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; } } }
/// <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(); }