Exemple #1
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));
        }
Exemple #2
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Clear all filters
        /// </summary>
        public void ClearFilter()
        {
            List <string> commandList = new List <string>();

            Helper.AddCommand(commandList, TraceConst.CST_CLEAR_FILTER);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #3
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Show the window tree
        /// </summary>
        public void DisplayWin()
        {
            StringList commandList = new StringList();

            commandList.Insert(0, String.Format("{0,5}", TraceConst.CST_DISPLAY_TREE));
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #4
0
        //------------------------------------------------------------------------------
        /// <summary>
        /// WinTrace constructor. The Window Trace is create on the viewer (if not already done)
        /// </summary>
        /// <param name="winTraceId">Required window trace Id. If empty, a guid will be generated</param>
        /// <param name="winTraceText">The Window Title on the viewer.If empty, a default name will be used</param>
        public WinTrace(string winTraceId, string winTraceText)
        {
            if (string.IsNullOrEmpty(winTraceId))
            {
                Id = Helper.NewGuid().ToString();
            }
            else
            {
                Id = winTraceId;
            }

            CreateNodes();

            if (winTraceId != null && winTraceId == "_")
            {
                return; // don't create new window on the viewer
            }
            if (string.IsNullOrEmpty(winTraceText))
            {
                winTraceText = Id;
            }

            // create the trace window
            StringList commandList = new StringList();

            commandList.Insert(0, String.Format("{0,5}{1}", TraceConst.CST_TREE_NAME, winTraceText));
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #5
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Clear all the watches
        /// </summary>
        public void ClearAll()
        {
            List <string> commandList = new List <string>();

            commandList.Insert(0, String.Format("{0,5}", TraceConst.CST_CLEAR_ALL));
            TTrace.SendToWinWatchClient(commandList, Id);
        }
Exemple #6
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Clear all the watches
        /// </summary>
        public void Close()
        {
            List <string> commandList = new List <string>();

            commandList.Insert(0, String.Format("{0,5}", TraceConst.CST_CLOSE_WIN));
            TTrace.SendToWinWatchClient(commandList, Id);
        }
Exemple #7
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Put the window in foreground
        /// </summary>
        public void DisplayWin()
        {
            List <string> commandList = new List <string>();

            commandList.Insert(0, String.Format("{0,5}", TraceConst.CST_DISPLAY_TREE));
            TTrace.SendToWinWatchClient(commandList, Id);
        }
Exemple #8
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Set the focus to the first trace node
        /// </summary>
        public void GotoFirstNode()
        {
            List <string> commandList = new List <string>();

            Helper.AddCommand(commandList, TraceConst.CST_GOTO_FIRST_NODE);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #9
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Save the window tree traces to an XML file
        /// </summary>
        /// <param name="fileName">file to save</param>
        public void SaveToXml(string fileName)
        {
            List <string> commandList = new List <string>();

            Helper.AddCommand(commandList, TraceConst.CST_SAVETOXML, fileName);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #10
0
        //------------------------------------------------------------------------------
        // PLUGIN API
        //------------------------------------------------------------------------------

        /// <summary>
        /// Plugin API : Create a resource.
        /// </summary>
        /// <param name="resId">The resource Id (must be >= 100)</param>
        /// <param name="resType">Resource type. See TraceConst
        /// <code>
        /// CST_RES_BUT_RIGHT    : Button on right
        /// CST_RES_BUT_LEFT     : Button on left
        /// CST_RES_LABEL_RIGHT  : Label on right
        /// CST_RES_LABELH_RIGHT : Label on right HyperLink
        /// CST_RES_LABEL_LEFT   : Label on left
        /// CST_RES_LABELH_LEFT  : Label on left hyperlink
        /// CST_RES_MENU_ACTION  : Item menu in the Actions Menu
        /// CST_RES_MENU_WINDOW  : Item menu in the Windows Menu.
        ///                        Call CreateResource on the main win trace to create this menu item
        /// </code>
        ///</param>
        /// <param name="resWidth">Width of the resource. Applicable only to button and labels</param>
        /// <param name="resText">Resource text</param>

        public void CreateResource(int resId, int resType, int resWidth, string resText)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_CREATE_RESOURCE, resId, resType, resWidth, resText);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #11
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Clear all trace for the window tree
        /// </summary>
        public void ClearAll()
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_CLEAR_ALL);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #12
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Close the window tree
        /// </summary>
        public void Close()
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_CLOSE_WIN);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #13
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Clear all bookmarks
        /// </summary>
        public void ClearBookmark()
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_CLEAR_BOOKMARK);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #14
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Add a filter to node. Multiple calls to this function can be done. Call ApplyFilter() to apply filtering
        /// </summary>
        /// <param name="column">Column to apply filter.<p/>
        ///   In multicolumn mode the first column start at 0 <p/>
        ///   In normal mode : <p/>
        ///   col icone   = 999    <p/>
        ///   col time    = 1      <p/>
        ///   col thread  = 2      <p/>
        ///   col traces  = 3      <p/>
        ///   col Comment = 4      <p/>
        ///   col members = 998
        /// </param>
        /// <param name="compare">There is 5 kinds of filters : <p/>
        ///    Equal           = 0  <p/>
        ///    Not equal       = 1  <p/>
        ///    contains       = 2  <p/>
        ///    Don't contains  = 3  <p/>
        ///    (Ignore this filter) = 4 or -1
        ///</param>
        /// <param name="text">The text to search (insensitive) </param>
        public void AddFilter(int column, int compare, string text)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_ADD_FILTER, column, compare, text);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #15
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Save the window tree traces to a text file
        /// </summary>
        /// <param name="fileName">file to save</param>
        public void SaveToTextfile(string fileName)
        {
            StringList commandList = new StringList();

            commandList.Insert(0, String.Format("{0,5}{1}", TraceConst.CST_SAVETOTEXT, fileName));
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #16
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Set the focus to a bookmarked node identified by his position. Bookmarks are cheched by the user or with the node.SetBookmark() function
        /// </summary>
        /// <param name="pos">Indice of the bookmark </param>
        public void GotoBookmark(int pos)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_GOTO_BOOKMARK, pos);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #17
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// set columns widths
        /// </summary>
        /// <param name="widths">Tab separated columns width.
        /// The format for each column is width[:Min[:Max]] <p/>
        /// where Min and Max are optional minimum and maximum column width for resizing purpose.<p/>
        /// Example : 100:20:80 \t 200:50 \t 100
        /// </param>
        public void SetColumnsWidth(string widths)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_TREE_COLUMNWIDTH, widths);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #18
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Set the focus to the last trace node
        /// </summary>
        public void GotoLastNode()
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_GOTO_LAST_NODE);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #19
0
        //------------------------------------------------------------------------------
        //------------------------------------------------------------------------------

        /// <summary>
        /// Plugin API : Attach a winTrace to a plugin. Many winTrace can be attached to a plugin.
        /// Note that a plugin don't need to be attached to a WinTrace.
        /// The plugin is identified by his internal name (not dll name).
        /// When linked, the plugin can receive event (see ITracePLugin).
        /// </summary>
        /// <param name="pluginName">name of the plugin</param>
        /// <param name="flags">combinaison of CST_PLUG_ONACTION , CST_PLUG_ONBEFOREDELETE , CST_PLUG_ONTIMER</param>

        public void LinkToPlugin(string pluginName, int flags)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_LINKTOPLUGIN, flags, pluginName);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #20
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 #21
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Plugin API : Set the resource text (tracetool or user created resources), specified by his Id
        /// </summary>
        /// <param name="resId">The resource Id </param>
        /// <param name="resText">Resource text</param>

        public void SetTextResource(int resId, string resText)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_SET_TEXT_RESOURCE, resId, resText);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #22
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Load an XML file to the window tree traces
        /// </summary>
        /// <param name="fileName">file to open</param>
        public void LoadXml(string fileName)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_LOADXML, fileName);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #23
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Save the window tree traces to an XML file
        /// </summary>
        /// <param name="fileName">file to save</param>
        /// <param name="styleSheet">optional StyleSheet file name added in xml</param>
        public void SaveToXml(string fileName, string styleSheet)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_SAVETOXML, fileName + '|' + styleSheet);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #24
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Plugin API : Disable tracetool or user created resources
        /// </summary>
        /// <param name="resId">The resource Id
        /// ResId: resource id to disable. Tracetool resources :
        /// <code>
        /// CST_ACTION_CUT            : Cut. Same as copy then delete
        /// CST_ACTION_COPY           : Copy
        /// CST_ACTION_DELETE         : Delete selected
        /// CST_ACTION_SELECT_ALL     : Select all
        /// CST_ACTION_RESIZE_COLS    : Resize columns
        /// CST_ACTION_VIEW_INFO      : View trace info
        /// CST_ACTION_VIEW_PROP      : View properties
        /// CST_ACTION_PAUSE          : Pause
        /// CST_ACTION_SAVE           : SaveToFile
        /// CST_ACTION_CLEAR_ALL      : Clear all
        /// CST_ACTION_CLOSE_WIN      : Close win
        /// CST_ACTION_LABEL_INFO     : TracesInfo label
        /// CST_ACTION_LABEL_LOGFILE  : LabelLogFile label
        /// CST_ACTION_VIEW_MAIN      : View Main trace
        /// CST_ACTION_VIEW_ODS       : ODS
        /// CST_ACTION_OPEN_XML       : XML trace -> Tracetool XML traces
        /// CST_ACTION_EVENTLOG       : Event log
        /// CST_ACTION_TAIL           : Tail
        /// </code>
        /// </param>

        public void DisableResource(int resId)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_DISABLE_RESOURCE, resId);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #25
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// Set the focus to the next matching node
        /// </summary>
        /// <param name="searForward">If true search down, else search up  </param>
        public void FindNext(bool searForward)
        {
            StringList commandList = new StringList();

            Helper.AddCommand(commandList, TraceConst.CST_FIND_NEXT, searForward);
            TTrace.SendToWinTraceClient(commandList, Id);
        }
Exemple #26
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);
        }
Exemple #27
0
        //----------------------------------------------------------------------

        /// <summary>
        /// Change font detail for an item in the trace
        /// </summary>
        /// <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>
        /// <param name="bold">Change font to bold</param>
        /// <param name="italic">Change font to Italic</param>
        /// <param name="color">Change Color. To reduce the number assembly reference, the Color structure is not used. Use YourColor.ToArgb() instead. Use -1 to keep default color</param>
        /// <param name="size">Change font size, use zero to keep normal size</param>
        /// <param name="fontName">Change font name</param>
        /// <returns>The trace node</returns>
        public TraceNode SetFontDetail(int colId, bool bold, bool italic, int color, int size, string fontName)
        {
            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

            StringBuilder tempStr = new StringBuilder();

            tempStr.Append(String.Format("{0,5}{1,3}", TraceConst.CST_FONT_DETAIL, colId));


            if (bold)
            {
                tempStr.Append("1");
            }
            else
            {
                tempStr.Append("0");
            }

            if (italic)
            {
                tempStr.Append("1");
            }
            else
            {
                tempStr.Append("0");
            }

            if (color != -1)
            {
                // remove Alpha blending
                color &= 0xFFFFFF;
                // Color is coded as RGB. convert to BGR
                int b = color & 0xff;
                int g = (color >> 8) & 0xff;
                int r = (color >> 0x10) & 0xff;
                color = (b << 0x10) + (g << 8) + r;
            }

            tempStr.Append(String.Format("{0,11}{1,11}", color, size)).Append(fontName);

            commandList.Add(tempStr.ToString());

            TTrace.SendToWinTraceClient(commandList, WinTraceId);
            return(this);
        }
        //----------------------------------------------------------------------

        /// <summary>
        /// Dispose of resources.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            TTrace.Flush();
            if (disposing)
            {
                // Free state-managed objects.
            }
            base.Dispose(disposing);
        }
Exemple #29
0
        //------------------------------------------------------------------------------

        /// <summary>
        ///   Return the last local log file. (when mode 4 or 5 is used). Note : Call TTrace.Flush() to ensure traces are saved
        /// </summary>

        public string GetLocalLogFile()
        {
            InternalWinTrace traceForm = TTrace.GetInternalTraceForm(Id, true);

            if (traceForm == null)
            {
                return("");
            }
            return(traceForm.LastLocalLogFileName);
        }
Exemple #30
0
        //------------------------------------------------------------------------------
        /// <summary>
        /// change the tree to display user defined multiple columns
        /// must be called before setting column titles. The first column is the main column
        /// </summary>

        public void SetMultiColumn()
        {
            InternalWinTrace traceForm = TTrace.GetInternalTraceForm(Id, true);

            traceForm.IsMultiColTree = true;

            StringList commandList = new StringList();

            commandList.Insert(0, String.Format("{0,5}{1,11}", TraceConst.CST_TREE_MULTI_COLUMN, 0));
            TTrace.SendToWinTraceClient(commandList, Id);
        }