Пример #1
0
 internal ResourceTypeIconConfiguration(XmlNode node)
 {
     _resType = XmlTools.GetRequiredAttribute(node, "type");
     foreach (XmlNode iconNode in node.SelectNodes("icon"))
     {
         ResourceIconInstance iconInstance = new ResourceIconInstance(iconNode);
         AddIconInstance(iconInstance);
     }
     foreach (XmlNode overlayNode in node.SelectNodes("overlay"))
     {
         ResourceIconInstance iconInstance = new ResourceIconInstance(overlayNode);
         _overlayIconInstances.Add(iconInstance);
     }
 }
Пример #2
0
 internal string GetResourceIconName(IResource res)
 {
     for (int i = 0; i < _condIconInstances.Count; i++)
     {
         ResourceIconInstance instance = (ResourceIconInstance)_condIconInstances [i];
         if (instance.MatchResource(res))
         {
             return(instance._name);
         }
     }
     if (_uncondIconInstance != null)
     {
         return(_uncondIconInstance._name);
     }
     return(null);
 }
Пример #3
0
        private Hashtable _iconMap         = new Hashtable();  // icon name -> icon

        public ConfigurableIconProvider(Assembly pluginAssembly, XmlNode node)
        {
            _pluginAssembly = pluginAssembly;
            XmlAttribute attrNS = node.Attributes ["namespace"];

            _defaultNamespace = (attrNS == null) ? "" : attrNS.Value;

            foreach (XmlNode typeNode in node.SelectNodes("icons"))
            {
                ResourceTypeIconConfiguration cfg = new ResourceTypeIconConfiguration(typeNode);
                _resourceTypeMap [cfg._resType] = cfg;
            }

            // shortcut for resource types which have only one icon
            foreach (XmlNode iconNode in node.SelectNodes("icon"))
            {
                ResourceTypeIconConfiguration cfg      = new ResourceTypeIconConfiguration(iconNode);
                ResourceIconInstance          instance = new ResourceIconInstance(iconNode);
                cfg.AddIconInstance(instance);
                _resourceTypeMap [cfg._resType] = cfg;
            }
        }
Пример #4
0
            internal string[] GetOverlayIconNames(IResource res)
            {
                ArrayList result = null;

                for (int i = 0; i < _overlayIconInstances.Count; i++)
                {
                    ResourceIconInstance instance = (ResourceIconInstance)_overlayIconInstances [i];
                    if (instance.MatchResource(res))
                    {
                        if (result == null)
                        {
                            result = new ArrayList();
                        }
                        result.Add(instance._name);
                    }
                }
                if (result != null)
                {
                    return((string[])result.ToArray(typeof(string)));
                }
                return(null);
            }
Пример #5
0
 internal void AddIconInstance(ResourceIconInstance iconInstance)
 {
     if (iconInstance._conditions.Count == 0)
     {
         if (_uncondIconInstance != null)
         {
             throw new Exception("There can be only one icon with no conditions for a resource type");
         }
         _uncondIconInstance = iconInstance;
     }
     else
     {
         _condIconInstances.Add(iconInstance);
     }
     if (iconInstance._isDefault)
     {
         if (_defaultIconInstance != null)
         {
             throw new Exception("There can be only one default icon for a resource type");
         }
         _defaultIconInstance = iconInstance;
     }
 }