void DisplayObjectService_DisplayObjectVisibleChanged(object sender, DisplayObjectEventArgs e)
        {
            string[] groups = DisplayObjectService.GetGroups(e.DisplayObject);
            string   name   = DisplayObjectService.GetDisplayName(e.DisplayObject);

            TreeNodeCollection parentCollection = this.Nodes;

            for (int i = 0; i < groups.Length; i++)
            {
                // if the group node doesn't exist, get out
                if (!parentCollection.ContainsKey(groups[i]))
                {
                    return;
                }

                parentCollection = parentCollection[groups[i]].Nodes;
            }

            // we have the collection for the immediate parent
            if (parentCollection.ContainsKey(name))
            {
                if (Services.DisplayObjectService.IsVisible(e.DisplayObject))
                {
                    parentCollection[name].NodeFont = boldFont;
                }
                else
                {
                    parentCollection[name].NodeFont = this.Font;
                }
            }
        }
Exemplo n.º 2
0
 void DisplayObjectService_DisplayObjectRemoved(object sender, DisplayObjectEventArgs e)
 {
     // find the item and remove it
     for (int i = 0; i < listViewItems.Items.Count; i++)
     {
         if (object.Equals(listViewItems.Items[i].Tag, e.DisplayObject))
         {
             listViewItems.Items.RemoveAt(i);
             break;
         }
     }
 }
        void DisplayObjectService_DisplayObjectAdded(object sender, DisplayObjectEventArgs e)
        {
            // add to the nodes
            string[] groups = DisplayObjectService.GetGroups(e.DisplayObject);
            string   name   = DisplayObjectService.GetDisplayName(e.DisplayObject);

            TreeNodeCollection parentCollection = this.Nodes;

            for (int i = 0; i < groups.Length; i++)
            {
                TreeNode node = null;
                if (parentCollection.ContainsKey(groups[i]))
                {
                    node = parentCollection[groups[i]];
                }
                else
                {
                    node = new TreeNode(groups[i]);
                    node.SelectedImageKey = node.ImageKey = "folder closed";
                    node.Name             = groups[i];
                    parentCollection.Add(node);
                }

                node.Expand();

                parentCollection = node.Nodes;
            }

            // we have the collection for the immediate parent
            // add the node if it doesn't exist
            if (!parentCollection.ContainsKey(name))
            {
                TreeNode node = new TreeNode(name);
                node.Name             = name;
                node.Tag              = e.DisplayObject;
                node.SelectedImageKey = node.ImageKey = "display object";

                if (Services.DisplayObjectService.IsVisible(e.DisplayObject))
                {
                    node.NodeFont = boldFont;
                }

                parentCollection.Add(node);

                // walk to the root and expand all
                while (node.Parent != null)
                {
                    node = node.Parent;
                    node.Expand();
                }
            }
        }
        void DisplayObjectService_DisplayObjectRemoved(object sender, DisplayObjectEventArgs e)
        {
            string[] groups = DisplayObjectService.GetGroups(e.DisplayObject);
            string   name   = DisplayObjectService.GetDisplayName(e.DisplayObject);

            TreeNode           parentNode       = null;
            TreeNodeCollection parentCollection = this.Nodes;

            for (int i = 0; i < groups.Length; i++)
            {
                // if the group node doesn't exist, get out
                if (!parentCollection.ContainsKey(groups[i]))
                {
                    return;
                }

                parentNode       = parentCollection[groups[i]];
                parentCollection = parentNode.Nodes;
            }

            // we have the collection for the immediate parent
            if (parentCollection.ContainsKey(name))
            {
                parentCollection.RemoveByKey(name);
            }

            // walk up the parents and see if the folder is empty
            while (parentNode != null)
            {
                if (parentCollection.Count == 0)
                {
                    // get the parent node and it's collection
                    TreeNode removeNode = parentNode;
                    parentNode = parentNode.Parent;
                    if (parentNode == null)
                    {
                        parentCollection = this.Nodes;
                    }
                    else
                    {
                        parentCollection = parentNode.Nodes;
                    }

                    parentCollection.Remove(removeNode);
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 5
0
        void DisplayObjectService_DisplayObjectAdded(object sender, DisplayObjectEventArgs e)
        {
            ListViewItem item = new ListViewItem(e.DisplayObject.Name, "obj");

            if (Services.DisplayObjectService.IsVisible(e.DisplayObject))
            {
                item.Font      = boldFont;
                item.ForeColor = this.ForeColor;
            }
            else
            {
                item.Font      = this.Font;
                item.ForeColor = Color.Gray;
            }
            item.Tag = e.DisplayObject;
            listViewItems.Items.Insert(0, item);
        }
Exemplo n.º 6
0
 void DisplayObjectService_DisplayObjectVisibleChanged(object sender, DisplayObjectEventArgs e)
 {
     // find the item
     foreach (ListViewItem item in listViewItems.Items)
     {
         if (object.Equals(item.Tag, e.DisplayObject))
         {
             if (Services.DisplayObjectService.IsVisible(e.DisplayObject))
             {
                 item.Font      = boldFont;
                 item.ForeColor = this.ForeColor;
             }
             else
             {
                 item.Font      = this.Font;
                 item.ForeColor = Color.Gray;
             }
             break;
         }
     }
 }