Esempio 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);
                        }
                    }
                }
            }
        }
Esempio 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);
        }