Ejemplo n.º 1
0
        public void AddNewComponent(ZComponent comp)
        {
            Type type = comp.GetType();
            // Do NOT register ZApplication and its derived classes
            if (typeof(ZApplication).IsAssignableFrom(type)) return;
            allComponents.Add(comp);
            // Store the name in the name cache
            if (comp.HasName()) nameCache[comp.Name] = comp;

            // TODO: consider all ancestor types
            if (!typeMap.ContainsKey(type))
                typeMap[type] = new HashSet<ZComponent>();            
             typeMap[type].Add(comp);
        }
Ejemplo n.º 2
0
 public void RefreshName(ZComponent comp, string name, string oldName)
 {
     if (oldName != null)
         nameCache.Remove(oldName);
     // Remove the component from the nameMap - if necessary
     foreach (var item in nameCache.Where(kvp => kvp.Value == comp).ToList())
     {
         nameCache.Remove(item.Key);
     }
     if (comp.HasName())
         nameCache[comp.Name] = comp;
 }
Ejemplo n.º 3
0
        private void AddElementToTree(ZComponent component, TreeNodeCollection nodes)
        {
            //  Add the element.
            TreeNode newNode = new TreeNode()
            {
                Tag = component
            };
            newNode.Text = component.GetType().Name;
            if (component.HasName())
                newNode.Text = newNode.Text + ": " + component.Name;
            else
                newNode.Text += " (No name)";
            nodes.Add(newNode);

            //  Add each child.
            //if (component.GetType() == typeof(Model))
            foreach (var element in component.Children)
                AddElementToTree(element, newNode.Nodes);
        }