Beispiel #1
0
        //------------------------------------------------------------------------------

        private void IndentButton_Click(object sender, RoutedEventArgs e)
        {
            TraceNode node = TTrace.Debug.Send("Tree indentation using Indent and UnIndent methods");

            node.Indent("Indent", "level 1");
            node.Send("Node1");
            node.Indent("Indent level 2");
            node.Send("Node2");

            // UnIndent with no title
            node.Indent("Indent level 3");
            node.Send("Node3");
            node.UnIndent(); // UnIndent without title

            node.Send("Node4");

            node.UnIndent("UnIndent level 2");
            node.UnIndent("UnIndent level 1");

            // node indentation using traceNodeEx
            TTrace.Debug.Send("root 1", TTrace.Debug.IndentLevel.ToString());
            TTrace.Debug.Indent("start indentation");
            TTrace.Debug.Send("under indent 1", TTrace.Debug.IndentLevel.ToString());
            TraceNodeEx nodeEx = new TraceNodeEx(TTrace.Debug); // Parent depends of the indentation

            nodeEx.LeftMsg = "under indent 2";
            nodeEx.Send();
            TTrace.Debug.UnIndent();
            TTrace.Debug.Send("root 2", TTrace.Debug.IndentLevel.ToString());
        }
Beispiel #2
0
        //----------------------------------------------------------------------

        /// <summary>
        /// Send a 'reflected' representation of the given type
        /// </summary>
        /// <param name="leftMsg">The message to display</param>
        /// <param name="oType">The type to inspect</param>
        /// <param name="flags">flags to limit information to send</param>
        /// <returns>the new node</returns>
        public TraceNode SendType(string leftMsg, Type oType, TraceDisplayFlags flags)
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }

            TraceNodeEx result = new TraceNodeEx(this, true);  // create a node with same properties as "this" with new ID

            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            // detect null type
            if (oType == null)
            {
                TMemberNode node = new TMemberNode("Null Type")
                {
                    ViewerKind = TraceConst.CST_VIEWER_OBJECT
                };
                result.Members.Add(node);
                result.Members.AddToStringList(commandList);
                TTrace.SendToWinTraceClient(commandList, WinTraceId);
                return(new TraceNode(result));
            }

            // information are added to the Members array of the new created object the actual object
            // the current instance can be the public 'Warning' node for example used by multi thread application
            result.AddTypeObject(null, oType, flags);
            result.Members.AddToStringList(commandList); // convert all groups and nested items/group to strings

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #3
0
        //----------------------------------------------------------------------

        /// <summary>
        /// Copy constructor : create a TraceNode copy of a TraceNodeEx
        /// </summary>
        /// <param name="source">TraceNodeEx to copy</param>
        internal TraceNode(TraceNodeEx source)   // TraceToSend base class don't have constructor
        {
            IconIndex  = source.IconIndex;
            Enabled    = source.Enabled;
            WinTraceId = source.WinTraceId;
            Id         = source.Id;
            Tag        = source.Tag;
        }
        //----------------------------------------------------------------------

        /// <summary>
        /// write the event to tracetool
        /// </summary>
        /// <param name="eventContainer"></param>
        public void Write(EventContainer eventContainer)
        {
            if (eventContainer == null)
            {
                throw new ArgumentNullException("eventContainer");
            }

            // create trace node in the log4WinTrace window
            TraceNodeEx node = new TraceNodeEx(this.log4WinTrace.Debug);

            node.LeftMsg  = EventSourceName;
            node.RightMsg = "";               // should be replaced by the message field value

            // add line feed before adding fields
            node.Members.Add("\n");

            // add the class name that generate the message
            node.Members.Add("Event Type", eventContainer.EventType.ToString());

            // deserialize the message using an EventEntrySerializer
            EventEntrySerializer serializer1 = new EventEntrySerializer();

            eventContainer.Evaluate(serializer1);
            EventEntry entry = serializer1.GetEventEntry();

            // get the EventLogEntryTypeID field. the value is a numeric (0 : error, 1: FailureAudit,...)
            Object field = entry["EventLogEntryTypeID"];

            if (field != null)
            {
                try
                {
                    // convert to "error" or "FailureAudit" or ...
                    EventLogEntryType eventLogEntryType = (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), field.ToString(), true);
                    node.Members.Add("EventLog EntryType", eventLogEntryType.ToString());
                }
                catch {}
            }

            // display the fields (key/value) in entry
            foreach (Object key in entry.Keys)
            {
                // check if key is "message" to change the trace node title
                if (node.RightMsg == "")
                {
                    if (key.ToString().ToLower() == "message")
                    {
                        node.RightMsg = entry[key].ToString();
                    }
                }
                node.Members.Add(key.ToString(), entry[key].ToString());
            }
            node.Send();

            // to do : use the "immediateFlush" option
            //TTrace.Flush() ;
        }
Beispiel #5
0
        internal List <NodeContext> WinTraceContext = null; // reference to winTrace Context (fContextList). Can be null

        /// <summary>
        /// The most useful function to send trace
        /// <example> This sample shows how to send a sample trace.
        /// <code>
        /// TTrace.Debug.Send ("Hello world") ;
        /// </code>
        /// <code>
        /// TraceNode FirstNode ;
        /// FirstNode = TTrace.Debug.Send ("Hello") ;
        /// FirstNode.Send ("World") ;   // add a second node under the first one
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="leftMsg">The message to display in the 'traces' column</param>
        /// <returns>the new node</returns>
        public TraceNode Send(string leftMsg)
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }
            // create a node with same properties as "this" with new ID
            TraceNodeEx   result      = new TraceNodeEx(this, true);
            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #6
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// send trace with a specific background color
        /// </summary>
        /// <param name="leftMsg">Trace message</param>
        /// <param name="color">RGB background color (see Color.ToArgb function)</param>
        /// <param name="colId">Column index : All columns= -1,Icon=0, Time=1, thread=2, left msg=3, right msg =4 or user defined column</param>
        /// <returns>the new node</returns>
        public TraceNode SendBackgroundColor(string leftMsg, int color, int colId) // = -1
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }

            TraceNodeEx   result      = new TraceNodeEx(this, true); // create a node with same properties as "this" with new ID
            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            Helper.AddCommand(commandList, TraceConst.CST_BACKGROUND_COLOR, Helper.ARGB_to_BGR(color), colId.ToString());      // param : color, colId

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #7
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Add table to node
        /// </summary>
        /// <param name="leftMsg">Trace message</param>
        /// <param name="table">Object table to send. Must be an Array or IEnumerable or IDictionary</param>
        /// <returns>the new node</returns>
        public TraceNode SendTable(string leftMsg, Object table)
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }

            TraceNodeEx   result      = new TraceNodeEx(this, true); // create a node with same properties as "this" with new ID
            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            result.AddTable(table);
            result.Members.AddToStringList(commandList); // convert all groups and nested items/group to strings

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #8
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Initialise the plugin
        /// </summary>
        public void Start()
        {
            // create a window and ask to receive timer, action and onBeforeDelete events
            PlugTraces = new WinTrace("CSHARP", "CSharp Plugin9");
            PlugTraces.DisplayWin();
            PlugTraces.LinkToPlugin(PlugName,
                                    TraceConst.CST_PLUG_ONACTION +
                                    TraceConst.CST_PLUG_ONBEFOREDELETE +
                                    TraceConst.CST_PLUG_ONTIMER);

            // disable the  LogFile label
            PlugTraces.DisableResource(TraceConst.CST_ACTION_LABEL_LOGFILE);

            // add a menu to the 'window' menu
            PlugTraces.CreateResource(100, TraceConst.CST_RES_MENU_WINDOW, 0, "My CSharp Plug");

            // add a menu to the 'action' menu
            PlugTraces.CreateResource(101, TraceConst.CST_RES_MENU_ACTION, 0, "My CSharp action Plug");

            // add a label on right, autosize (0)
            PlugTraces.CreateResource(102, TraceConst.CST_RES_LABEL_RIGHT, 0, "My label");

            // add a button on right (100 pixels)
            PlugTraces.CreateResource(103, TraceConst.CST_RES_BUT_RIGHT, 100, "STOP");

            // add a label on left, 100 pixels
            PlugTraces.CreateResource(104, TraceConst.CST_RES_LABEL_LEFT, 100, "My status");

            TraceNodeEx node;

            node         = new TraceNodeEx(PlugTraces.Debug);
            node.LeftMsg = "Actions";
            node.Id      = "ActionsNode";
            ActionNodes  = node.Send();

            node              = new TraceNodeEx(PlugTraces.Debug);
            node.LeftMsg      = "Deleted Nodes";
            node.Id           = "BeforeDeletes";
            BeforeDeleteNodes = node.Send();

            node         = new TraceNodeEx(PlugTraces.Debug);
            node.LeftMsg = "Timer";
            node.Id      = "Timer";
            Timer        = node.Send();

            PlugTraces.Debug.Send("Sample CSharp 10.1 Plugin started");
        }
Beispiel #9
0
        //----------------------------------------------------------------------

        /// <summary>
        /// Send a trace specifying the text for 2 columns
        /// <example> This sample shows how to send a sample trace.
        /// <code>
        /// TTrace.Debug.Send ("Hello", "world") ;  // 2 columns trace
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="leftMsg">The message in the "traces" column</param>
        /// <param name="rightMsg">The message in the "Comment" column</param>
        /// <returns>the new node</returns>
        public TraceNode Send(string leftMsg, string rightMsg)
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }
            // create a node with same properties as "this" with new ID
            TraceNodeEx   result      = new TraceNodeEx(this, true);
            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            if (rightMsg != "")
            {
                Helper.AddCommand(commandList, TraceConst.CST_RIGHT_MSG, rightMsg);    // param : right string
            }
            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #10
0
        //----------------------------------------------------------------------
        /// <summary>
        /// Send the Value of the given object (useful for base type, variant and array)
        /// </summary>
        /// <param name="leftMsg">the message to display</param>
        /// <param name="objToSend">The object to show</param>
        /// <param name="sendPrivate">Send Private fields (default is false)</param>
        /// <param name="maxLevel">Max level to inspect (default is 3)</param>
        /// <param name="objTitle">Title of the object</param>
        /// <returns>the new node</returns>
        public TraceNode SendValue(string leftMsg, Object objToSend, bool sendPrivate, int maxLevel, string objTitle)
        {
            if (Enabled == false)
            {
                return(new TraceNode(this));
            }

            TraceNodeEx   result      = new TraceNodeEx(this, true); // create a node with same properties as "this" with new ID
            List <string> commandList = PrepareNewNode(leftMsg, result.Id);

            // information are added to the Members array of the new created object the actual object.
            // This current instance can be the public 'Warning' node for example used by multi thread application
            result.AddValue(objToSend, sendPrivate, maxLevel, objTitle);
            result.Members.AddToStringList(commandList);   // convert all groups and nested items/group to strings

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(new TraceNode(result));
        }
Beispiel #11
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Send a watch
        /// </summary>
        /// <param name="watchName">Watch name</param>
        /// <param name="watchValue">Watch value</param>
        public void Send(string watchName, object watchValue)
        {
            if (Enabled == false)
            {
                return;
            }

            List <string> commandList = new List <string>();

            commandList.Insert(0, String.Format("{0,5}{1}", TraceConst.CST_WATCH_NAME, watchName));

            // create a node with same properties as "self" with new ID
            TraceNodeEx node = new TraceNodeEx(null, false);                                           // no parent, don't generate node id

            node.AddValue(watchValue, TTrace.Options.SendPrivate, TTrace.Options.ObjectTreeDepth, ""); // sendPrivate true , max 3 levels, no title
            node.Members.AddToStringList(commandList);                                                 // convert all groups and nested items/group to strings

            TTrace.SendToWinWatchClient(commandList, Id);
        }
Beispiel #12
0
    //--------------------------------------------------------------------------------------------

    protected void butSample_Click(object sender, EventArgs e)
    {
        TTrace.Debug.Send("VS8 ASP NET F2 demo");

        TTrace.Options.SendProcessName = false;
        string str = '\u2250' + "qwerty é ù è azerty" + '\u9999';

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

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

        TTrace.Debug.SendType("SendType 'Trace node Type'", TTrace.Debug.GetType());
        TTrace.Debug.SendObject("My const", TraceConst.CST_CREATE_MEMBER);
        TTrace.Debug.SendDump("SendDump test", "Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50);

        // TTrace.Debug.SendType ("My abstract type" , typeof (Base));  // same as Type.GetType("Project1.Base")

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

        node.LeftMsg   = "TraceNodeEx";
        node.RightMsg  = "demo";
        node.IconIndex = 8;
        node.AddDump("ASCII", System.Text.Encoding.ASCII.GetBytes(str), 50);     // 3F 61 7A          ..... 3F
        node.AddDump("UTF8", System.Text.Encoding.UTF8.GetBytes(str), 50);
        node.AddDump("Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50); // 50 22 61 00 7A 00 ..... 99 99
        node.Send();


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

        TTrace.Error.SendObject("SendObject 'Trace node Object'", TTrace.Debug, flags);

        TTrace.Flush();
    }
Beispiel #13
0
        //----------------------------------------------------------------------
        /// <summary>
        /// append right text to an existing node
        /// </summary>
        /// <returns>The trace node</returns>
        public TraceNode AppendStack()
        {
            if (Enabled == false)
            {
                return(this);
            }

            if (Id == "")
            {
                throw new Exception("Node Id is null, root node cannot be modified (for now)");
            }

            List <string> commandList = new List <string>();

            Helper.AddCommand(commandList, TraceConst.CST_USE_NODE, Id); // param : guid

            TraceNodeEx result = new TraceNodeEx(this, true);            // create a node with same properties as "this" with new ID

            result.AddStackTrace(1);
            result.Members.AddToStringList(commandList); // convert all groups and nested items/group to strings

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(this);
        }
Beispiel #14
0
        //------------------------------------------------------------------------------

        // send to default : "127.0.0.1" on port 4502
        private void butTrace_Click(object sender, RoutedEventArgs e)
        {
            //TTrace.Debug.SendObject("button1", button1);
            //button1.Width = button1.Width + 10;
            //button1.SetValue(Canvas.LeftProperty, (double)button1.GetValue(Canvas.LeftProperty) + 1);
            TTrace.Options.SendProcessName = (bool)chkSendProcessName.IsChecked;
            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, (int)Helper.ToArgb(Colors.Red))                      // set col 3 (Left Msg)  to bold and Red
            .SetFontDetail(4, false, false, (int)Helper.ToArgb(Colors.Green), 12, "Symbol");    // set col 4 (Right Msg) to Green , font size 12 , Symbol
            TTrace.Debug.Send("Impact Italic")
            .SetFontDetail(3, false, true, (int)Helper.ToArgb(Colors.Orange), 12, "Impact");    // Col3 (left msg), non bold, Italic , Orange , 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 ((bool)chkSendFunctions.IsChecked)
            {
                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, (int)Helper.ToArgb(Colors.Green));
            node.IconIndex = 8;
            node.Members.Add("My Members", "col2", "col3")
            .SetFontDetail(0, true)                                                        // set first column to bold
            .SetFontDetail(1, false, false, (int)Helper.ToArgb(Colors.Green))              // set second column to green
            .Add("Sub members")                                                            // add sub member node
            .SetFontDetail(0, false, true);                                                // set first column to Italic
            node.AddDump("BigEndianUnicode", Encoding.BigEndianUnicode.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
            //--------------------------------------------

            // currently not possibe in silverlight 2 :
            // - No way to read the Image content
            // - BmpBitmapEncoder is not supported
            //TTrace.Debug.SendBitmap("Bitmap", image1);

            // Text and XML together
            //--------------------------------------------
            node         = new TraceNodeEx(TTrace.Debug);
            node.LeftMsg = "Text and XML together";
            node.Members.Add("Text displayed in detail");
            //node.AddBitmap(image1); // currently not possibe in silverlight 2
            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);

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

            GroupTrace.IconIndex = 5;

            GroupTrace.Enabled = true;
            GroupTrace.Send("GroupTrace traces 1"); // send to viewer
            GroupTrace.Enabled = false;
            GroupTrace.Send("GroupTrace traces 2"); // not send : group not enabled

            // ensure all traces are send to the viewer
            TTrace.Flush();
        }
Beispiel #15
0
        //--------------------------------------------------------
        private void IndentButton_Click(object sender, EventArgs e)
        {
            TraceNode node = TTrace.Debug.Send("Tree indentation using Indent and UnIndent methods");

            node.Indent("Indent","level 1");
            node.Send("Node1");
            node.Indent("Indent level 2");
            node.Send("Node2");

            // UnIndent with no title
            node.Indent("Indent level 3");
            node.Send("Node3");
            node.UnIndent();   // UnIndent without title

            node.Send("Node4");

            node.UnIndent("UnIndent level 2");
            node.UnIndent("UnIndent level 1");

            // node indentation using traceNodeEx
            TTrace.Debug.Send   ("root 1", TTrace.Debug.IndentLevel.ToString()) ;
            TTrace.Debug.Indent ("start indentation");
            TTrace.Debug.Send   (   "under indent 1", TTrace.Debug.IndentLevel.ToString());
            TraceNodeEx nodeEx = new TraceNodeEx(TTrace.Debug) ;   // Parent depends of the indentation
            nodeEx.LeftMsg =        "under indent 2" ;
            nodeEx.Send() ;
            TTrace.Debug.UnIndent ();
            TTrace.Debug.Send("root 2", TTrace.Debug.IndentLevel.ToString());
        }
Beispiel #16
0
        //--------------------------------------------------------------------------------------------

        private void butSample_Click(object sender, System.EventArgs e)
        {
            TTrace.Debug.Send("VS7 ppc2003 CF1 demo");

            TTrace.Options.SendProcessName = false;
            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(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 and font size 12
            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.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;

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


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

            TTrace.Debug.SendType("SendType 'Trace node Type'", TTrace.Debug.GetType());
            TTrace.Debug.SendObject("My const", TraceConst.CST_CREATE_MEMBER);
            TTrace.Debug.SendDump("SendDump test", "Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50);

            // TTrace.Debug.SendType ("My abstract type" , typeof (Base));  // same as Type.GetType("Project1.Base")

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

            node.LeftMsg   = "TraceNodeEx";
            node.RightMsg  = "demo";
            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", System.Text.Encoding.ASCII.GetBytes(str), 50);     // 3F 61 7A          ..... 3F
            node.AddDump("UTF8", System.Text.Encoding.UTF8.GetBytes(str), 50);
            node.AddDump("Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50); // 50 22 61 00 7A 00 ..... 99 99
            node.Send();


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

            TTrace.Error.SendObject("SendObject 'Trace node Object'", TTrace.Debug, flags);

            TTrace.Flush();
        }
Beispiel #17
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();
        }
Beispiel #18
0
        private void butTrace_Click(object sender, RoutedEventArgs e)
        {
            // specify what to send (modifiers, fields, ...). Can be slow on complexe objects
            TraceDisplayFlags flags = TraceDisplayFlags.ShowModifiers |
                                      TraceDisplayFlags.ShowInheritedMembers |
                                      TraceDisplayFlags.ShowNonPublic |
                                      TraceDisplayFlags.ShowFields;

            if (ChkSendFunctions.IsChecked != null && (bool)ChkSendFunctions.IsChecked)
            {
                flags |= TraceDisplayFlags.ShowMethods;
            }


            //TTrace.Debug.SendObject("button1", button1);
            //button1.Width = button1.Width + 10;
            //button1.SetValue(Canvas.LeftProperty, (double)button1.GetValue(Canvas.LeftProperty) + 1);
            if (ChkSendProcessName.IsChecked != null)
            {
                TTrace.Options.SendProcessName = (bool)ChkSendProcessName.IsChecked;
            }
            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
            // use System.Drawing.Color.ToArgb() (not supported in Silverlight) or (int)Helper.ToArgb(System.Windows.Media.Color) to specify Argb color
            TTrace.Debug.Send("Special font", "Symbol 12")
            .SetFontDetail(-1, false, true)                                                         // set whole line to italic
            .SetFontDetail(3, true, false, System.Drawing.Color.Red.ToArgb())                       // set col 3 (Left Msg)  to bold and Red
            .SetFontDetail(4, false, false, System.Drawing.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, System.Drawing.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());  // note that 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(IMyinterface));
            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());

            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, System.Drawing.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, System.Drawing.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", Image1);

            // 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(Image1);
            node.AddXML("<?xml version='1.0' ?><Data> Xml in traceNodeEx </Data>");
            node.Send();

            // group of traces enabled / disabled
            //------------------------------------
            TraceNode groupTrace = new TraceNode(null, false); // dummy node not send to viewer

            groupTrace.IconIndex = 5;
            groupTrace.Enabled   = true;
            groupTrace.Send("GroupTrace traces 1"); // send to viewer
            groupTrace.Enabled = false;
            groupTrace.Send("GroupTrace traces 2"); // not send : group not enabled

            // generics
            //------------------------------------
            TTrace.Debug.SendType("typeof(Dictionary<,>)", typeof(Dictionary <,>), flags);                                  // open generic
            TTrace.Debug.SendType("typeof(Dictionary<Window, structTest>", typeof(Dictionary <Window, StructTest>), flags); // closed generic
            TTrace.Debug.SendObject("new Dictionary<Window, structTest>()", new Dictionary <Window, StructTest>(), flags);

            TTrace.Debug.SendType("typeof(templateTest<,>)", typeof(TemplateTest <,>), flags);
            TTrace.Debug.SendObject("new templateTest<Window, structTest>()", new TemplateTest <Window, StructTest>(), flags);


            // Display tables : use an object that implement : Array or IEnumerable or IDictionary or create a special table
            //--------------------------------------------------------------------------------------------------------------

            // 1) array of int
            int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
            int[] numbersB = { 1, 3, 5, 7, 8 };
            TTrace.Debug.SendTable("numbersA", numbersA);
            TTrace.Debug.SendTable("numbersB", numbersB);

            // Linq on array
            var pairs =
                from a in numbersA
                from b in numbersB
                where a < b
                select new { a, b };

            TTrace.Debug.SendTable("Linq query on series", pairs);

            // 2) array of FileInfo[]
            string        strTempPath = Path.GetTempPath();
            DirectoryInfo tempPath    = new DirectoryInfo(strTempPath);

            TTrace.Debug.SendTable("Files in temp path", tempPath.GetFiles());

            // Linq to array of FileInfo[]
            var linqToObjectQuery = from file in tempPath.GetFiles()
                                    where file.Length > 100
                                    orderby file.Length descending
                                    select new
            {
                file.Name,
                file.Length,
                file.LastWriteTime,
                file
            };

            TTrace.Debug.SendTable("Files having length>100 in temp path (Linq)", linqToObjectQuery);


            // 3) IDictionary : Hashtable
            Hashtable openWith = new Hashtable();

            openWith.Add("txt", "notepad.exe");
            openWith.Add("bmp", "paint.exe");
            openWith.Add("dib", "paint.exe");
            openWith.Add("rtf", "wordpad.exe");
            TTrace.Debug.SendTable("Hashtable", openWith);

            // 4) UnTyped collection : Stack
            Stack windowStack = new Stack(5);

            windowStack.Push(this);
            windowStack.Push(this);
            windowStack.Push(this);
            TTrace.Debug.SendTable("Stack ", windowStack);

            // 5) Typed collection (implement ICollection)
            Collection <Window> windowsCollection = new Collection <Window>();

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

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

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

            // 6) create manually a 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);


            // ensure all traces are send to the viewer
            TTrace.Flush();
        }
Beispiel #19
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

            // 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 = "demo";
            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);

            // ensure all traces are send to the viewer
            TTrace.Flush();
        }
Beispiel #20
0
        private void butSample_Click(object sender, EventArgs e)
        {
            // use the selected ip
             TTrace.Options.SocketHost = textBoxIP.Text ;

             TTrace.Debug.Send("CF3 demo");

             TTrace.Options.SendProcessName = false;
             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(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 and font size 12
             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.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;

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

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

             TTrace.Debug.SendType("SendType 'Trace node Type'", TTrace.Debug.GetType());
             TTrace.Debug.SendObject("My const", TraceConst.CST_CREATE_MEMBER);
             TTrace.Debug.SendDump("SendDump test", "Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50);

             // TTrace.Debug.SendType ("My abstract type" , typeof (Base));  // same as Type.GetType("Project1.Base")

             // traces using TraceNodeEx
             TraceNodeEx node = new TraceNodeEx(null);  //  TTrace.Debug
             node.LeftMsg = "TraceNodeEx";
             node.RightMsg = "demo";
             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", System.Text.Encoding.ASCII.GetBytes(str), 50);   // 3F 61 7A          ..... 3F
             node.AddDump("UTF8", System.Text.Encoding.UTF8.GetBytes(str), 50);
             node.AddDump("Unicode", System.Text.Encoding.Unicode.GetBytes(str), 50); // 50 22 61 00 7A 00 ..... 99 99
             node.Send();

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

             TTrace.Error.SendObject("SendObject 'Trace node Object'", TTrace.Debug, flags);

             // Linq on array
             int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
             int[] numbersB = { 1, 3, 5, 7, 8 };
             TTrace.Debug.SendTable("numbersA", numbersA);
             TTrace.Debug.SendTable("numbersB", numbersB);

             var pairs =
            from a in numbersA
            from b in numbersB
            where a < b
            select new { a, b };
             TTrace.Debug.SendTable("Linq query on series", pairs);

             TTrace.Flush();
        }
Beispiel #21
0
        //----------------------------------------------------------------------
        /// <summary>
        /// Writes the logging event to the TraceTool system.
        /// </summary>
        /// <param name="loggingEvent">The event to log.</param>
        protected override void Append(LoggingEvent loggingEvent)
        {
            try
            {
                // if null then first append.
                if (this.log4WinTrace == null)
                {
                    if (this.winTraceId != null || this.winTraceTitle != null)
                    {
                        this.log4WinTrace = new WinTrace(this.winTraceId, this.winTraceTitle);
                        if (this.Layout != null)
                        {
                            this.log4WinTrace.SetMultiColumn();
                        }
                    }
                    else
                    {
                        // no wintrace specified

                        if (this.Layout != null)
                        {
                            // Layout on main trace window. create a brother main wintrace
                            this.log4WinTrace = new WinTrace("_", "_");
                            this.log4WinTrace.SetMultiColumn();                                // must be specified before setting titles
                        }
                        else
                        {                          // no layout and no wintrace specified, use main wintrace
                            this.log4WinTrace = TTrace.WinTrace;
                        }
                    }

                    if (this.titleLayout != null && this.log4WinTrace != TTrace.WinTrace)
                    {
                        this.log4WinTrace.SetColumnsTitle(this.titleLayout);
                    }

                    if (this.logMode >= 0)
                    {
                        this.log4WinTrace.SetLogFile(this.logFileName, this.logMode);
                    }
                }
                TraceNodeEx node = new TraceNodeEx(this.log4WinTrace.Debug);

                // if layout is used, fill only the leftMsg.
                if (this.Layout != null)
                {
                    node.LeftMsg = RenderLoggingEvent(loggingEvent); //  1.2.0 beta8 and 1.2.9 beta
                    //node.LeftMsg =  this.Layout.Format (loggingEvent) ; // 1.2.0 b8
                    node.Time       = "";                            // blank time //$NON-NLS-1$
                    node.ThreadName = "";                            // blank thread name //$NON-NLS-1$
                }
                else
                {
                    // no layout. Use tracetool columns

                    node.LeftMsg    = loggingEvent.LoggerName;
                    node.RightMsg   = loggingEvent.RenderedMessage;
                    node.ThreadName = loggingEvent.ThreadName;
                    node.Time       = loggingEvent.TimeStamp.ToString("HH:mm:ss:fff");

                    // to do : change icon
                    //int level = event.getLevel ().toInt () ;
                    //String levelstr = event.getLevel ().toString () ;
                    //node.iconIndex = 8 ;
                }

                // add the message object if not a primitive
                Object msg = loggingEvent.MessageObject;
                if (!(msg is string))
                {
                    node.AddValue(msg, this.sendPrivateObjectInfo, 3, "Trace Object");
                }

                // add throwable info, if any
                // GetExceptionStrRep is Obsolete but is keept for previous version compatibility  (1.2.0)
                // string strException = loggingEvent.GetExceptionString ();
                string strException = loggingEvent.GetExceptionStrRep();
                if (strException != "")
                {
                    TMemberNode localInfo = node.Members.Add("Exception informations");

                    string [] split = strException.Split(new Char[] { '\n', '\r' });
                    foreach (string s in split)
                    {
                        if (s.Trim() != "")
                        {
                            localInfo.Add(s);
                        }
                    }
                }

                // send Local information.
                if (this.sendLocationInfo)
                {
                    TMemberNode  localInfo = node.Members.Add("LocalInfo");
                    LocationInfo locInfo   = loggingEvent.LocationInformation;
                    localInfo.Add(locInfo.FileName, locInfo.MethodName, locInfo.LineNumber);
                }

                // finally send the node
                node.Send();

                if (this.immediateFlush)
                {
                    TTrace.Flush();
                }
            }
            catch
            {
                // eat exception
            }
        }