public TreeNodeWixIcon(WixIconNode node, int idx)
     : base(node)
 {
     if (idx > 0)
     {
         ImageIndex = idx;
     }
     else
     {
         ImageIndex = TreeViewWix.IMG_ICON;
     }
     SelectedImageIndex = ImageIndex;
     node.FileChanged  += node_FileChanged;
     node.IdChanged    += node_IdChanged;
 }
 void node_FileChanged(object sender, EventArgs e)
 {
     if (this.TreeView != null)
     {
         ImageList imgs = this.TreeView.ImageList;
         if (imgs != null)
         {
             WixIconNode ico = IconNode;
             if (!string.IsNullOrEmpty(ico.SourceFile))
             {
                 if (File.Exists(ico.SourceFile))
                 {
                     Image img = Image.FromFile(ico.SourceFile);
                     imgs.Images.Add(img);
                     ImageIndex         = imgs.Images.Count - 1;
                     SelectedImageIndex = ImageIndex;
                 }
             }
         }
     }
 }
        private void mnu_removeIcon(object sender, EventArgs e)
        {
            TreeViewWix tv = this.TreeView as TreeViewWix;
            Form        f  = null;

            if (this.TreeView != null)
            {
                f = this.TreeView.FindForm();
            }
            if (MessageBox.Show(f, "Do you want to remove this icon from the setup?", "Remove Icon", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                TreeNodeWixIconCollection ip = this.Parent as TreeNodeWixIconCollection;
                WixIconNode ico = IconNode;
                XmlNode     p   = ico.XmlData.ParentNode;
                p.RemoveChild(ico.XmlData);
                ip.IconNodes.Icons.Remove(ico);
                this.Remove();
                if (tv != null)
                {
                    tv.OnPropertyValueChanged();
                }
            }
        }
        private void mnu_addIcon(object sender, EventArgs e)
        {
            WixIconNode ico = this.IconNodes.AddIcon();

            if (_nextLevelLoaded)
            {
                TreeNodeWixIcon iconNode = new TreeNodeWixIcon(ico, -1);
                Nodes.Add(iconNode);
                this.TreeView.SelectedNode = iconNode;
            }
            else
            {
                this.Expand();
                if (this.TreeView != null)
                {
                    for (int i = 0; i < this.Nodes.Count; i++)
                    {
                        TreeNodeWixIcon iconNode = this.Nodes[i] as TreeNodeWixIcon;
                        if (iconNode != null)
                        {
                            if (string.CompareOrdinal(iconNode.IconNode.Id, ico.Id) == 0)
                            {
                                this.TreeView.SelectedNode = iconNode;
                                break;
                            }
                        }
                    }
                }
            }
            TreeViewWix tv = this.TreeView as TreeViewWix;

            if (tv != null)
            {
                tv.OnPropertyValueChanged();
            }
        }