Exemple #1
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Delete indentation to the node added by indent()
        /// </summary>
        /// <param name="leftMsg">Message to send to close indentation (optional)</param>
        /// <param name="rightMsg">Message to send to close indentation (optional)</param>
        /// <param name="backGroundColor">RGB background color (optional)(see Color.ToArgb function)</param>
        /// <param name="isExit">if true, viewer type 'exit' is used</param>
        public void UnIndent(String leftMsg, String rightMsg, int backGroundColor, bool isExit)
        {
            if (Enabled == false)
            {
                return;
            }

            DeleteLastContext();

            if (leftMsg != null || rightMsg != null)
            {
                String nodeId = Helper.NewGuid().ToString();  // then give new ID

                List <string> commandList = PrepareNewNode(leftMsg, nodeId);

                if (rightMsg != null)
                {
                    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 (isExit)
                {
                    TMemberNode member = new TMemberNode();                     // create root member
                    member.Add("").ViewerKind = TraceConst.CST_VIEWER_EXIT;     // then add an empty member with special viewer
                    member.AddToStringList(commandList);                        // convert all groups and nested items/group to strings
                }
                TTrace.SendToWinTraceClient(commandList, WinTraceId);
            }
        }
Exemple #2
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);
        }