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); } }
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); }
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; } }
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); }
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; } }