Exemplo n.º 1
0
        static ControlInfo()
        {
            // parse control descriptions from xml
            XElement elem      = XDocument.Load(SAMPLE_TREE).Root;
            int      pageIndex = 0;

            Controls = new List <ControlInfo>();
            foreach (XElement controlNode in elem.Descendants("control").ToList())
            {
                ControlInfo control = new ControlInfo();
                if (controlNode.Attribute("name") != null)
                {
                    control.Name = controlNode.Attribute("name").Value;
                }
                if (controlNode.Attribute("link") != null)
                {
                    control.Link = controlNode.Attribute("link").Value;
                }
                if (controlNode.Attribute("tooltip") != null)
                {
                    control.Tooltip = controlNode.Attribute("tooltip").Value;
                }
                if (controlNode.Attribute("group") != null)
                {
                    control.Group = controlNode.Attribute("group").Value;
                }
                if (controlNode.Attribute("status") != null)
                {
                    foreach (string val in controlNode.Attribute("status").Value.Split(','))
                    {
                        switch (val)
                        {
                        case "new":
                            control.IsNew = true;
                            break;

                        case "popular":
                            control.IsPopular = true;
                            break;
                        }
                    }
                }
                else
                {
                    control.IsNew     = false;
                    control.IsPopular = false;
                }
                if (controlNode.Attribute("newFeatureName") != null)
                {
                    control.NewFeatureName = controlNode.Attribute("newFeatureName").Value;
                }

                /*      // todo: we have it in xml, but currently it is not used
                 *      if (controlNode.Attribute("icon") != null)
                 *      {
                 *          string icon = controlNode.Attribute("icon").Value;
                 *          if (_icons.ContainsKey(icon))
                 *          {
                 *              control.Icon = _icons[icon].Image;
                 *          }
                 *      }
                 *      if (control.Icon == null)
                 *      {
                 *          if (!_icons.ContainsKey(control.Name))
                 *          {
                 *              _icons.Add(control.Name, Properties.Resources.ci_Empty); // Default empty icon for new stuff
                 *          }
                 *          control.Icon = _icons[control.Name].Image;
                 *      }*/
                control.Features = new List <FeatureInfo>();
                foreach (XElement node in controlNode.Elements())
                {
                    if (node.Name == "sample")
                    {
                        SampleInfo sample = ReadSampleData(node);
                        control.Features.Add(sample);
                    }
                    else if (node.Name == "category")
                    {
                        CategoryInfo category = ReadCategoryData(node);
                        if (category.Samples.Count > 0)
                        {
                            control.Features.Add(category);
                        }
                    }
                }
                ControlInfo.Controls.Add(control);
                pageIndex++;
            }
        }