public void Link(ResourceNode res)
        {
            Unlink();
            if (res != null)
            {
                this.Text = res.Name;
                TreeNodeCollection nodes = Nodes;

                //Should we continue down the tree?
                if ((IsExpanded) && (res.HasChildren))
                {
                    //Add/link each resource node
                    foreach (ResourceNode n in res.Children)
                    {
                        bool found = false;
                        foreach (BaseWrapper tn in nodes)
                        {
                            if (tn.Text == n.Name)
                            {
                                tn.Link(n);
                                found = true;
                                // Move node to bottom, to ensure that nodes are shown and saved in the same order as in the original data
                                nodes.Remove(tn);
                                nodes.Add(tn);
                                break;
                            }
                        }

                        if (!found)
                        {
                            nodes.Add(Wrap(_owner, n));
                        }
                    }

                    //Remove empty nodes
                    for (int i = 0; i < nodes.Count;)
                    {
                        BaseWrapper n = nodes[i] as BaseWrapper;
                        if (n._resource == null)
                        {
                            n.Remove();
                        }
                        else
                        {
                            i++;
                        }
                    }

                    _discovered = true;
                }
                else
                {
                    //Node will be reset and undiscovered
                    nodes.Clear();
                    //Collapse();
                    if (res.HasChildren)
                    {
                        nodes.Add(new GenericWrapper());
                        _discovered = false;
                    }
                    else
                    {
                        _discovered = true;
                    }
                }

                SelectedImageIndex = ImageIndex = (int)res.ResourceType & 0xFF;

                res.SelectChild     += OnSelectChild;
                res.ChildAdded      += OnChildAdded;
                res.ChildRemoved    += OnChildRemoved;
                res.ChildInserted   += OnChildInserted;
                res.Replaced        += OnReplaced;
                res.Restored        += OnRestored;
                res.Renamed         += OnRenamed;
                res.MovedUp         += OnMovedUp;
                res.MovedDown       += OnMovedDown;
                res.PropertyChanged += OnPropertyChanged;
                res.UpdateProps     += OnUpdateProperties;
                res.UpdateControl   += OnUpdateCurrentControl;
            }
            _resource = res;
        }