Ejemplo n.º 1
0
        public override void OnShow()
        {
            ifNotPresentList.Clear();
            Controls.Clear();

            titleLabel = new Label();
            titleLabel.Text = stepElement.SelectSingleNode("Title").InnerText;
            titleLabel.Dock = DockStyle.Top;
            titleLabel.Height = 20;
            titleLabel.Left = 0;
            titleLabel.Top = 0;
            titleLabel.Padding = new Padding(5, 5, 5, 0);
            titleLabel.Font = new Font("Verdana",
                        10,
                        FontStyle.Bold,
                        GraphicsUnit.Point
                    );
            titleLabel.BackColor = Color.White;

            descriptionLabel = new Label();
            descriptionLabel.Text = stepElement.SelectSingleNode("Description").InnerText;
            descriptionLabel.Dock = DockStyle.Top;
            descriptionLabel.Height = 50 - titleLabel.Height;
            descriptionLabel.Left = 0;
            descriptionLabel.Top = titleLabel.Height;
            descriptionLabel.Padding = new Padding(8, 3, 5, 0);
            descriptionLabel.BackColor = Color.White;

            this.Controls.Add(descriptionLabel);

            this.Controls.Add(titleLabel);

            lineLabel = new Label();
            lineLabel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            lineLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            lineLabel.Location = new System.Drawing.Point(0, titleLabel.Height + descriptionLabel.Height);
            lineLabel.Size = new System.Drawing.Size(this.Width, 2);

            this.Controls.Add(lineLabel);

            Control prevControl = lineLabel;

            xmlnsmgr = new XmlNamespaceManager(stepElement.OwnerDocument.NameTable);

            // Check the TemplatePart@SelectionTarget, then the first control
            // should be a selection control.

            foreach (XmlElement templatePartNode in stepElement.SelectNodes("TemplatePart"))
            {
                String ifNotPresent = templatePartNode.GetAttribute("IfNotPresent");
                if (!String.IsNullOrEmpty(ifNotPresent))
                {
                    XmlNodeList ifNotPresentNodes = Wizard.WixFiles.WxsDocument.SelectNodes(ifNotPresent, Wizard.WixFiles.WxsNsmgr);
                    if (ifNotPresentNodes.Count > 0)
                    {
                        ifNotPresentList.Add(ifNotPresent);
                        continue;
                    }
                }

                XmlElement templatePart = (XmlElement)templatePartNode;
                String selectionTarget = templatePart.GetAttribute("SelectionTarget");
                if (selectionTarget != null && selectionTarget != String.Empty)
                {
                    Label label = new Label();
                    label.Width = this.Width - 10;
                    label.Height = 14;
                    label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    label.Text = "Select target location";

                    String selectionTargetDescription = templatePart.GetAttribute("Description");
                    if (selectionTargetDescription != null && selectionTargetDescription != String.Empty)
                    {
                        label.Text = selectionTargetDescription;
                    }

                    label.Top = prevControl.Bottom + 4;
                    label.Left = 5;
                    this.Controls.Add(label);

                    ComboBox text = new ComboBox();
                    text.DropDownStyle = ComboBoxStyle.DropDownList;
                    foreach (XmlNode dir in Wizard.WixFiles.WxsDocument.SelectNodes(selectionTarget, Wizard.WixFiles.WxsNsmgr))
                    {
                        text.Items.Add(dir.Attributes["Id"]);
                    }
                    text.DisplayMember = "Value";
                    text.Width = this.Width - 14;
                    text.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    // text.Items...
                    text.Top = prevControl.Bottom + label.Height + 4;
                    text.Left = 7;
                    text.Name = selectionTarget;
                    this.Controls.Add(text);

                    prevControl = text;
                }
            }

            foreach (XmlElement edit in stepElement.SelectNodes("Edit"))
            {
                string editMode = edit.GetAttribute("Mode");
                if (editMode == "GenerateGuid" || editMode == "CopyFromTarget")
                {
                    continue;
                }

                string refAtt = edit.GetAttribute("Ref");
                ExtractNamespaces(edit, xmlnsmgr, refAtt);

                // TODO: What if this edit thingie is in the template part that is not shown due to IfNotPresent?
                // Check the template part from theNode

                XmlNode theNode = stepElement.SelectSingleNode("TemplatePart/" + TranslateNamespace(refAtt), xmlnsmgr);
                if (theNode != null) // Could be that the IfNotPresent prevents it.
                {
                    XmlElement theTemplateNode = (XmlElement)stepElement.SelectSingleNode("TemplatePart[" + TranslateNamespace(refAtt) + "]", xmlnsmgr);
                    String ifNotPresent = theTemplateNode.GetAttribute("IfNotPresent");
                    if (!String.IsNullOrEmpty(ifNotPresent))
                    {
                        if (ifNotPresentList.Contains(ifNotPresent))
                        {
                            continue;
                        }
                    }

                    Label label = new Label();
                    label.Width = this.Width - 10;
                    label.Height = 14;
                    label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    label.Text = edit.GetAttribute("Description");
                    if (label.Text == String.Empty)
                    {
                        label.Text = edit.GetAttribute("Name");
                    }
                    if (label.Text == String.Empty)
                    {
                        label.Text = refAtt.Replace('/', ' ').Replace('[', ' ').Replace(']', ' ').Replace(':', ' ').Replace('@', ' ').Replace("  ", " ");
                    }
                    label.Top = prevControl.Bottom + 4;
                    label.Left = 5;
                    this.Controls.Add(label);

                    XmlDocumentationManager mgr = new XmlDocumentationManager(this.Wizard.WixFiles);
                    XmlNode xmlNodeDefinition = mgr.GetXmlNodeDefinition(theNode);

                    switch (editMode)
                    {
                        case "Select":
                            ComboBox select = new ComboBox();
                            select.DropDownStyle = ComboBoxStyle.DropDownList;
                            select.Width = this.Width - 14;
                            select.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

                            String selectionTarget = edit.GetAttribute("Selection");

                            foreach (XmlNode dir in Wizard.WixFiles.WxsDocument.SelectNodes(selectionTarget, Wizard.WixFiles.WxsNsmgr))
                            {
                                select.Items.Add(dir);
                            }

                            select.DisplayMember = "Value";
                            select.Top = prevControl.Bottom + label.Height + 4;
                            select.Left = 7;
                            select.Name = refAtt;
                            this.Controls.Add(select);

                            prevControl = select;
                            break;
                        case "Dropdown":
                            ComboBox combo = new ComboBox();
                            combo.DropDownStyle = ComboBoxStyle.DropDownList;
                            combo.Width = this.Width - 14;
                            combo.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                            combo.DisplayMember = "InnerText";
                            foreach (XmlNode optionNode in edit.SelectNodes("Option"))
                            {
                                XmlElement optionElement = (XmlElement)optionNode;
                                combo.Items.Add(optionNode);
                                if (optionElement.GetAttribute("Value") == theNode.InnerText)
                                {
                                    combo.SelectedItem = optionNode;
                                }
                            }

                            combo.Top = prevControl.Bottom + label.Height + 4;
                            combo.Left = 7;
                            combo.Name = refAtt;
                            this.Controls.Add(combo);

                            prevControl = combo;
                            break;
                        default:
                            TextBox text = new TextBox();
                            text.Width = this.Width - 14;
                            text.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                            text.Text = theNode.Value;
                            text.Top = prevControl.Bottom + label.Height + 4;
                            text.Left = 7;
                            text.Name = refAtt;
                            this.Controls.Add(text);

                            prevControl = text;
                            break;
                    }

                    if (xmlNodeDefinition != null)
                    {
                        string docu = mgr.GetDocumentation(xmlNodeDefinition, true);
                        if (!string.IsNullOrEmpty(docu))
                        {
                            prevControl.Width = prevControl.Width - 18;
                            errorProvider.SetError(prevControl, docu);
                            errorProvider.SetIconPadding(prevControl, 4);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void InfoAboutCurrentElement_Click(object sender, EventArgs e)
        {
            if (dialogTreeView.SelectedNode == null)
            {
                return;
            }

            XmlNode xmlNode = (XmlNode)dialogTreeView.SelectedNode.Tag;

            XmlDocumentationManager docManager = new XmlDocumentationManager(WixFiles);
            XmlAttributeAdapter attAdapter = (XmlAttributeAdapter)CurrentGrid.SelectedObject;

            string title = String.Format("Info about '{0}' element", xmlNode.Name);
            string message = docManager.GetDocumentation(attAdapter.XmlNodeDefinition);

            MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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);
        }