示例#1
0
        void drawHeader(Graphics g, MethodEvent e, float x, float y)
        {
            String title = e.MethodInfo.ClassName;
            Pen blackBorderPen = new Pen(Color.Gray);
            Font textFont = new Font("Tahoma", 8 * zoomScale);

            if (!e.MethodInfo.IsStatic)
                title += "\nInst. " + e.InstanceObjectID.ToString();

            StringFormat f = new StringFormat();
            f.Alignment = StringAlignment.Center;
            f.LineAlignment = StringAlignment.Center;

            SizeF stringSize = new SizeF();
            stringSize = g.MeasureString(title, textFont, new SizeF(colWidth * zoomScale, 50));

            int boxHeight = (int) (stringSize.Height + 20 * zoomScale);

            if (e.MethodInfo.IsStatic)
            {
                g.DrawRectangle(blackBorderPen, x, y - boxHeight - 20 * zoomScale, colWidth * zoomScale, boxHeight);
            }
            else
            {
                RoundedCornerRectangle(g, blackBorderPen, x, y - boxHeight - 20 * zoomScale, colWidth * zoomScale, boxHeight, boxHeight * 0.3f);
            }

            if (zoomScale >= 0.5) {
                Rectangle r = new Rectangle((int) x, (int)(y - boxHeight - 10 * zoomScale), (int)(colWidth * zoomScale), (int)(stringSize.Height));
                g.DrawString(title, textFont, Brushes.Black, r, f);
            }
        }
示例#2
0
        ClassData getOrCreateClassData(MethodEvent mev)
        {
            String hash = mev.getHash();

            if (!classData.ContainsKey(hash))
            {
                ClassData c = new ClassData();
                c.instanceObjectID = mev.InstanceObjectID;
                c.columnNumber = nextFreeColumn++;
                this.classData[hash] = c;
            }

            return (ClassData) this.classData[hash];
        }
示例#3
0
        private ArrayList readXml(string xmlFile)
        {
            classes = new ArrayList();
            objects = new ArrayList();
            threads = new ArrayList();
            inAppClasses = new ArrayList();

            classList.Items.Clear();
            objectList.Items.Clear();
            threadList.Items.Clear();

            XPathDocument doc = new XPathDocument(xmlFile);
            XPathNavigator nav = doc.CreateNavigator();

            XPathExpression functionInfosExpression = nav.Compile("infos/functionInfos/functionInfo");
            XPathNodeIterator functionInfosIterator = nav.Select(functionInfosExpression);

            XPathExpression eventsExpression = nav.Compile("infos/events/*");
            XPathNodeIterator eventsIterator = nav.Select(eventsExpression);

            Hashtable functionInfos = new Hashtable();

            while (functionInfosIterator.MoveNext())
            {
                XPathNavigator node = functionInfosIterator.Current.Clone();

                MethodInfo m = new MethodInfo();
                m.FunctionID = node.GetAttribute("functionId", String.Empty);
                m.ClassName = node.GetAttribute("className", String.Empty);
                m.MethodName = node.GetAttribute("methodName", String.Empty);
                if (node.GetAttribute("isInApp", String.Empty).Length > 0)
                    m.IsInApp = Convert.ToBoolean(node.GetAttribute("isInApp", String.Empty));
                if (node.GetAttribute("static", String.Empty).Length > 0)
                    m.IsStatic = Convert.ToBoolean(node.GetAttribute("static", String.Empty));
                m.ReturnType = node.GetAttribute("returnType", String.Empty);

                functionInfos[m.FunctionID] = m;

                if (!classes.Contains(m.ClassName)) {
                    classes.Add(m.ClassName);
                    if (m.IsInApp) inAppClasses.Add(classes.Count - 1);
                    classList.Items.Add(m.ClassName);
                    classList.SetItemChecked(classList.Items.Count - 1, true);
                }
            }

            ArrayList events = new ArrayList();

            System.Globalization.NumberFormatInfo info = new System.Globalization.NumberFormatInfo();
            info.NumberDecimalSeparator = ".";
            info.NumberGroupSeparator = ",";

            while (eventsIterator.MoveNext())
            {
                XPathNavigator node = eventsIterator.Current.Clone();

                if (node.Name == "methodEvent")
                {

                    MethodEvent m = new MethodEvent();
                    m.InstanceObjectID = node.GetAttribute("objectId", String.Empty);
                    m.MethodInfo = (MethodInfo)functionInfos[node.GetAttribute("functionId", String.Empty)];
                    m.ThreadID = node.GetAttribute("threadId", String.Empty);
                    m.timestamp = Convert.ToDouble(node.GetAttribute("timestamp", String.Empty), info);

                    String type = node.GetAttribute("type", String.Empty);

                    if (type == "Enter")
                        m.EventType = MethodEvent.EventTypeEnum.EnterEvent;
                    else if (type == "Leave")
                        m.EventType = MethodEvent.EventTypeEnum.LeaveEvent;

                    if (m.InstanceObjectID != "0" && !objects.Contains(m.InstanceObjectID))
                    {
                        objects.Add(m.InstanceObjectID);
                        objectList.Items.Add("Instance " + m.InstanceObjectID + " (" + m.MethodInfo.ClassName + ")");
                        objectList.SetItemChecked(objectList.Items.Count - 1, true);
                    }

                    events.Add(m);
                }
                if (node.Name == "threadEvent")
                {
                    ThreadEvent t = new ThreadEvent();
                    t.timestamp = Convert.ToDouble(node.GetAttribute("timestamp", String.Empty), info);
                    t.ThreadID = node.GetAttribute("threadId", String.Empty);

                    String type = node.GetAttribute("type", String.Empty);
                    if (type == "Create")
                        t.EventType = ThreadEvent.EventTypeEnum.CreateEvent;
                    else if (type == "Destroy")
                        t.EventType = ThreadEvent.EventTypeEnum.DestroyEvent;

                    events.Add(t);

                    if (!threads.Contains(t.ThreadID))
                    {
                        threads.Add(t.ThreadID);
                        threadList.Items.Add("Thread " + t.ThreadID);
                        threadList.SetItemChecked(threadList.Items.Count - 1, true);
                    }
                }
                if (node.Name == "exceptionEvent")
                {
                    ExceptionEvent t = new ExceptionEvent();
                    t.timestamp = Convert.ToDouble(node.GetAttribute("timestamp", String.Empty), info);
                    events.Add(t);
                }
            }

            return events;
        }