protected void PopupDialogTreeViewContextMenu(Object sender, EventArgs e) { dialogTreeViewContextMenu.MenuItems.Clear(); if (dialogTreeView.SelectedNode == null) { return; } XmlNode node = dialogTreeView.SelectedNode.Tag as XmlNode; if (node == null) { return; } switch (node.Name) { case "Dialog": dialogTreeViewContextMenu.MenuItems.Add(newControlElementMenu); break; case "Control": newControlSubElementsMenu.MenuItems.Clear(); dialogTreeViewContextMenu.MenuItems.Add(newControlSubElementsMenu); ArrayList newControlSubElementStrings = WixFiles.GetXsdSubElements(node.Name); newControlSubElementStrings.Sort(); string typeAttributeValue = null; XmlAttribute typeAttribute = node.Attributes["Type"]; if (typeAttribute != null) { typeAttributeValue = typeAttribute.Value; } foreach (string newControlSubElementString in newControlSubElementStrings) { // Do not show properties and binaries. // There is a separate place to add those. if (newControlSubElementString == "Binary" || newControlSubElementString == "Property") { continue; } IconMenuItem subMenuItem = null; switch (newControlSubElementString) { case "Text": subMenuItem = new IconMenuItem("Text", new Bitmap(WixFiles.GetResourceStream("elements.text.bmp"))); break; case "Publish": subMenuItem = new IconMenuItem("Publish", new Bitmap(WixFiles.GetResourceStream("elements.publish.bmp"))); break; case "Condition": subMenuItem = new IconMenuItem("Condition", new Bitmap(WixFiles.GetResourceStream("elements.condition.bmp"))); break; case "Subscribe": subMenuItem = new IconMenuItem("Subscribe", new Bitmap(WixFiles.GetResourceStream("elements.subscribe.bmp"))); break; default: string resourceName = "elements." + newControlSubElementString.ToLower() + ".bmp"; if (WixFiles.HasResource(resourceName)) { subMenuItem = new IconMenuItem(newControlSubElementString, new Bitmap(WixFiles.GetResourceStream(resourceName))); } else { subMenuItem = new IconMenuItem(newControlSubElementString); } break; } subMenuItem.Click += new EventHandler(NewSubElement_Click); newControlSubElementsMenu.MenuItems.Add(subMenuItem); } if (typeAttributeValue != null) { ArrayList newElementStrings = WixFiles.GetXsdSubElements(typeAttributeValue); if (newControlSubElementStrings.Count > 0 && newElementStrings.Count > 0) { newElementStrings.Sort(); newControlSubElementsMenu.MenuItems.Add(new IconMenuItem("-")); } bool isExtention = false; foreach (string newElementString in newElementStrings) { if (!isExtention && newElementString.Contains(":")) { newControlSubElementsMenu.MenuItems.Add(new IconMenuItem("-")); isExtention = true; } IconMenuItem subMenuItem = new IconMenuItem(newElementString); subMenuItem.Click += new EventHandler(NewControlElement_Click); newControlSubElementsMenu.MenuItems.Add(subMenuItem); } } break; default: break; } if (node.Name != "Dialog") { dialogTreeViewContextMenu.MenuItems.Add(deleteCurrentElementMenu); } XmlAttributeAdapter attAdapter = (XmlAttributeAdapter)CurrentGrid.SelectedObject; XmlDocumentationManager docManager = new XmlDocumentationManager(WixFiles); if (docManager.HasDocumentation(attAdapter.XmlNodeDefinition)) { dialogTreeViewContextMenu.MenuItems.Add(new IconMenuItem("-")); dialogTreeViewContextMenu.MenuItems.Add(infoAboutCurrentElementMenu); } }
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); }