Exemplo n.º 1
0
        //--------------------------------------------------------
        private void butTrace_Click(object sender, EventArgs e)
        {
            TTrace.Options.SendProcessName = chkSendProcessName.Checked;
            string str = '\u2250' + "qwerty & @ € é ù è azerty" + '\u9999';

            // simple traces
            //--------------------------------------------
            TTrace.Debug.Send("Hello").Send("World"); // "World" is a sub trace of "Hello"

            // single separator
            TTrace.Debug.Send("---");

            // send traces with special font style (bold and Italic), color font size and font name
            TTrace.Debug.Send("Special font", "Symbol 12")
            .SetFontDetail(-1, false, true)                                           // set whole line to italic
            .SetFontDetail(3, true, false, Color.Red.ToArgb())                        // set col 3 (Left Msg)  to bold and Red
            .SetFontDetail(4, false, false, Color.Green.ToArgb(), 12, "Symbol");      // set col 4 (Right Msg) to Green , font size 12 , Symbol
            TTrace.Debug.Send("Impact Italic")
            .SetFontDetail(3, false, true, Color.BlueViolet.ToArgb(), 12, "Impact");  // Col3 (left msg), non bold, Italic , Blue-Violet , font 12 , Impact

            TTrace.Debug.Send("Special chars", "€ é ù è $ ");

            // The characters to encode:
            //    Latin Small Letter Z (U+007A)
            //    Latin Small Letter A (U+0061)
            //    Combining Breve (U+0306)
            //    Latin Small Letter AE With Acute (U+01FD)
            //    Greek Small Letter Beta (U+03B2)
            //    a high-surrogate value (U+D8FF)
            //    a low-surrogate value (U+DCFF)
            //char[] myChars = new char[] { 'z', 'a', '\u0306', '\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };
            //TTrace.Debug.Send("Other Special chars", new StringBuilder().Append(myChars).ToString());  // myChars.ToString() return  "char[]"

            // double separator
            TTrace.Debug.Send("===");

            //TTrace.Options.SendThreadId = false ;
            //TTrace.Debug.Send("trace without thread id");
            //TTrace.Options.SendThreadId = true;

            //TTrace.Options.SendDate = true;
            //TTrace.Debug.Send("trace with date");
            //TTrace.Options.SendDate = false;

            // traces using Sendxxx method
            //--------------------------------------------
            // Use default display filter. (see TTrace.Options)

            TTrace.Debug.SendType("Object base type", typeof(Object));
            TTrace.Debug.SendType("My interface", typeof(Myinterface));
            TTrace.Debug.SendObject("My const", TraceConst.CST_CREATE_MEMBER);
            TTrace.Debug.SendObject("My enum", testClass.fieldDay);
            TTrace.Debug.SendCaller("SendCaller test", 0);
            TTrace.Debug.SendStack("Stack test", 0);
            TTrace.Debug.SendDump("SendDump test", "Unicode", Encoding.Unicode.GetBytes(str), 50);

            TTrace.Warning.SendType("SendType 'testClass'", testClass.GetType());

            // specify what to send (modifiers, fields, ...). Can be slow on complexe objects
            TraceDisplayFlags flags = TraceDisplayFlags.ShowModifiers |
                                      TraceDisplayFlags.ShowInheritedMembers |
                                      TraceDisplayFlags.ShowNonPublic |
                                      TraceDisplayFlags.ShowFields;

            if (chkSendFunctions.Checked)
            {
                flags |= TraceDisplayFlags.ShowMethods;
            }
            TTrace.Error.SendObject("SendObject 'testClass'", testClass, flags);

            // traces using TraceNodeEx
            //--------------------------------------------
            TraceNodeEx node = new TraceNodeEx(null); //  TTrace.Debug

            node.LeftMsg  = "TraceNodeEx";
            node.RightMsg = str;
            node.AddFontDetail(3, false, false, Color.Green.ToArgb());
            node.IconIndex = 8;
            node.Members.Add("My Members", "col2", "col3")
            .SetFontDetail(0, true)                                      // set first column to bold
            .SetFontDetail(1, false, false, Color.Green.ToArgb())        // set second column to green
            .Add("Sub members")                                          // add sub member node
            .SetFontDetail(0, false, true);                              // set first column to Italic
            node.AddDump("ASCII", Encoding.ASCII.GetBytes(str), 50);     // 3F 61 7A          ..... 3F
            node.AddDump("UTF8", Encoding.UTF8.GetBytes(str), 50);
            node.AddDump("Unicode", Encoding.Unicode.GetBytes(str), 50); // 50 22 61 00 7A 00 ..... 99 99
            node.AddStackTrace(0);
            node.AddCaller();
            TraceNode sendNode = node.Send();

            sendNode.ResendIconIndex(5); // change icon index after the node is send

            // XML sample using Send
            //--------------------------------------------
            TTrace.Debug.SendXml("xml", "<?xml version='1.0' ?><Data> Hello XML </Data>");

            // Image sample using Send
            //--------------------------------------------
            TTrace.Debug.SendBitmap("Bitmap", pictureBox1.Image);

            // Text, image and XML together
            //--------------------------------------------
            node         = new TraceNodeEx(TTrace.Debug);
            node.LeftMsg = "Text, image and XML together";
            node.Members.Add("Text displayed in detail");
            node.AddBitmap(pictureBox1.Image);
            node.AddXML("<?xml version='1.0' ?><Data> Xml in traceNodeEx </Data>");
            node.Send();

            // send table detail
            //--------------------------------------------

            // create the table
            TraceTable table = new TraceTable();

            // add titles. Individual columns titles can be added or multiple columns , separated by tabs
            table.AddColumnTitle("colA");                 // first column title
            table.AddColumnTitle("colB");                 // second column title
            table.AddColumnTitle("title column C\tcolD"); // other columns title (tab separated)

            // add first line. Individual columns data can be added or multiple columns , separated by tabs
            table.AddRow();
            table.AddRowData("a");                                        // add first col
            table.AddRowData("b" + "\t" + "c" + "\t" + "d" + "\t" + "e"); // then add other columns (tab separated)

            // add second line
            table.AddRow();
            table.AddRowData("aa" + "\t" + "data second column" + "\t" + "cc" + "\t" + "dd" + "\t" + "ee"); // add all columns data in a single step (tab separated)

            // finally send the table
            TTrace.Debug.SendTable("Mytable", table);

            ParsedObjectList objList = new ParsedObjectList();

            objList.Add(testClass);
            objList.Add(test2);
            TTrace.Debug.SendTable("Generic table", objList);

            List <int> intCollection = new List <int>();

            for (int c = 0; c < 500; c++)
            {
                intCollection.Add(c);
            }
            TTrace.Debug.SendTable("int Collection", intCollection);


            // group of traces enabled / disabled
            TraceNode databinding = new TraceNode(null, false);

            databinding.IconIndex = 5;

            databinding.Enabled = true;
            databinding.Send("databing traces 1");
            databinding.Enabled = false;
            databinding.Send("databing traces 2");

            // ensure all traces are send to the viewer
            TTrace.Flush();
        }
Exemplo n.º 2
0
        //--------------------------------------------------------
        private void butTrace_Click(object sender, EventArgs e)
        {
            TTrace.Options.SendProcessName = chkSendProcessName.Checked;
               string str = '\u2250' + "qwerty & @ € é ù è azerty" + '\u9999';

               // simple traces
               //--------------------------------------------
               TTrace.Debug.Send("Hello").Send("World");  // "World" is a sub trace of "Hello"

               // single separator
               TTrace.Debug.Send("---");

               // send traces with special font style (bold and Italic), color font size and font name
               TTrace.Debug.Send("Special font", "Symbol 12")
               .SetFontDetail(-1, false, true)                                        // set whole line to italic
               .SetFontDetail(3, true, false, Color.Red.ToArgb())                     // set col 3 (Left Msg)  to bold and Red
               .SetFontDetail(4, false, false, Color.Green.ToArgb(), 12, "Symbol");   // set col 4 (Right Msg) to Green , font size 12 , Symbol
               TTrace.Debug.Send("Impact Italic")
               .SetFontDetail(3, false, true, Color.BlueViolet.ToArgb(), 12, "Impact");     // Col3 (left msg), non bold, Italic , Blue-Violet , font 12 , Impact

               TTrace.Debug.Send("Special chars", "€ é ù è $ ");

               // The characters to encode:
               //    Latin Small Letter Z (U+007A)
               //    Latin Small Letter A (U+0061)
               //    Combining Breve (U+0306)
               //    Latin Small Letter AE With Acute (U+01FD)
               //    Greek Small Letter Beta (U+03B2)
               //    a high-surrogate value (U+D8FF)
               //    a low-surrogate value (U+DCFF)
               //char[] myChars = new char[] { 'z', 'a', '\u0306', '\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };
               //TTrace.Debug.Send("Other Special chars", new StringBuilder().Append(myChars).ToString());  // myChars.ToString() return  "char[]"

               // double separator
               TTrace.Debug.Send("===");

               //TTrace.Options.SendThreadId = false ;
               //TTrace.Debug.Send("trace without thread id");
               //TTrace.Options.SendThreadId = true;

               //TTrace.Options.SendDate = true;
               //TTrace.Debug.Send("trace with date");
               //TTrace.Options.SendDate = false;

               // traces using Sendxxx method
               //--------------------------------------------
               // Use default display filter. (see TTrace.Options)

               TTrace.Debug.SendType("Object base type", typeof(Object));
               TTrace.Debug.SendType("My interface", typeof(Myinterface));
               TTrace.Debug.SendObject("My const", TraceConst.CST_CREATE_MEMBER);
               TTrace.Debug.SendObject("My enum", testClass.fieldDay);
               TTrace.Debug.SendCaller("SendCaller test", 0);
               TTrace.Debug.SendStack("Stack test", 0);
               TTrace.Debug.SendDump("SendDump test", "Unicode", Encoding.Unicode.GetBytes(str), 50);

               TTrace.Warning.SendType("SendType 'testClass'", testClass.GetType());

            // specify what to send (modifiers, fields, ...). Can be slow on complexe objects
               TraceDisplayFlags flags = TraceDisplayFlags.ShowModifiers |
                                      TraceDisplayFlags.ShowInheritedMembers |
                                      TraceDisplayFlags.ShowNonPublic |
                                      TraceDisplayFlags.ShowFields;

               if (chkSendFunctions.Checked)
              flags |= TraceDisplayFlags.ShowMethods;
               TTrace.Error.SendObject("SendObject 'testClass'", testClass, flags);

               // traces using TraceNodeEx
               //--------------------------------------------
               TraceNodeEx node = new TraceNodeEx(null);  //  TTrace.Debug
               node.LeftMsg = "TraceNodeEx";
               node.RightMsg = str;
               node.AddFontDetail(3, false, false, Color.Green.ToArgb());
               node.IconIndex = 8;
               node.Members.Add("My Members", "col2", "col3")
              .SetFontDetail(0, true)                                 // set first column to bold
              .SetFontDetail(1, false, false, Color.Green.ToArgb())   // set second column to green
              .Add("Sub members")                                     // add sub member node
                 .SetFontDetail(0, false, true);                      // set first column to Italic
               node.AddDump("ASCII", Encoding.ASCII.GetBytes(str), 50);   // 3F 61 7A          ..... 3F
               node.AddDump("UTF8", Encoding.UTF8.GetBytes(str), 50);
               node.AddDump("Unicode", Encoding.Unicode.GetBytes(str), 50); // 50 22 61 00 7A 00 ..... 99 99
               node.AddStackTrace(0);
               node.AddCaller();
               TraceNode sendNode = node.Send();
               sendNode.ResendIconIndex(5);  // change icon index after the node is send

               // XML sample using Send
               //--------------------------------------------
               TTrace.Debug.SendXml("xml", "<?xml version='1.0' ?><Data> Hello XML </Data>");

               // Image sample using Send
               //--------------------------------------------
               TTrace.Debug.SendBitmap("Bitmap", pictureBox1.Image);

               // Text, image and XML together
               //--------------------------------------------
               node = new TraceNodeEx(TTrace.Debug);
               node.LeftMsg = "Text, image and XML together";
               node.Members.Add("Text displayed in detail");
               node.AddBitmap(pictureBox1.Image);
               node.AddXML("<?xml version='1.0' ?><Data> Xml in traceNodeEx </Data>");
               node.Send();

               // send table detail
               //--------------------------------------------

               // create the table
               TraceTable table = new TraceTable();

               // add titles. Individual columns titles can be added or multiple columns , separated by tabs
               table.AddColumnTitle("colA");          // first column title
               table.AddColumnTitle("colB");          // second column title
               table.AddColumnTitle("title column C\tcolD");  // other columns title (tab separated)

               // add first line. Individual columns data can be added or multiple columns , separated by tabs
               table.AddRow();
               table.AddRowData("a");                           // add first col
               table.AddRowData("b" + "\t" + "c" + "\t" + "d" + "\t" + "e");            // then add other columns (tab separated)

               // add second line
               table.AddRow();
               table.AddRowData("aa" + "\t" + "data second column" + "\t" + "cc" + "\t" + "dd" + "\t" + "ee");  // add all columns data in a single step (tab separated)

               // finally send the table
               TTrace.Debug.SendTable("Mytable", table);

               ParsedObjectList objList = new ParsedObjectList() ;
               objList.Add (testClass) ;
               objList.Add (test2) ;
               TTrace.Debug.SendTable("Generic table",objList );

               List<int> intCollection = new List<int>();
               for (int c = 0; c < 500; c++)
              intCollection.Add(c);
               TTrace.Debug.SendTable("int Collection", intCollection);

               // group of traces enabled / disabled
               TraceNode databinding = new TraceNode(null, false);
               databinding.IconIndex = 5;

               databinding.Enabled = true;
               databinding.Send("databing traces 1");
               databinding.Enabled = false;
               databinding.Send("databing traces 2");

               // ensure all traces are send to the viewer
               TTrace.Flush();
        }