Пример #1
0
        protected void PopupTreeViewContextMenu(System.Object sender, System.EventArgs e)
        {
            currTreeViewContextMenu.MenuItems.Clear();
            if (currTreeView.SelectedNode == null)
            {
                return;
            }

            XmlNode node = currTreeView.SelectedNode.Tag as XmlNode;

            if (node == null)
            {
                return;
            }

            IconMenuItem item1 = new IconMenuItem("&New", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            IconMenuItem item2 = new IconMenuItem("&Delete", new Bitmap(WixFiles.GetResourceStream("bmp.delete.bmp")));

            item2.Click += new System.EventHandler(DeleteElement_Click);
            IconMenuItem item3 = new IconMenuItem("&Info", new Bitmap(WixFiles.GetResourceStream("bmp.info.bmp")));

            item3.Click += new System.EventHandler(InfoAboutCurrentElement_Click);

            ArrayList newElementStrings = WixFiles.GetXsdSubElements(node.Name, SkipElements);

            bool isExtention = false;

            foreach (string newElementString in newElementStrings)
            {
                if (!isExtention && newElementString.Contains(":"))
                {
                    item1.MenuItems.Add(new MenuItem("-"));
                    isExtention = true;
                }

                MenuItem subMenuItem = new MenuItem(newElementString);
                subMenuItem.Click += new EventHandler(NewElement_Click);
                item1.MenuItems.Add(subMenuItem);
            }

            if (item1.MenuItems.Count > 0)
            {
                currTreeViewContextMenu.MenuItems.Add(item1);
            }

            currTreeViewContextMenu.MenuItems.Add(item2);

            XmlAttributeAdapter attAdapter = (XmlAttributeAdapter)CurrentGrid.SelectedObject;

            if (attAdapter != null)
            {
                XmlDocumentationManager docManager = new XmlDocumentationManager(WixFiles);
                if (docManager.HasDocumentation(attAdapter.XmlNodeDefinition))
                {
                    currTreeViewContextMenu.MenuItems.Add(new IconMenuItem("-"));
                    currTreeViewContextMenu.MenuItems.Add(item3);
                }
            }

            AddCustomTreeViewContextMenuItems(node, currTreeViewContextMenu);
        }