/// <summary>
        /// This routine removes a related link from the tree.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void DeleteLink_Click(object sender, RoutedEventArgs args)
        {
            if (this.RelatedLinks1.LinkIDTextBox.Text == "")
            {
                //Safe to simply reset the Examples page.
                MainWindow.ResetLinksPage();
            }
            else //We must remove the current record from the Examples list
            {
                TreeViewItem selectedNode = (TreeViewItem)MainWindow.NavControl.CmdletTreeView.SelectedItem;
                TreeViewItem ParentNode   = (TreeViewItem)selectedNode.Parent;
                TreeViewItem CmdletNode   = (TreeViewItem)ParentNode.Parent;
                ParentNode.IsSelected = true;
                ParentNode.Items.Remove(selectedNode);

                cmdletDescription selectedCmdlet = (cmdletDescription)CmdletNode.DataContext;
                relatedlink       selectedLink   = (relatedlink)selectedNode.DataContext;

                foreach (cmdletDescription mycmdlet in MainWindow.CmdletsHelps)
                {
                    if (mycmdlet.CmdletName == selectedCmdlet.CmdletName)
                    {
                        Collection <relatedlink> myLinks = mycmdlet.RelatedLinks;
                        relatedlink linktoRemove         = new relatedlink();
                        foreach (relatedlink mylink in myLinks)
                        {
                            if (mylink.LinkID == selectedLink.LinkID)
                            {
                                linktoRemove = mylink;
                            }
                        }
                        if (linktoRemove.LinkID.ToString() != null)
                        {
                            mycmdlet.RelatedLinks.Remove(linktoRemove);
                            ParentNode.Items.Remove(selectedNode);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public XmlWriter createAlertSetSection(XmlWriter writer, cmdletDescription result)
        {
            try
            {
                //Start AlertSet section
                writer.WriteRaw("	<maml:alertSet>\r\n");
                //writer.WriteComment("Notes Secion");
                writer.WriteRaw("		<maml:title></maml:title>\r\n");
                writer.WriteRaw("		<maml:alert>\r\n");
                writer.WriteRaw("			<maml:para>");
                //writer.WriteComment("Note Details");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Note));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("		</maml:alert>\r\n");

                //End AlertSet section
                writer.WriteRaw("	</maml:alertSet>\r\n");

                //<maml:alertSet>
                //  <maml:title></maml:title>
                //  <maml:alert>
                //    <maml:para>
                //      <!-- Note details-->
                //    </maml:para>
                //  </maml:alert>
                //  <maml:alert>
                //    <maml:para></maml:para>
                //  </maml:alert>
                //</maml:alertSet>
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            return(writer);
        }
Esempio n. 3
0
        public static void GetHelpInfoNotInCode(Collection<cmdletDescription> CodeCmdlets, String path)
        {
            //String path1 = @"C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-Help.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(path);

            XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
            ns.AddNamespace("", "http://msh");
            ns.AddNamespace("command", "http://schemas.microsoft.com/maml/dev/command/2004/10");
            ns.AddNamespace("maml", "http://schemas.microsoft.com/maml/2004/10");
            ns.AddNamespace("dev", "http://schemas.microsoft.com/maml/dev/2004/10");
            XmlNodeList commandNodes = doc.SelectNodes("//command:command", ns);

            //TreeViewItem psSnapinNode =  ; 
            foreach (XmlNode commandNode in commandNodes)
            //foreach (cmdletDescription cmdletHelp in CodeCmdlets)
            {
                cmdletDescription CmdletHelp = new cmdletDescription();
                XmlNode nameNode = commandNode.SelectSingleNode("command:details/command:name", ns);
                //CmdletHelp = cmdletHelp;
                Boolean CmdletFound = false;
                foreach (cmdletDescription cmdletHelp in CodeCmdlets)
                {

                    if (nameNode.InnerText.Trim().ToLower() == cmdletHelp.CmdletName.ToLower())
                    {
                        CmdletFound = true;
                        break;
                    }
                }
                if (CmdletFound == false)
                {
                    //Add cmdlet from help to code one and color it.
                    CmdletHelp = GetExistingHelpInfo(CmdletHelp, nameNode.InnerText.Trim(), path);


                    //Start building the Cmdlet navigation tree
                    TreeViewItem Node = new TreeViewItem();

                    Node.Header = nameNode.InnerText.Trim();
                    // Brushes MyBrush = "#FF363B44";
                    //MyBrush = 5;

                    Node.Foreground = Brushes.Red;
                    Node.FontWeight = FontWeights.Bold;
                    MainWindow.ObsoleteInfo = true;


                    TreeViewItem ParameterNode = new TreeViewItem();
                    TreeViewItem ExamplesNode = new TreeViewItem();
                    TreeViewItem LinksNode = new TreeViewItem();
                    //add the Parameters record to the tree
                    if (CmdletHelp.ParameterDecription != null)
                    {
                        foreach (parameterDecription nodeparameterDesc in CmdletHelp.ParameterDecription)
                        {
                            TreeViewItem paramItem = new TreeViewItem();
                            paramItem.Header = (nodeparameterDesc.Name);
                            paramItem.DataContext = nodeparameterDesc;
                            paramItem.Foreground = Brushes.Red;
                            paramItem.FontWeight = FontWeights.Bold;
                            MainWindow.ObsoleteInfo = true;
                            ParameterNode.Items.Add(paramItem);

                        }

                    }
                    ParameterNode.Header = "Parameters";
                    ParameterNode.Foreground = Brushes.Red;
                    ParameterNode.FontWeight = FontWeights.Bold;
                    ParameterNode.DataContext = CmdletHelp.ParameterDecription;
                    ExamplesNode.Header = "Examples";
                    ExamplesNode.Foreground = Brushes.Red;
                    ExamplesNode.FontWeight = FontWeights.Bold;
                    ExamplesNode.DataContext = new Collection<example>();
                    if (CmdletHelp.Examples != null)
                    {
                        ExamplesNode.DataContext = CmdletHelp.Examples;
                        foreach (example examp in CmdletHelp.Examples)
                        {
                            TreeViewItem exmpNode = new TreeViewItem();
                            exmpNode.DataContext = examp;
                            exmpNode.Foreground = Brushes.Red;
                            exmpNode.FontWeight = FontWeights.Bold;
                            exmpNode.Header = examp.ExampleName;
                            ExamplesNode.Items.Add(exmpNode);
                        }

                    }

                    LinksNode.Header = "Related Links";
                    LinksNode.Foreground = Brushes.Red;
                    LinksNode.FontWeight = FontWeights.Bold;
                    LinksNode.DataContext = new Collection<relatedlink>();
                    if (CmdletHelp.RelatedLinks != null)
                    {
                        LinksNode.DataContext = CmdletHelp.RelatedLinks;
                        foreach (relatedlink examp in CmdletHelp.RelatedLinks)
                        {
                            TreeViewItem exmpNode = new TreeViewItem();
                            exmpNode.DataContext = examp;
                            exmpNode.Foreground = Brushes.Red;
                            exmpNode.FontWeight = FontWeights.Bold;
                            exmpNode.Header = examp.LinkText;
                            LinksNode.Items.Add(exmpNode);
                        }

                    }
                    Node.Items.Add(ParameterNode);
                    Node.Items.Add(ExamplesNode);
                    Node.Items.Add(LinksNode);
                    //  Node.Header = CmdletHelp.CmdletName;
                    Node.DataContext = CmdletHelp;

                    //    TreeViewItem PsSnapinNode = new TreeViewItem();

                    MainWindow.PsSnapinNode.Items.Add(Node);
                    //Cmdlets.Add(CmdletHelp);

                }


            }
            // return CodeCmdlets;

        }
Esempio n. 4
0
        /// <summary>
        /// This is the static method which Asim helped me with.
        /// I get all the Cmdlet Mamal info from here.
        /// I need to pass the cmdletDescription record before adding it to the CmdletHelps collection.
        /// 
        /// </summary>
        public static cmdletDescription GetExistingHelpInfo(cmdletDescription CmdletHelp, String CmdletName, String path)
        {
            //String path1 = @"C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-Help.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(path);

            XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
            ns.AddNamespace("", "http://msh");
            ns.AddNamespace("command", "http://schemas.microsoft.com/maml/dev/command/2004/10");
            ns.AddNamespace("maml", "http://schemas.microsoft.com/maml/2004/10");
            ns.AddNamespace("dev", "http://schemas.microsoft.com/maml/dev/2004/10");
            XmlNodeList commandNodes = doc.SelectNodes("//command:command", ns);
            foreach (XmlNode commandNode in commandNodes)
            {
                XmlNode nameNode = commandNode.SelectSingleNode("command:details/command:name", ns);
                if (nameNode.InnerText.Trim().ToLower() == CmdletName.ToLower())
                {
                    // MessageBox.Show(commandNode.OuterXml);
                    XmlNode tempNode = null;

                    tempNode = commandNode.SelectSingleNode("command:details/maml:description", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldShortDescription = CmdletHelp.ShortDescription = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("maml:description", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldLongDescription = CmdletHelp.LongDescription = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("command:inputTypes/command:inputType/dev:type/maml:name", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldInputType = CmdletHelp.InputType = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("command:inputTypes/command:inputType/dev:type/maml:description", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldInputDesc = CmdletHelp.InputDesc = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("command:returnValues/command:returnValue/dev:type/maml:name", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldOutputType = CmdletHelp.OutputType = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("command:returnValues/command:returnValue/dev:type/maml:description", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldOutputDesc = CmdletHelp.OutputDesc = tempNode.InnerText.Trim();
                    }

                    tempNode = commandNode.SelectSingleNode("maml:alertSet/maml:alert", ns);
                    if (tempNode != null)
                    {
                        CmdletHelp.OldNote = CmdletHelp.Note = tempNode.InnerText.Trim();
                    }

                    XmlNodeList exampleNodes = commandNode.SelectNodes("command:examples/command:example", ns);

                    int exampleCount = 0;
                    Collection<example> CmdletExamples = new Collection<example>();
                    foreach (XmlNode exampleNode in exampleNodes)
                    {
                        example CmdletExample = new example();

                        tempNode = exampleNode.SelectSingleNode("maml:title", ns);
                        if (tempNode != null)
                        {
                            CmdletExample.OldExampleName = CmdletExample.ExampleName = tempNode.InnerText.Trim().Replace("-", "");
                            if (CmdletExample.ExampleName.Length == 0 || CmdletExample.ExampleName.Replace(" ", "") == "") { CmdletExample.ExampleName = CmdletExample.OldExampleName = "Unkown"; }
                        }

                        CmdletExample.ExampleID = exampleCount;

                        tempNode = exampleNode.SelectSingleNode("dev:code", ns);
                        if (tempNode != null)
                        {
                            CmdletExample.OldExampleCmd = CmdletExample.ExampleCmd = tempNode.InnerText.Trim();
                        }

                        tempNode = exampleNode.SelectSingleNode("dev:remarks", ns);
                        if (tempNode != null)
                        {
                            int NodeCount = 0;
                            foreach (XmlNode DescriptionNode in tempNode)
                            {
                                if (NodeCount == 0)
                                {
                                    CmdletExample.OldExampleDescription = CmdletExample.ExampleDescription = DescriptionNode.InnerText.Trim();
                                }
                                else
                                {

                                    CmdletExample.OldExampleOutput += DescriptionNode.InnerText.Trim();
                                    CmdletExample.ExampleOutput = CmdletExample.OldExampleOutput;
                                }
                                NodeCount++;
                            }
                        }

                        tempNode = exampleNode.SelectSingleNode("command:commandLines", ns);
                        if (tempNode != null)
                        {
                            CmdletExample.OldExampleOutput += tempNode.InnerText.Trim();
                            CmdletExample.ExampleOutput = CmdletExample.OldExampleOutput;
                        }

                        exampleCount++;

                        CmdletExamples.Add(CmdletExample);
                    }

                    CmdletHelp.Examples = CmdletExamples;

                    Collection<relatedlink> RelatedLinks = new Collection<relatedlink>();
                    XmlNodeList NodeLinks = commandNode.SelectNodes("maml:relatedLinks/maml:navigationLink", ns);
                    int LinkCount = 0;
                    foreach (XmlNode linkNode in NodeLinks)
                    {
                        relatedlink RelatedLink = new relatedlink();

                        tempNode = linkNode.SelectSingleNode("maml:linkText", ns);
                        if (tempNode != null)
                        {
                            RelatedLink.OldLinkText = RelatedLink.LinkText = tempNode.InnerText.Trim();
                            if (RelatedLink.LinkText.Length == 0) { RelatedLink.LinkText = RelatedLink.LinkText = "Unkown"; }
                        }

                        RelatedLink.LinkID = LinkCount;

                        LinkCount++;

                        RelatedLinks.Add(RelatedLink);
                    }
                    CmdletHelp.RelatedLinks = RelatedLinks;


                    //iterate through parameters
                    XmlNodeList parameterNodes = commandNode.SelectNodes("command:parameters/command:parameter", ns);
                    if (CmdletHelp.ParameterDecription != null)
                    {
                        foreach (parameterDecription CmdletParameter in CmdletHelp.ParameterDecription)
                        {
                            //maml:description
                            foreach (XmlNode parameterNode in parameterNodes)
                            {
                                tempNode = parameterNode.SelectSingleNode("maml:name", ns);
                                if (tempNode != null)
                                {
                                    if (CmdletParameter.Name.ToLower() == tempNode.InnerText.Trim().ToLower())
                                    {
                                        tempNode = parameterNode.SelectSingleNode("maml:description", ns);
                                        if (tempNode != null)
                                        {
                                            CmdletParameter.OldDescription = CmdletParameter.NewDescription = tempNode.InnerText.Trim();
                                        }

                                        tempNode = parameterNode.SelectSingleNode("dev:defaultValue", ns);
                                        if (tempNode != null)
                                        {
                                            CmdletParameter.DefaultValue = CmdletParameter.OldDefaultValue = tempNode.InnerText.Trim();
                                        }

                                        tempNode = parameterNode.SelectSingleNode("@globbing", ns);

                                        if (tempNode.Value.ToLower().Trim() == "true")
                                        {
                                            CmdletParameter.Globbing = CmdletParameter.OldGlobbing = true;


                                        }
                                        else
                                        {
                                            CmdletParameter.Globbing = CmdletParameter.OldGlobbing = false;

                                        }
                                    }

                                }
                            }


                        }
                    }

                    //I do not have code parameters. Get only help ones and mark them in red.

                    foreach (XmlNode parameterNode in parameterNodes)
                    {
                        Boolean ParameterFound = false;
                        tempNode = parameterNode.SelectSingleNode("maml:name", ns);
                        String ParameterName = tempNode.InnerText.Trim();
                        if (CmdletHelp.ParameterDecription != null)
                        {
                            foreach (parameterDecription CmdletParameter in CmdletHelp.ParameterDecription)
                            {

                                if (CmdletParameter.Name.ToLower() == ParameterName.ToLower())
                                {
                                    ParameterFound = true;
                                    break;
                                }
                            }
                        }
                        if (ParameterFound == false)
                        {
                            //Get help parameter.
                            parameterDecription CmdletParameter = new parameterDecription();
                            CmdletParameter.HelpOnlyParameter = true;
                            MainWindow.ObsoleteInfo = true;
                            tempNode = parameterNode.SelectSingleNode("maml:name", ns);
                            if (tempNode != null)
                            {
                                //  if (CmdletParameter.Name.ToLower() == tempNode.InnerText.Trim().ToLower())
                                // {
                                tempNode = parameterNode.SelectSingleNode("maml:description", ns);
                                if (tempNode != null)
                                {
                                    CmdletParameter.OldDescription = CmdletParameter.NewDescription = tempNode.InnerText.Trim();
                                }

                                tempNode = parameterNode.SelectSingleNode("dev:defaultValue", ns);
                                if (tempNode != null)
                                {
                                    CmdletParameter.DefaultValue = CmdletParameter.OldDefaultValue = tempNode.InnerText.Trim();
                                }

                                tempNode = parameterNode.SelectSingleNode("@globbing", ns);

                                if (tempNode.Value.ToLower().Trim() == "true")
                                {
                                    CmdletParameter.Globbing = CmdletParameter.OldGlobbing = true;

                                }
                                else
                                {
                                    CmdletParameter.Globbing = CmdletParameter.OldGlobbing = false;

                                }
                                tempNode = parameterNode.SelectSingleNode("@pipelineInput", ns);

                                if (tempNode != null)
                                {
                                    if (tempNode.Value.ToLower().Trim() == "true (ByPropertyName)")
                                    {
                                        CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = true;

                                    }
                                    else if (tempNode.Value.ToLower().Trim() == "true (ByValue, ByPropertyName)")
                                    {
                                        CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = true;
                                        CmdletParameter.VFP = CmdletParameter.VFP = true;
                                    }
                                    else if (tempNode.Value.ToLower().Trim() == "true (ByValue)")
                                    {
                                        CmdletParameter.VFP = CmdletParameter.VFP = true;
                                    }
                                    else
                                    {
                                        CmdletParameter.VFPBPN = CmdletParameter.VFPBPN = false;
                                        CmdletParameter.VFP = CmdletParameter.VFP = false;
                                    }
                                }
                                tempNode = parameterNode.SelectSingleNode("@position", ns);

                                if (tempNode != null)
                                {
                                    CmdletParameter.Position = tempNode.Value.ToLower().Trim();
                                }

                                tempNode = parameterNode.SelectSingleNode("@required", ns);
                                if (tempNode != null)
                                {
                                    if (tempNode.Value.ToLower().Trim() == "true")
                                    {
                                        CmdletParameter.isMandatory = true;
                                    }
                                }
                                tempNode = parameterNode.SelectSingleNode("dev:type/maml:name", ns);
                                if (tempNode != null)
                                {

                                    if (tempNode.InnerText != null)
                                    {
                                        CmdletParameter.ParameterType = tempNode.InnerText.Trim().ToLower();
                                    }
                                }

                                CmdletParameter.Name = ParameterName;
                                CmdletParameter.CmdletName = CmdletName;
                                if (CmdletHelp.ParameterDecription == null)
                                {
                                    CmdletHelp.ParameterDecription = new Collection<parameterDecription>();
                                }
                                CmdletHelp.ParameterDecription.Add(CmdletParameter);

                            }

                        }
                    }

                    // break;
                }


            }
            return CmdletHelp;

        }
        /// <summary>
        /// This routine is used to create the one Cmdlet help MAML
        /// at a time.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="CmdletHelp"></param>
        public void SaveHelpFileBody(XmlWriter writer, cmdletDescription CmdletHelp)
        {
            try
            {

                writer.WriteRaw("<command:command xmlns:maml=\"http://schemas.microsoft.com/maml/2004/10\" xmlns:command=\"http://schemas.microsoft.com/maml/dev/command/2004/10\" xmlns:dev=\"http://schemas.microsoft.com/maml/dev/2004/10\">\r\n");
                writer = MainWindow.helpWriter.writeCmdletDetails(writer, CmdletHelp);

                //Add Syntax section <command:syntax>
                writer.WriteRaw("	<command:syntax>");

                Collection<parameterDecription> ParamDescription = CmdletHelp.ParameterDecription;
                Collection<parameterSet> HelpParameterSets = CmdletHelp.ParameterSets;
                //Iterate through the Syntax section and add Syntax items.
                //foreach (parameterset in paramDescription.ParameterSets[0].Parameters[0].Name
                if (HelpParameterSets != null)
                {
                    foreach (parameterSet HelpParameterSet in HelpParameterSets)
                    {
                        writer.WriteRaw("		<command:syntaxItem>\r\n");
                        //Cdmlet Name.
                        writer.WriteRaw("			<maml:name>");
                        writer.WriteRaw(CmdletHelp.CmdletName);
                        writer.WriteRaw("</maml:name>\r\n");
                        // writer.WriteRaw("		<!--New Syntax Item-->\r\n");
                        if (HelpParameterSet.Parameters != null)
                        {
                            foreach (parametersetParameter HelpParameter in HelpParameterSet.Parameters)
                            {
                                foreach (parameterDecription param in ParamDescription)
                                {
                                    if (param.Name.ToLower() == HelpParameter.Name.ToLower())
                                    {
                                        writer = MainWindow.helpWriter.createSyntaxItem(writer, param, CmdletHelp);
                                        break;
                                    }
                                }
                            }
                        }
                        //End <command:syntaxItem>
                        writer.WriteRaw("		</command:syntaxItem>\r\n");
                    }
                }
                else
                {
                    writer.WriteRaw("		<command:syntaxItem>\r\n");
                    writer.WriteRaw("		</command:syntaxItem>\r\n");

                }


                writer.WriteRaw("	</command:syntax>\r\n");
                //writer.WriteRaw("	</command:syntax>\r\n");

                //Add Parameters section <command:parameters>
                writer.WriteRaw("	<command:parameters>\r\n");
                //writer.WriteComment("Parameters section");

                //Iterate through the parameters section and add parameters Items.


                foreach (parameterDecription parameter in ParamDescription)
                {
                    writer = MainWindow.helpWriter.createParameters(writer, parameter);
                }


                writer.WriteRaw("	</command:parameters>\r\n");


                //Input Object Section
                writer = MainWindow.helpWriter.createInputSection(writer, CmdletHelp);

                //Output Object Section
                writer = MainWindow.helpWriter.createOutputSection(writer, CmdletHelp);


                // Error Section (Static section not used)
                //<command:terminatingErrors />
                //<command:nonTerminatingErrors />
                writer.WriteRaw("	<command:terminatingErrors>\r\n");
                //writer.WriteComment("Terminating errors section");
                writer.WriteRaw("	</command:terminatingErrors>\r\n");
                writer.WriteRaw("	<command:nonTerminatingErrors>\r\n");
                //writer.WriteComment("Non terminating errors section");
                writer.WriteRaw("	</command:nonTerminatingErrors>\r\n");


                //AlertSet  <!-- Notes section  -->
                writer = MainWindow.helpWriter.createAlertSetSection(writer, CmdletHelp);

                //Examples section.
                //Examples header goes here <command:examples>
                writer.WriteRaw("	<command:examples>\r\n");

                //Iterate through all the examples here
                if (CmdletHelp.Examples != null)
                {
                    foreach (example ExampleRecord in CmdletHelp.Examples)
                    {
                        writer = MainWindow.helpWriter.createExampleItemSection(writer, ExampleRecord);
                        //End examples section

                    }
                }
                writer.WriteRaw("	</command:examples>\r\n");


                //Links section
                // <maml:relatedLinks>
                writer.WriteRaw("	<maml:relatedLinks>\r\n");
                //Iterate through the links

                if (CmdletHelp.RelatedLinks != null)
                {
                    foreach (relatedlink RelatedLinkRecord in CmdletHelp.RelatedLinks)
                    {
                        writer = MainWindow.helpWriter.createLinksSection(writer, RelatedLinkRecord);

                    }
                }
                writer.WriteRaw("	</maml:relatedLinks>\r\n");

                //Write the end node for the starting <command:command> node.
                //writer.WriteRaw();
                writer.WriteRaw("</command:command>\r\n");
                //  }

                //Write the help file.

                //  }

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML file", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                //FailedToWrite = true;
                if (writer != null)
                {
                    writer.Close();
                }

            }
        }
        /// <summary>
        /// Check the type of the selected item on the tree view.
        /// This is needed to determine different functionality such
        /// as copy and paste. It lets me know which type of node on the tree
        /// is slected.
        /// </summary>
        /// <returns></returns>
        public cmdletDescription CheckTheType()
        {
            cmdletDescription CmdletHelp = new cmdletDescription();
            TreeViewItem SelectedNode = (TreeViewItem)this.NavigationControl1.CmdletTreeView.SelectedItem;

            if (SelectedNode != null)
            {
                if (SelectedNode.DataContext != null)
                {

                    if (SelectedNode.DataContext is HelpEditorOS.parameterDecription)
                    {
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        CmdletHelp = (cmdletDescription)SelectedNode.DataContext;
                    }
                    else if (SelectedNode.DataContext is HelpEditorOS.example)
                    {
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        CmdletHelp = (cmdletDescription)SelectedNode.DataContext;

                    }
                    else if (SelectedNode.DataContext is HelpEditorOS.relatedlink)
                    {
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        SelectedNode = (TreeViewItem)SelectedNode.Parent;
                        CmdletHelp = (cmdletDescription)SelectedNode.DataContext;

                    }
                    else if (SelectedNode.DataContext is cmdletDescription)
                    {
                        CmdletHelp = (cmdletDescription)SelectedNode.DataContext;
                    }
                }
            }
            return CmdletHelp;
        }
Esempio n. 7
0
        /// <summary>
        /// Write the Cmdlet Parameter Sets syntax.
        /// </summary>
        /// <param name="CmdletHelp"></param>
        /// <returns></returns>
        public static String WriteSyntax(cmdletDescription CmdletHelp)
        {
            String Syntax = "";
            if (CmdletHelp.ParameterSets != null)
            {
                foreach (parameterSet parSet in CmdletHelp.ParameterSets)
                {
                    Syntax += "    " + CmdletHelp.CmdletName + " ";
                    foreach (parametersetParameter ParameterName in parSet.Parameters)
                    {
                        foreach (parameterDecription param in CmdletHelp.ParameterDecription)
                        {
                            if (param.Name == ParameterName.Name)
                            {
                                if (param.isMandatory && param.Position.ToLower() != "named")
                                {
                                    Syntax += "[-" + param.Name + "] <" + param.ParameterType + "> ";
                                }
                                else if (param.isMandatory && param.Position.ToLower() == "named")
                                {
                                    Syntax += "-" + param.Name + " <" + param.ParameterType + "> ";
                                }
                                else if (!param.isMandatory && param.Position.ToLower() != "named")
                                {
                                    Syntax += "[[-" + param.Name + "] <" + param.ParameterType + ">] ";
                                }
                                else if (!param.isMandatory && param.Position == "named")
                                {
                                    Syntax += "[-" + param.Name + " <" + param.ParameterType + ">] ";
                                }
                            }
                        }
                    }
                    Syntax += "\r\n";
                }
            }
            else
            {
                foreach (parameterDecription param in CmdletHelp.ParameterDecription)
                {
                    if (param.isMandatory && param.Position.ToLower() != "named")
                    {
                        Syntax += "[-" + param.Name + "] <" + param.ParameterType + "> ";
                    }
                    else if (param.isMandatory && param.Position.ToLower() == "named")
                    {
                        Syntax += "-" + param.Name + " <" + param.ParameterType + "> ";
                    }
                    else if (!param.isMandatory && param.Position.ToLower() != "named")
                    {
                        Syntax += "[[-" + param.Name + "] <" + param.ParameterType + ">] ";
                    }
                    else if (!param.isMandatory && param.Position == "named")
                    {
                        Syntax += "[-" + param.Name + " <" + param.ParameterType + ">] ";
                    }
                }

            }

            return Syntax;
        }
        public XmlWriter createSyntaxItem(XmlWriter writer, parameterDecription param, cmdletDescription Cmdlet)
        {
            try
            {

                // foreach (PSObject result in results)
                // {
                // String LocalParamDescription = "";
                Boolean Globbing = param.Globbing;
                String cmdletName = Cmdlet.CmdletName; // TODO add real CmdletName CmdletsList.SelectedValue.ToString();
                //foreach (HelpEditor.parameterDecription param in parametersDescription)
                //{

                //    if ((param.Name.ToLower() == Parameterecord.Name.ToLower()) && (cmdletName == param.CmdletName))
                //    {
                //        LocalParamDescription = param.NewDescription;
                //        Globbing = param.Globbing;
                //        break;
                //    }
                //}





                // Parameter Metadata for the Syntax Item section.
                writer.WriteRaw("			<command:parameter ");
                writer.WriteRaw("required = \"" + param.isMandatory.ToString().ToLower() + "\"");
                //Do variable length verification
                String parametertype = param.ParameterType;
                int LengthName = parametertype.Length;
                String VariableLength = "false";

                if (LengthName > 2)
                {
                    if (parametertype[LengthName - 1] == ']' && parametertype[LengthName - 2] == '[')
                    {
                        VariableLength = "true";
                    }
                }

                writer.WriteRaw(" variableLength = \"" + VariableLength + "\"");
                // TODO add code for globbing here.
                String strGlobbing = "false";
                if (Globbing)
                {
                    strGlobbing = "true";
                }
                writer.WriteRaw(" globbing = \"" + strGlobbing + "\"");

                String pipelineInput;
                if (param.VFP || param.VFPBPN)
                {
                    pipelineInput = "true (";
                    if (param.VFP) { pipelineInput += "ByValue"; }
                    if (param.VFPBPN)
                    {
                        if (pipelineInput.Length > 6)
                        {
                            pipelineInput += ", ByPropertyName)";
                        }
                        else
                        {
                            pipelineInput += "ByPropertyName)";
                        }
                    }
                    else
                    {
                        pipelineInput += ")";
                    }
                }
                else
                {
                    pipelineInput = "false";
                }
                writer.WriteRaw(" pipelineInput = \"" + pipelineInput + "\"");

                //Positional?
                // int position;
                // if (param.Position < 0)
                // {
                //    writer.WriteRaw(" position = \"named\">");
                // }
                // else
                // {
                //     position = (Parameterecord.Position + 1);
                writer.WriteRaw(" position = \"" + param.Position + "\" >\r\n");
                // }


                //Maml parameter name.
                //  writer.WriteRaw("				<!--Parameter Name-->\r\n");
                writer.WriteRaw("				<maml:name>");

                writer.WriteRaw(HttpUtility.HtmlEncode(param.Name));
                writer.WriteRaw("</maml:name>\r\n");


                //Parameter description

                //  writer.WriteRaw("maml", "para", "http://schemas.microsoft.com/maml/2004/10");
                writer.WriteRaw("				<maml:description>\r\n");
                // writer.WriteRaw("				<!--Parameter Description->\r\n");
                //Get the description from the struc.
                writer.WriteRaw("					<maml:para>");

                writer.WriteRaw(HttpUtility.HtmlEncode(param.NewDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("				</maml:description>\r\n");

                string paramValueRequired = "true";
                if (param.ParameterType.ToLower() != "switchparameter")
                {
                    //Additional parameter Values
                    if (param.ParameterType.ToLower() == "boolean")
                    {
                        paramValueRequired = "false";
                    }
                    //Additional parameter Values
                    writer.WriteRaw("			<command:parameterValue ");
                    writer.WriteRaw("required=\"" + paramValueRequired + "\"");
                    writer.WriteRaw(" variableLength = \"" + VariableLength + "\" >");
                    writer.WriteRaw(HttpUtility.HtmlEncode(param.ParameterType));
                    writer.WriteRaw("</command:parameterValue>\r\n");
                }

                //End <command:prameter>
                writer.WriteRaw("			</command:parameter>\r\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }


            //}
            return writer;

        }
        public XmlWriter createAlertSetSection(XmlWriter writer, cmdletDescription result)
        {
            try
            {


                //Start AlertSet section
                writer.WriteRaw("	<maml:alertSet>\r\n");
                //writer.WriteComment("Notes Secion");
                writer.WriteRaw("		<maml:title></maml:title>\r\n");
                writer.WriteRaw("		<maml:alert>\r\n");
                writer.WriteRaw("			<maml:para>");
                //writer.WriteComment("Note Details");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Note));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("		</maml:alert>\r\n");

                //End AlertSet section
                writer.WriteRaw("	</maml:alertSet>\r\n");

                //<maml:alertSet>
                //  <maml:title></maml:title>
                //  <maml:alert>
                //    <maml:para>
                //      <!-- Note details-->
                //    </maml:para>
                //  </maml:alert>
                //  <maml:alert>
                //    <maml:para></maml:para>
                //  </maml:alert>
                //</maml:alertSet>
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            return writer;
        }
        public XmlWriter createOutputSection(XmlWriter writer, cmdletDescription result)
        {
            try
            {
                //Input Types Section
                writer.WriteRaw("	<command:returnValues>\r\n");
                writer.WriteRaw("		<command:returnValue>\r\n");
                writer.WriteRaw("			<dev:type>\r\n");

                //Input Type
                writer.WriteRaw("				<maml:name>");
                //writer.WriteComment("Output Type");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.OutputType));
                writer.WriteRaw("</maml:name>\r\n");

                //Input Uri
                writer.WriteRaw("				<maml:uri />\r\n");
                //writer.WriteComment("Uri section not used");
                //writer.WriteRaw();

                //Input Type
                writer.WriteRaw("				<maml:description>\r\n");
                //writer.WriteComment("Output type description");
                writer.WriteRaw("					<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.OutputDesc));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("				</maml:description>\r\n");


                //End dev:type
                writer.WriteRaw("			</dev:type>\r\n");

                //End command:inputType
                writer.WriteRaw("			<maml:description></maml:description>\r\n");

                writer.WriteRaw("		</command:returnValue>\r\n");


                //End command:inputTypes section
                writer.WriteRaw("	</command:returnValues>\r\n");

                //<command:returnValues>
                //  <command:returnValue>
                //    <dev:type>
                //      <maml:name><!-- Output Type --></maml:name>
                //      <maml:uri />
                //      <maml:description>
                //        <maml:para>
                //          <!-- Output type description  -->

                //        </maml:para>
                //      </maml:description>
                //    </dev:type>
                //    <maml:description></maml:description>
                //  </command:returnValue>
                //</command:returnValues>

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            return writer;
        }
        //private String XMLEncode(String encodedString)
        //{
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //}
        public XmlWriter writeCmdletDetails(XmlWriter writer, cmdletDescription result)
        {

            //ns.AddNamespace("", "http://msh");
            //ns.AddNamespace("command", "http://schemas.microsoft.com/maml/dev/command/2004/10");
            //ns.AddNamespace("maml", "http://schemas.microsoft.com/maml/2004/10");
            //ns.AddNamespace("dev","http://schemas.microsoft.com/maml/dev/2004/10");
            //String OutString = result.Members["Verb"].Value + "\n";
            //OutString += result.Members["Noun"].Value + "\n";
            //Write <commnd:details>
            //  foreach (cmdletDescription result in CmdletsHelps)
            //{
            try
            {
                writer.WriteRaw("<!--Generated by Help Cmdlet Editor-->\r\n");
                writer.WriteRaw("	<command:details>\r\n");
                writer.WriteRaw("		<command:name>");

                //Write cmdletName
                writer.WriteRaw(HttpUtility.HtmlEncode(result.CmdletName));
                writer.WriteRaw("</command:name>\r\n");

                //Short Description
                writer.WriteRaw("		<maml:description>\r\n");
                writer.WriteRaw("			<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.ShortDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("		</maml:description>\r\n");
                // writer.WriteRaw("\r\n    <maml:copyright>\r\n        <maml:para></maml:para>\r\n    </maml:copyright>\r\n");
                //Write CopyRight info:
                writer.WriteRaw("		<maml:copyright>\r\n");
                writer.WriteRaw("           <maml:para />\r\n");
                writer.WriteRaw("		<!--Add copy right info here.-->\r\n");
                //writer.WriteRaw();
                writer.WriteRaw("		</maml:copyright>\r\n");


                //Write Noun and Verb
                writer.WriteRaw("		<command:verb>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Verb));
                writer.WriteRaw("</command:verb>\r\n");
                writer.WriteRaw("		<command:noun>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Noun));
                writer.WriteRaw("</command:noun>\r\n");

                //Add Dev version
                writer.WriteRaw("		<!--Add Dev version info here.-->\r\n");
                writer.WriteRaw("		<dev:version />\r\n");
                //writer.WriteRaw();

                //End </commnd:details>
                writer.WriteRaw("	</command:details>\r\n");


                //Add Cmdlet detailed description
                writer.WriteRaw("	<maml:description>\r\n");
                writer.WriteRaw("	<!--This is the Description section-->\r\n");
                writer.WriteRaw("		<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.LongDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("	</maml:description>\r\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            // writer.WriteRaw();

            // }
            return writer;

        }
Esempio n. 12
0
        public XmlWriter createSyntaxItem(XmlWriter writer, parameterDecription param, cmdletDescription Cmdlet)
        {
            try
            {
                // foreach (PSObject result in results)
                // {
                // String LocalParamDescription = "";
                Boolean Globbing   = param.Globbing;
                String  cmdletName = Cmdlet.CmdletName; // TODO add real CmdletName CmdletsList.SelectedValue.ToString();
                //foreach (HelpEditor.parameterDecription param in parametersDescription)
                //{

                //    if ((param.Name.ToLower() == Parameterecord.Name.ToLower()) && (cmdletName == param.CmdletName))
                //    {
                //        LocalParamDescription = param.NewDescription;
                //        Globbing = param.Globbing;
                //        break;
                //    }
                //}



                // Parameter Metadata for the Syntax Item section.
                writer.WriteRaw("			<command:parameter ");
                writer.WriteRaw("required = \"" + param.isMandatory.ToString().ToLower() + "\"");
                //Do variable length verification
                String parametertype  = param.ParameterType;
                int    LengthName     = parametertype.Length;
                String VariableLength = "false";

                if (LengthName > 2)
                {
                    if (parametertype[LengthName - 1] == ']' && parametertype[LengthName - 2] == '[')
                    {
                        VariableLength = "true";
                    }
                }

                writer.WriteRaw(" variableLength = \"" + VariableLength + "\"");
                // TODO add code for globbing here.
                String strGlobbing = "false";
                if (Globbing)
                {
                    strGlobbing = "true";
                }
                writer.WriteRaw(" globbing = \"" + strGlobbing + "\"");

                String pipelineInput;
                if (param.VFP || param.VFPBPN)
                {
                    pipelineInput = "true (";
                    if (param.VFP)
                    {
                        pipelineInput += "ByValue";
                    }
                    if (param.VFPBPN)
                    {
                        if (pipelineInput.Length > 6)
                        {
                            pipelineInput += ", ByPropertyName)";
                        }
                        else
                        {
                            pipelineInput += "ByPropertyName)";
                        }
                    }
                    else
                    {
                        pipelineInput += ")";
                    }
                }
                else
                {
                    pipelineInput = "false";
                }
                writer.WriteRaw(" pipelineInput = \"" + pipelineInput + "\"");

                //Positional?
                // int position;
                // if (param.Position < 0)
                // {
                //    writer.WriteRaw(" position = \"named\">");
                // }
                // else
                // {
                //     position = (Parameterecord.Position + 1);
                writer.WriteRaw(" position = \"" + param.Position + "\" >\r\n");
                // }


                //Maml parameter name.
                //  writer.WriteRaw("				<!--Parameter Name-->\r\n");
                writer.WriteRaw("				<maml:name>");

                writer.WriteRaw(HttpUtility.HtmlEncode(param.Name));
                writer.WriteRaw("</maml:name>\r\n");


                //Parameter description

                //  writer.WriteRaw("maml", "para", "http://schemas.microsoft.com/maml/2004/10");
                writer.WriteRaw("				<maml:description>\r\n");
                // writer.WriteRaw("				<!--Parameter Description->\r\n");
                //Get the description from the struc.
                writer.WriteRaw("					<maml:para>");

                writer.WriteRaw(HttpUtility.HtmlEncode(param.NewDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("				</maml:description>\r\n");

                string paramValueRequired = "true";
                if (param.ParameterType.ToLower() != "switchparameter")
                {
                    //Additional parameter Values
                    if (param.ParameterType.ToLower() == "boolean")
                    {
                        paramValueRequired = "false";
                    }
                    //Additional parameter Values
                    writer.WriteRaw("			<command:parameterValue ");
                    writer.WriteRaw("required=\"" + paramValueRequired + "\"");
                    writer.WriteRaw(" variableLength = \"" + VariableLength + "\" >");
                    writer.WriteRaw(HttpUtility.HtmlEncode(param.ParameterType));
                    writer.WriteRaw("</command:parameterValue>\r\n");
                }

                //End <command:prameter>
                writer.WriteRaw("			</command:parameter>\r\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }


            //}
            return(writer);
        }
Esempio n. 13
0
        public XmlWriter createOutputSection(XmlWriter writer, cmdletDescription result)
        {
            try
            {
                //Input Types Section
                writer.WriteRaw("	<command:returnValues>\r\n");
                writer.WriteRaw("		<command:returnValue>\r\n");
                writer.WriteRaw("			<dev:type>\r\n");

                //Input Type
                writer.WriteRaw("				<maml:name>");
                //writer.WriteComment("Output Type");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.OutputType));
                writer.WriteRaw("</maml:name>\r\n");

                //Input Uri
                writer.WriteRaw("				<maml:uri />\r\n");
                //writer.WriteComment("Uri section not used");
                //writer.WriteRaw();

                //Input Type
                writer.WriteRaw("				<maml:description>\r\n");
                //writer.WriteComment("Output type description");
                writer.WriteRaw("					<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.OutputDesc));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("				</maml:description>\r\n");


                //End dev:type
                writer.WriteRaw("			</dev:type>\r\n");

                //End command:inputType
                writer.WriteRaw("			<maml:description></maml:description>\r\n");

                writer.WriteRaw("		</command:returnValue>\r\n");


                //End command:inputTypes section
                writer.WriteRaw("	</command:returnValues>\r\n");

                //<command:returnValues>
                //  <command:returnValue>
                //    <dev:type>
                //      <maml:name><!-- Output Type --></maml:name>
                //      <maml:uri />
                //      <maml:description>
                //        <maml:para>
                //          <!-- Output type description  -->

                //        </maml:para>
                //      </maml:description>
                //    </dev:type>
                //    <maml:description></maml:description>
                //  </command:returnValue>
                //</command:returnValues>
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            return(writer);
        }
Esempio n. 14
0
        //private String XMLEncode(String encodedString)
        //{
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //    encodedString = encodedString.Replace("<", "&lt;");
        //}
        public XmlWriter writeCmdletDetails(XmlWriter writer, cmdletDescription result)
        {
            //ns.AddNamespace("", "http://msh");
            //ns.AddNamespace("command", "http://schemas.microsoft.com/maml/dev/command/2004/10");
            //ns.AddNamespace("maml", "http://schemas.microsoft.com/maml/2004/10");
            //ns.AddNamespace("dev","http://schemas.microsoft.com/maml/dev/2004/10");
            //String OutString = result.Members["Verb"].Value + "\n";
            //OutString += result.Members["Noun"].Value + "\n";
            //Write <commnd:details>
            //  foreach (cmdletDescription result in CmdletsHelps)
            //{
            try
            {
                writer.WriteRaw("<!--Generated by Help Cmdlet Editor-->\r\n");
                writer.WriteRaw("	<command:details>\r\n");
                writer.WriteRaw("		<command:name>");

                //Write cmdletName
                writer.WriteRaw(HttpUtility.HtmlEncode(result.CmdletName));
                writer.WriteRaw("</command:name>\r\n");

                //Short Description
                writer.WriteRaw("		<maml:description>\r\n");
                writer.WriteRaw("			<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.ShortDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("		</maml:description>\r\n");
                // writer.WriteRaw("\r\n    <maml:copyright>\r\n        <maml:para></maml:para>\r\n    </maml:copyright>\r\n");
                //Write CopyRight info:
                writer.WriteRaw("		<maml:copyright>\r\n");
                writer.WriteRaw("           <maml:para />\r\n");
                writer.WriteRaw("		<!--Add copy right info here.-->\r\n");
                //writer.WriteRaw();
                writer.WriteRaw("		</maml:copyright>\r\n");


                //Write Noun and Verb
                writer.WriteRaw("		<command:verb>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Verb));
                writer.WriteRaw("</command:verb>\r\n");
                writer.WriteRaw("		<command:noun>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.Noun));
                writer.WriteRaw("</command:noun>\r\n");

                //Add Dev version
                writer.WriteRaw("		<!--Add Dev version info here.-->\r\n");
                writer.WriteRaw("		<dev:version />\r\n");
                //writer.WriteRaw();

                //End </commnd:details>
                writer.WriteRaw("	</command:details>\r\n");


                //Add Cmdlet detailed description
                writer.WriteRaw("	<maml:description>\r\n");
                writer.WriteRaw("	<!--This is the Description section-->\r\n");
                writer.WriteRaw("		<maml:para>");
                writer.WriteRaw(HttpUtility.HtmlEncode(result.LongDescription));
                writer.WriteRaw("</maml:para>\r\n");
                writer.WriteRaw("	</maml:description>\r\n");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error writing the XML File.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            // writer.WriteRaw();

            // }
            return(writer);
        }
        /// <summary>
        /// This routine handles the Save button on the Related Link page
        /// It adds the new record to the tree.
        /// If this is already in the tree it updates it with the latest
        /// info in the page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void AddRelatedLink_Click(object sender, RoutedEventArgs args)
        {
            TreeViewItem SelectedNode = (TreeViewItem)MainWindow.NavControl.CmdletTreeView.SelectedItem;

            if (SelectedNode != null)
            {
                int count = SelectedNode.Items.Count;
                if (this.RelatedLinks1.LinkIDTextBox.Text == "")
                //This is a new link
                {
                    //Add new related link info.
                    TreeViewItem      ParentNode = (TreeViewItem)SelectedNode.Parent;
                    cmdletDescription Cmdletdesc = (cmdletDescription)ParentNode.DataContext;
                    int LinkCount = 0;
                    if (Cmdletdesc.RelatedLinks != null)
                    {
                        LinkCount = Cmdletdesc.RelatedLinks.Count;
                    }

                    relatedlink linkDetails = new relatedlink();
                    linkDetails.LinkText = this.RelatedLinks1.RelatedLinkTextBox.Text;
                    linkDetails.LinkID   = LinkCount;
                    TreeViewItem NewLinkNode = new TreeViewItem();
                    NewLinkNode.DataContext = linkDetails;
                    NewLinkNode.Header      = linkDetails.LinkText;
                    if (Cmdletdesc.RelatedLinks == null)
                    {
                        Collection <relatedlink> Links = new Collection <relatedlink>();
                        Links.Add(linkDetails);
                        Cmdletdesc.RelatedLinks  = Links;
                        SelectedNode.DataContext = Links;
                    }
                    else
                    {
                        Cmdletdesc.RelatedLinks.Add(linkDetails);
                    }
                    MainWindow.ResetLinksPage();

                    if ((String)SelectedNode.Header == "Related Links")
                    {
                        if (sender != null)
                        {
                            SelectedNode.Items.Add(NewLinkNode);
                            SelectedNode.IsExpanded = true;
                            TreeViewItem ChildNode = (TreeViewItem)SelectedNode.Items[count];
                            ChildNode.IsSelected = true;
                        }
                        else
                        {
                            SelectedNode.Items.Add(NewLinkNode);
                            SelectedNode.IsExpanded = true;
                        }
                    }
                }

                else //this is an existing link
                {
                    if (SelectedNode.Header.ToString() == "Related Links")
                    {
                        //Update link info.
                        Collection <relatedlink> linkDetails = (Collection <relatedlink>)SelectedNode.DataContext;
                        relatedlink linkDetail = new relatedlink();
                        linkDetail.LinkText = this.RelatedLinks1.RelatedLinkTextBox.Text;
                        linkDetails.Add(linkDetail);
                    }
                    else
                    {
                        relatedlink linkDetails = (relatedlink)SelectedNode.DataContext;
                        linkDetails.LinkText = this.RelatedLinks1.RelatedLinkTextBox.Text;
                        SelectedNode.Header  = this.RelatedLinks1.RelatedLinkTextBox.Text;
                    }
                }
            }
        }