Exemplo n.º 1
0
        public static TileGroup FromXml(XmlNode configNode, string resourceFolderPath)
        {
            var config = new TileGroup();

            config.Title     = configNode.SelectSingleNode("./Title")?.InnerText;
            config.ForeColor = ColorTranslator.FromHtml(configNode.SelectSingleNode("./ForeColor")?.InnerText);
            config.Font      = TileConfiguration.ParseFontConfiguration(configNode.SelectSingleNode("./Font"));
            config.Padding   = TileConfiguration.ParsePaddingConfiguration(configNode.SelectSingleNode("./Padding"));

            var itemNodes = configNode.SelectNodes("./Item")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { };

            foreach (var itemNode in itemNodes)
            {
                config.Items.Add(TileItem.FromXml(itemNode, resourceFolderPath));
            }

            return(config);
        }
Exemplo n.º 2
0
        public static TileConfiguration FromFile(string configFilePath)
        {
            var config = new TileConfiguration();

            var resourceFolderPath = Path.Combine(Path.GetDirectoryName(configFilePath), "Resources");

            var document = new XmlDocument();

            document.Load(configFilePath);

            var groupNodes = document.SelectNodes("//Config/Tiles/Group")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { };

            foreach (var groupNode in groupNodes)
            {
                config.Groups.Add(TileGroup.FromXml(groupNode, resourceFolderPath));
            }

            return(config);
        }