Example #1
0
        private bool DrawFunctionBlock(Graphics g, FunctionCall f, int y)
        {
            int left  = ConvertTime(f.StartTime);
            int right = ConvertTime(f.EndTime);

            if ((right > 0) && (left < this.Width) && (y < this.Height))
            {
                Rectangle r = new Rectangle(left, y, right - left, functionCallHeight);
                if (r.Width >= 2)
                {
                    using (Brush b = new SolidBrush(f.Color))
                    {
                        g.FillRectangle(b, r);

                        g.DrawLine(functionCallDivider, new Point(left, y), new Point(left, y + functionCallHeight - 1));
                        g.DrawLine(functionCallDivider, new Point(right - 1, y), new Point(right - 1, y + functionCallHeight - 1));
                    }

                    // Draw the text only if there is enough space:
                    if (r.Width > 20)
                    {
                        SizeF size = g.MeasureString(f.Name, functionCallFont);
                        if (size.Width < r.Width)
                        {
                            float xx = ((r.Width - size.Width) * 0.5f) + left;
                            float yy = ((r.Height - size.Height) * 0.5f) + y;
                            g.DrawString(f.Name, functionCallFont, functionCallFontColor, new PointF(xx, yy));
                        }
                        else
                        {
                            string str = "...";
                            size = g.MeasureString(str, functionCallFont);
                            if (size.Width < r.Width)
                            {
                                float xx = ((r.Width - size.Width) * 0.5f) + left;
                                float yy = ((r.Height - size.Height) * 0.5f) + y;
                                g.DrawString(str, functionCallFont, functionCallFontColor, new PointF(xx, yy));
                            }
                        }
                    }
                }
                else
                {
                    using (Pen p = new Pen(f.Color))
                    {
                        g.DrawLine(p, new Point(left, y), new Point(left, y + functionCallHeight - 1));
                    }
                }
                return(true);
            }
            return(false);
        }
Example #2
0
        private void TimeView_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = new Point(e.X, e.Y);

            if (m_panning)
            {
                int  deltax  = p.X - m_prevMousePosition.X;
                long timeadd = ConvertScreenDelta(deltax);

                long newleft  = m_leftTime - timeadd;
                long newright = m_rightTime - timeadd;

                long middle = (newleft + newright) / 2;
                if (m_report != null)
                {
                    if ((middle >= m_report.MinimumTime) && (middle <= m_report.MaximumTime))
                    {
                        m_leftTime  = newleft;
                        m_rightTime = newright;
                    }

                    int deltay = p.Y - m_prevMousePosition.Y;
                    m_yOffset -= deltay;

                    if (m_yOffset > m_maxY)
                    {
                        m_yOffset = m_maxY;
                    }
                    if (m_yOffset < 0)
                    {
                        m_yOffset = 0;
                    }
                }

                Invalidate();
            }
            else
            {
                FunctionCall f = GetFunctionCallUnderMouse(e.X, e.Y);
                if (f != null)
                {
                    double duration = ((double)f.Duration * 1000.0) / (double)m_report.Frequency;
                    this.toolTip1.SetToolTip(this, String.Format("{0} - {1:N}", f.ToString(), duration));
                }
                else
                {
                    this.toolTip1.SetToolTip(this, "");
                }
            }

            m_prevMousePosition = p;
        }
Example #3
0
 private FunctionCall GetFunctionCallUnderMouse(int mx, int my)
 {
     if (m_report != null)
     {
         foreach (FunctionCall f in m_report.TopFunctions)
         {
             FunctionCall result = RecGetFunctionCallUnderMouse(f, functionCallOffset - m_yOffset, mx, my);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
Example #4
0
 public void AddChild(FunctionCall func)
 {
     m_children.Add(func);
 }
Example #5
0
        private static bool RecGenerate(ProfileReport report, List <ProfileSample> samples, ref int i, FunctionCall f)
        {
            int size = samples.Count;

            ++i;

            for (; i < size; ++i)
            {
                if (samples[i].Enter)
                {
                    FunctionCall fchild = new FunctionCall(samples[i].Name, samples[i].Time, samples[i].Color);

                    RecGenerate(report, samples, ref i, fchild);

                    f.AddChild(fchild);

                    report.m_allFunctionCalls.Add(fchild);
                }
                else
                {
                    f.EndTime = samples[i].Time;
                    return(true);
                }
            }

            return(false);
        }