private static void addTiledPropertiesToXTile(List <TiledProperty> tprops, IPropertyCollection xprops) { foreach (var tprop in tprops) { if (tprop.Type == TiledProperty.PropertyType.String) { xprops.Add(tprop.Name, tprop.Value); } else if (tprop.Type == TiledProperty.PropertyType.Float) { xprops.Add(tprop.Name, float.Parse(tprop.Value)); } else if (tprop.Type == TiledProperty.PropertyType.Int) { xprops.Add(tprop.Name, int.Parse(tprop.Value)); } else if (tprop.Type == TiledProperty.PropertyType.Bool) { xprops.Add(tprop.Name, bool.Parse(tprop.Value)); } else { Log.warn("Bad tilesheet tile property type: " + tprop.Type + " " + tprop.Name + " (not supported by xTile)"); } } }
/// <summary> /// Creates the section style. /// </summary> /// <param name="styleNode">The style node.</param> private void CreateSectionStyle(XmlNode styleNode) { SectionStyle sectionStyle = new SectionStyle(this._document, styleNode.CloneNode(true)); IPropertyCollection pCollection = new IPropertyCollection(); if (styleNode.HasChildNodes) { foreach (XmlNode node in styleNode.ChildNodes) { IProperty property = this.GetProperty(sectionStyle, node.CloneNode(true)); if (property != null) { pCollection.Add(property); } } } sectionStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { sectionStyle.PropertyCollection.Add(property); } if (!this._common) { this._document.Styles.Add(sectionStyle); } else { this._document.CommonStyles.Add(sectionStyle); } }
/// <summary> /// create chart floor style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> private FloorStyle CreateChartFloorStyle(XmlNode nodeStyle) { FloorStyle floorStyle = new FloorStyle(this.Chart.Document); floorStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(floorStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } floorStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { floorStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (floorStyle); return(floorStyle); }
/// <summary> /// create chart plotarea style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public PlotAreaStyle CreateChartPlotAreaStyle(XmlNode nodeStyle) { PlotAreaStyle plotareaStyle = new PlotAreaStyle(this.Chart.Document); plotareaStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(plotareaStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } plotareaStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { plotareaStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (plotareaStyle); return(plotareaStyle); }
/// <summary> /// create chart series style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> private SeriesStyle CreateChartSeriesStyle(XmlNode nodeStyle) { SeriesStyle seriesStyle = new SeriesStyle(this.Chart.Document, nodeStyle); seriesStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(seriesStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } seriesStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { seriesStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (seriesStyle); return(seriesStyle); }
/// <summary> /// create chart title style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public TitleStyle CreateChartTitleStyle(XmlNode nodeStyle) { TitleStyle titleStyle = new TitleStyle(this.Chart.Document); titleStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(titleStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } titleStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { titleStyle.PropertyCollection.Add(property); } return(titleStyle); }
/// <summary> /// create chart legend style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public LegendStyle CreateChartLegendStyle(XmlNode nodeStyle) { LegendStyle legendStyle = new LegendStyle(this.Chart.Document); legendStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(legendStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } legendStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { legendStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (legendStyle); return(legendStyle); }
/// <summary> /// Creates the section style. /// </summary> /// <param name="styleNode">The style node.</param> private void CreateSectionStyle(XElement styleNode) { SectionStyle sectionStyle = new SectionStyle(_document, new XElement(styleNode)); IPropertyCollection pCollection = new IPropertyCollection(); if (styleNode.HasElements) { foreach (XElement node in styleNode.Elements()) { IProperty property = GetProperty(sectionStyle, new XElement(node)); if (property != null) { pCollection.Add(property); } } } sectionStyle.Node.Value = ""; foreach (IProperty property in pCollection) { sectionStyle.PropertyCollection.Add(property); } if (!_common) { _document.Styles.Add(sectionStyle); } else { _document.CommonStyles.Add(sectionStyle); } }
/// <summary> /// create chart floor style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> private FloorStyle CreateChartFloorStyle(XElement nodeStyle) { FloorStyle floorStyle = new FloorStyle(Chart.Document) { Node = nodeStyle }; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasElements) { foreach (XElement nodeChild in nodeStyle.Elements()) { IProperty property = GetProperty(floorStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } floorStyle.Node.Value = ""; foreach (IProperty property in pCollection) { floorStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (floorStyle); return(floorStyle); }
/// <summary> /// create chart plotarea style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public PlotAreaStyle CreateChartPlotAreaStyle(XElement nodeStyle) { PlotAreaStyle plotareaStyle = new PlotAreaStyle(Chart.Document) { Node = nodeStyle }; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasElements) { foreach (XElement nodeChild in nodeStyle.Elements()) { IProperty property = GetProperty(plotareaStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } plotareaStyle.Node.Value = ""; foreach (IProperty property in pCollection) { plotareaStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (plotareaStyle); return(plotareaStyle); }
/// <summary> /// create chart legend style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public LegendStyle CreateChartLegendStyle(XElement nodeStyle) { LegendStyle legendStyle = new LegendStyle(Chart.Document) { Node = nodeStyle }; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasElements) { foreach (XElement nodeChild in nodeStyle.Elements()) { IProperty property = GetProperty(legendStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } legendStyle.Node.Value = ""; foreach (IProperty property in pCollection) { legendStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (legendStyle); return(legendStyle); }
/// <summary> /// create chart title style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> public TitleStyle CreateChartTitleStyle(XElement nodeStyle) { TitleStyle titleStyle = new TitleStyle(Chart.Document) { Node = nodeStyle }; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasElements) { foreach (XElement nodeChild in nodeStyle.Elements()) { IProperty property = GetProperty(titleStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } titleStyle.Node.Value = ""; foreach (IProperty property in pCollection) { titleStyle.PropertyCollection.Add(property); } return(titleStyle); }
public static IPropertyCollection AddOrReplace(this IPropertyCollection t, string key, string value) { if (!t.ContainsKey(key)) { t.Add(key, value); } else { t[key] = value; } return(t); }
internal static void ReadXml(IPropertyCollection collection, XmlReader reader) { if (reader == null) { throw new ArgumentNullException(); } reader.ReadStartElement(); int depth = reader.Depth; reader.MoveToContent(); while (reader.Depth == depth) { string name = reader.LocalName; string value = reader.ReadElementString(); collection.Add(name, value); reader.MoveToContent(); } }