Пример #1
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Send a message. further trace to the same node are indented under this one.
        /// </summary>
        /// <param name="leftMsg">Left message to send</param>
        /// <param name="rightMsg">Right message to send</param>
        /// <param name="backGroundColor">BackGround Color</param>
        /// <param name="isEnter">if true , a special "enter" icon is added on the node</param>
        public TraceNode Indent(string leftMsg, string rightMsg, int backGroundColor, bool isEnter)
        {
            if (Enabled == false)
            {
                return(null);
            }
            string thId = Helper.GetCurrentThreadId();


            NodeContext newContext = new NodeContext
            {
                ThreadId = thId,
                NodeId   = Helper.NewGuid().ToString()
            };

            TraceNode result = new TraceNode(this)
            {
                Id = newContext.NodeId
            };

            List <string> commandList = new List <string>();
            NodeContext   lastContext = GetLastContext();

            if (lastContext == null)
            {
                //newContext.level = 1 ;
                Helper.AddCommand(commandList, TraceConst.CST_NEW_NODE, Id);              // param : parent Node id
            }
            else
            {                                                                                // context already exist
               //newContext.level = lastContext.level + 1 ;
                Helper.AddCommand(commandList, TraceConst.CST_NEW_NODE, lastContext.NodeId); // param : parent Node id
            }

            Helper.AddCommand(commandList, TraceConst.CST_TRACE_ID, newContext.NodeId);    // param : Node Id
            Helper.AddCommand(commandList, TraceConst.CST_LEFT_MSG, leftMsg);              // param : left string

            if (!string.IsNullOrEmpty(rightMsg))
            {
                Helper.AddCommand(commandList, TraceConst.CST_RIGHT_MSG, rightMsg);        // param : right string
            }
            if (backGroundColor != -1)
            {
                Helper.AddCommand(commandList, TraceConst.CST_BACKGROUND_COLOR, Helper.ARGB_to_BGR(backGroundColor), "-1");      // param : color, colId
            }
            if (isEnter)
            {
                TMemberNode member = new TMemberNode();                     // create root member
                member.Add("").ViewerKind = TraceConst.CST_VIEWER_ENTER;    // then add an empty member with special viewer
                member.AddToStringList(commandList);                        // convert all groups and nested items/group to strings
            }

            Helper.AddCommand(commandList, TraceConst.CST_ICO_INDEX, IconIndex);          // param : icon index
            TTrace.SendToWinTraceClient(commandList, WinTraceId);

            PushContext(newContext);
            return(result);
        }
Пример #2
0
 //----------------------------------------------------------------------
 /// <summary>
 /// Force creation of new trace node
 /// </summary>
 protected override void WriteIndent()
 {
     if (Listener == null)
     {
         return;
     }
     _currentNode = Listener.Send("");
     NeedIndent   = false;
 }
Пример #3
0
        /// <summary>
        /// Constructor. Use TTrace or TraceNodeEx class as entry point
        /// Create a Node with an unique ID (true)
        /// You can also recreated an already send node if you still have the id
        /// </summary>
        /// <param name="parentNode">The parent node where to place that trace.
        /// The IconIndex and the enabled properties are also recopied
        /// Can be null : the root tree become the parent node, enabled is true and the default icon is used
        /// </param>
        /// <param name="generateUniqueId">When true, a unique ID (a guid) is generated for the trace.
        /// </param>

        public TraceNode(TraceNode parentNode, bool generateUniqueId)  // TraceToSend base class don't have constructor
        {
            if (generateUniqueId)
            {
                Id = Helper.NewGuid().ToString();// else : no more reset to empty string if generateUniqueId is false
            }
            if (parentNode == null)
            {
                IconIndex = TraceConst.CST_ICO_DEFAULT;
                Enabled   = true;
            }
            else
            {
                IconIndex  = parentNode.IconIndex;
                Enabled    = parentNode.Enabled;
                WinTraceId = parentNode.WinTraceId;
            }
        }
Пример #4
0
 //----------------------------------------------------------------------
 /// <summary>
 /// Create a listener giving a TraceNode as the parent node.
 /// </summary>
 /// <param name="traceDoor">Specify Debug,Warning,Error or user TraceNode object</param>
 public TTraceListener(TraceNode traceDoor)
 {
     Listener   = traceDoor;
     NeedIndent = true;
 }
Пример #5
0
 public TraceNode(TraceNode ParentNode, bool generateUniqueId)
 {
 }