public void LoadDataFromXMLDocument(string filename) { Microsoft.Xna.Framework.Graphics.Color color; Font font; XmlDocument document = new XmlDocument(); document.Load(filename); XmlNode nextSibling = document.FirstChild.NextSibling; XmlNode node = nextSibling.ChildNodes.Item(0); this.numberInputer.BackgroundTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.BackgroundSize.X = int.Parse(node.Attributes.GetNamedItem("Width").Value); this.numberInputer.BackgroundSize.Y = int.Parse(node.Attributes.GetNamedItem("Height").Value); node = nextSibling.ChildNodes.Item(1); StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color); this.numberInputer.RangeText = new FreeText(this.graphicsDevice, font, color); this.numberInputer.RangeText.Position = StaticMethods.LoadRectangleFromXMLNode(node); this.numberInputer.RangeText.Align = (TextAlign)Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value); node = nextSibling.ChildNodes.Item(2); this.numberInputer.FrameTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.FramePosition = StaticMethods.LoadRectangleFromXMLNode(node); StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color); this.numberInputer.FrameText = new FreeText(this.graphicsDevice, font, color); this.numberInputer.FrameText.Position = this.numberInputer.FramePosition; this.numberInputer.FrameText.Align = (TextAlign)Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value); node = nextSibling.ChildNodes.Item(3); foreach (XmlNode node3 in node.ChildNodes) { NumberInputerPlugin.Number item = new NumberInputerPlugin.Number { Position = StaticMethods.LoadRectangleFromXMLNode(node3), Num = int.Parse(node3.Attributes.GetNamedItem("Num").Value), Texture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node3.Attributes.GetNamedItem("FileName").Value) }; this.numberInputer.Numbers.Add(item); } node = nextSibling.ChildNodes.Item(4); this.numberInputer.ClearTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.ClearPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(5); this.numberInputer.EnterTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.EnterPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(6); this.numberInputer.BackspaceTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.BackspacePosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(7); this.numberInputer.MaxTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.MaxPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(8); this.numberInputer.ExitTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.ExitPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(9); this.numberInputer.SelectionTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); }
public void LoadDataFromXMLDocument(string filename) { Microsoft.Xna.Framework.Graphics.Color color; Font font; XmlDocument document = new XmlDocument(); document.Load(filename); XmlNode nextSibling = document.FirstChild.NextSibling; XmlNode node = nextSibling.ChildNodes.Item(0); this.numberInputer.BackgroundTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.BackgroundSize.X = int.Parse(node.Attributes.GetNamedItem("Width").Value); this.numberInputer.BackgroundSize.Y = int.Parse(node.Attributes.GetNamedItem("Height").Value); node = nextSibling.ChildNodes.Item(1); StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color); this.numberInputer.RangeText = new FreeText(this.graphicsDevice, font, color); this.numberInputer.RangeText.Position = StaticMethods.LoadRectangleFromXMLNode(node); this.numberInputer.RangeText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value); node = nextSibling.ChildNodes.Item(2); this.numberInputer.FrameTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.FramePosition = StaticMethods.LoadRectangleFromXMLNode(node); StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color); this.numberInputer.FrameText = new FreeText(this.graphicsDevice, font, color); this.numberInputer.FrameText.Position = this.numberInputer.FramePosition; this.numberInputer.FrameText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value); node = nextSibling.ChildNodes.Item(3); foreach (XmlNode node3 in node.ChildNodes) { NumberInputerPlugin.Number item = new NumberInputerPlugin.Number { Position = StaticMethods.LoadRectangleFromXMLNode(node3), Num = int.Parse(node3.Attributes.GetNamedItem("Num").Value), Texture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node3.Attributes.GetNamedItem("FileName").Value) }; this.numberInputer.Numbers.Add(item); } node = nextSibling.ChildNodes.Item(4); this.numberInputer.ClearTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.ClearPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(5); this.numberInputer.EnterTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.EnterPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(6); this.numberInputer.BackspaceTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.BackspacePosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(7); this.numberInputer.MaxTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.MaxPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(8); this.numberInputer.ExitTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); this.numberInputer.ExitPosition = StaticMethods.LoadRectangleFromXMLNode(node); node = nextSibling.ChildNodes.Item(9); this.numberInputer.SelectionTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\NumberInputer\Data\" + node.Attributes.GetNamedItem("FileName").Value); }