Ejemplo n.º 1
0
        private void treeView2_AfterSelect( object sender, TreeViewEventArgs e )
        {
            if ( e.Node == null )
                return;

            LibraryMember lm = ( LibraryMember )e.Node.Tag;
            Library lib = lm.Library;
            Member memb = lm.Member;

            if ( memb is Function )
            {
                Function func = ( Function )memb;
                HTML doc = new HTML();
                doc.Header();
                doc.AddLine( func.Return + " " );
                doc.AddLine( "<b>" );
                doc.AddLine( func.Name );
                doc.AddLine( "</b>" );
                doc.AddLine( "(" );
                string paramText = "";
                foreach ( Parameter param in func.Parameters )
                {
                    paramText += param.DataType + " " + param.Name + ", ";
                }
                paramText = paramText.TrimEnd( ',', ' ' );
                doc.AddLine( paramText + ")\n\n" );
                doc.AddLine( "<b>" );
                doc.AddLine( "Summary:" );
                doc.AddLine( "</b>" );
                doc.AddLine( "\n" + func.Description + "\n\n" );
                if ( func.Parameters.Count > 0 )
                {
                    doc.AddLine( "<b>" );
                    doc.AddLine( "Parameters:" );
                    doc.AddLine( "</b>" );
                }
                foreach ( Parameter param in func.Parameters )
                {
                    doc.AddLine("<i>");
                    doc.AddLine( "\n" + param.Name );
                    doc.AddLine( "</i>" );
                    doc.AddLine( ": " + param.Description );
                }
                doc.AddLine("\n\n");
                doc.AddLine("Wiki: <a href=\"http://www.garrysmod.com/wiki/?title=" + lib.Name + "." + func.Name + "\">" + lib.Name + "." + func.Name + "</a>");
                doc.Footer();
                wb.DocumentStream = doc.GetStream();

            }
            else if ( memb is Property )
            {
                Property prop = ( Property )memb;

                HTML doc = new HTML();
                doc.Header();
                doc.AddLine( prop.DataType + " " );
                doc.AddLine( "<b>" );
                doc.AddLine( lib.Name );
                doc.AddLine( "</b>" );
                doc.AddLine( "." );
                doc.AddLine( "<b>" );
                doc.AddLine( prop.Name );
                doc.AddLine( "</b>" );
                doc.AddLine( "\n\n" );
                doc.AddLine( "<b>" );
                doc.AddLine( "Summary:" );
                doc.AddLine( "</b>" );
                doc.AddLine( "\n" + prop.Description );
                doc.Footer();
                wb.DocumentStream = doc.GetStream();
            }
        }
Ejemplo n.º 2
0
        private void treeView1_AfterSelect( object sender, TreeViewEventArgs e )
        {
            if ( e.Node == null )
                return;

            if ( e.Node.Tag is Library )
            {
                Library lib = ( Library )e.Node.Tag;
                treeView2.Nodes.Clear();

                foreach ( Member memb in lib.Members )
                {
                    TreeNode tn = new TreeNode();
                    LibraryMember lm = new LibraryMember();
                    lm.Library = lib;
                    lm.Member = memb;

                    if ( memb is Function )
                    {
                        Function func = ( Function )memb;
                        tn.Text = func.Name + "(" + func.Params + ")";
                        tn.Tag = lm;
                        switch ( func.Type )
                        {
                            case "SHARED":
                                tn.ImageKey = "shared";
                                tn.SelectedImageKey = "shared";
                                break;
                            case "SERVER":
                                tn.ImageKey = "server";
                                tn.SelectedImageKey = "server";
                                break;
                            case "CLIENT":
                                tn.ImageKey = "client";
                                tn.SelectedImageKey = "client";
                                break;
                        }
                    }
                    else if ( memb is Property )
                    {
                        Property prop = ( Property )memb;
                        tn.Text = prop.Name;
                        tn.Tag = lm;
                        switch ( prop.Type )
                        {
                            case "SHARED":
                                tn.ImageKey = "shared";
                                tn.SelectedImageKey = "shared";
                                break;
                            case "SERVER":
                                tn.ImageKey = "server";
                                tn.SelectedImageKey = "server";
                                break;
                            case "CLIENT":
                                tn.ImageKey = "client";
                                tn.SelectedImageKey = "client";
                                break;
                        }
                    }

                    treeView2.Nodes.Add( tn );

                }

                HTML doc = new HTML();
                doc.Header();
                doc.AddLine( "Library " );
                doc.AddLine("<b>");
                doc.AddLine( lib.Name );
                doc.AddLine("</b>");
                doc.AddLine( "\n\n" );
                doc.AddLine("<b>");
                doc.AddLine( "Summary:");
                doc.AddLine("</b>");
                doc.AddLine("\n" + lib.Description);
                doc.AddLine("\n\n");
                doc.AddLine("Wiki: <a href=\"http://www.garrysmod.com/wiki/?title=" + lib.Name + "\">" + lib.Name + "</a>");
                doc.Footer();
                wb.DocumentStream = doc.GetStream();
            }
            else if ( e.Node.Tag is LibraryMember )
            {
                treeView2.Nodes.Clear();

                LibraryMember lm = ( LibraryMember )e.Node.Tag;
                Library lib = lm.Library;
                Member memb = lm.Member;

                if ( memb is Function )
                {
                    Function func = ( Function )memb;

                    HTML doc = new HTML();
                    doc.Header();
                    doc.AddLine( func.Return + " " );
                    doc.AddLine( "<b>" );
                    doc.AddLine( lib.Name );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "." );
                    doc.AddLine( "<b>" );
                    doc.AddLine( func.Name );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "(" );
                    string paramText = "";
                    foreach ( Parameter param in func.Parameters )
                    {
                        paramText += param.DataType + " " + param.Name + ", ";
                    }
                    paramText = paramText.TrimEnd( ',', ' ' );
                    doc.AddLine( paramText + ")\n\n" );
                    doc.AddLine( "<b>" );
                    doc.AddLine( "Summary:" );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "\n" + func.Description + "\n\n" );
                    if ( func.Parameters.Count > 0 )
                    {
                        doc.AddLine( "<b>" );
                        doc.AddLine( "Parameters:" );
                        doc.AddLine( "</b>" );
                    }
                    foreach ( Parameter param in func.Parameters )
                    {
                        doc.AddLine("<i>");
                        doc.AddLine( "\n" + param.Name );
                        doc.AddLine( "</i>" );
                        doc.AddLine( ": " + param.Description );
                    }
                    doc.Footer();
                    wb.DocumentStream = doc.GetStream();

                }
                else if ( memb is Property )
                {
                    Property prop = ( Property )memb;

            HTML doc = new HTML();
                    doc.Header();
                    doc.AddLine( prop.DataType + " " );
                    doc.AddLine( "<b>" );
                    doc.AddLine( lib.Name );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "." );
                    doc.AddLine( "<b>" );
                    doc.AddLine( prop.Name );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "\n\n" );
                    doc.AddLine( "<b>" );
                    doc.AddLine( "Summary:" );
                    doc.AddLine( "</b>" );
                    doc.AddLine( "\n" + prop.Description );
                    doc.Footer();
                    wb.DocumentStream = doc.GetStream();
                }
            }
        }