Exemplo n.º 1
0
        /// <summary>
        /// Prints preview of all methods under the specified node to the provided printers according to the current settings.
        /// </summary>
        private void PrintMethodPreview(TreeNode node, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst)
        {
            // this can take some time - try to not appear hung
            int    tick_count1     = Environment.TickCount;
            int    tick_count2     = unchecked (tick_count1 + 1);
            Cursor original_cursor = Cursor.Current;

            // this is a node representing a type - get signatures of all its methods
            ILogPrinter mem_log = new LogMemoryPrinter();
            bool        first   = true;

            try
            {
                foreach (TreeNode child in node.Nodes)
                {
                    MethodDescriptor method_descr = child.Tag as MethodDescriptor;
                    if (method_descr != null)
                    {
                        if (!first)
                        {
                            codePrinter.PrintLn();
                            codePrinter.PrintLn();
                        }
                        else
                        {
                            first = false;
                        }

                        // print no messages and no definitions
                        PrintMethod(method_descr, codePrinter, mem_log, printDefs, defsFirst);

                        int ticks = Environment.TickCount;
                        if (ticks != tick_count1 && ticks != tick_count2)
                        {
                            // it's taking too long
                            tick_count1 = Environment.TickCount;
                            tick_count2 = unchecked (tick_count1 + 1);

                            Application.DoEvents();

                            // re-set the selection on rich text box controls because DoEvents may have
                            // included some undesired user input
                            richTextBoxCode.Select(richTextBoxCode.TextLength, 0);
                            richTextBoxMessages.Select(richTextBoxMessages.TextLength, 0);

                            Cursor.Current = Cursors.WaitCursor;
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current = original_cursor;
            }

            logPrinter.PrintEntry(
                Severity.Info, 0,
                "Please select an individual method in the tree to view additional information.");
        }
Exemplo n.º 2
0
        private static void PrintNativeSignature(NativeSignature nativeSig)
        {
            PrintFlags p_flags = PrintFlags.None;

            if (options.UsePlainCDataTypes)
            {
                p_flags |= PrintFlags.UsePlainC;
            }
            if (options.PrintMarshalDirection)
            {
                p_flags |= PrintFlags.PrintMarshalDirection;
            }

            LogMemoryPrinter log_mem_printer = new LogMemoryPrinter();

            // print definitions first
            if (!options.SuppressTypeDefinitions)
            {
                foreach (NativeTypeDefinition def in nativeSig.GetDefinitions())
                {
                    def.PrintTo(codePrinter, log_mem_printer, p_flags);
                    codePrinter.PrintLn();
                    codePrinter.PrintLn();
                }
            }

            // and then the method signature
            nativeSig.PrintTo(codePrinter, log_mem_printer, p_flags);
            codePrinter.PrintLn();
            codePrinter.PrintLn();

            // flush the log_mem_printer to the real log printer
            if (!options.SuppressMessages)
            {
                log_mem_printer.ReplayTo(logPrinter);
                logPrinter.Separate();
            }
        }