예제 #1
0
        public FastBitmap DrawGraph(string StatName)
        {
            Bitmap bitmap = new Bitmap(200, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            FastBitmap bmp = new FastBitmap(bitmap);
            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);
            double MaxVal = statManager.GetMaxValue();

            double ScaleFactor = 1 / (MaxVal / 200); //We multiply by this so that the graph uses the full space

            ProfilerValueInfo[] Stats = new ProfilerValueInfo[10];
            int i = 0;
            foreach (ProfilerValueInfo info in statManager.GetInfos())
            {
                Stats[i] = info;
                i++;
            }

            for (i = 0; i < Stats.Length; i++)
            {
                //Update the scales
                Stats[i].Value = Stats[i].Value * ScaleFactor;
            }

            for (int x = 200; x > 0; x--)
            {
                for (int y = 200; y > 0; y--)
                {
                    //Note: we do 200-x and 200-y to flip the graph on the X and Y axises
                    if (IsInGraphBar(x, y, Stats))
                        bmp.SetPixel(200 - x, 200 - y, BarColor);
                    else
                    {
                        //Check whether the line needs drawn
                        if (DrawLine(y, ScaleFactor))
                            bmp.SetPixel(200 - x, 200 - y, LineColor);
                        else
                            bmp.SetPixel(200 - x, 200 - y, BackgroundColor);
                    }
                }
            }
            bmp.UnlockBitmap();

            return bmp;
        }
예제 #2
0
 private void ShiftLeft(ProfilerValueInfo info)
 {
     for (int i = 0; i < 10; i++)
     {
         if (i != 0)
             infos[i - 1] = infos[i];
     }
     infos[9] = info;
 }
예제 #3
0
 public void AddStat(ProfilerValueInfo info)
 {
     lock (infos)
     {
         if (lastSet != 10)
         {
             infos[lastSet] = info;
             lastSet++;
         }
         else
             ShiftLeft(info);
     }
 }
예제 #4
0
 public void AddStat(string Name, ProfilerValueInfo info)
 {
     if (!Stats.ContainsKey(Name))
         Stats[Name] = new ProfilerValueManager();
     Stats[Name].AddStat(info);
 }
예제 #5
0
 private bool IsInGraphBar(int x, int y, ProfilerValueInfo[] Stats)
 {
     for (int i = GraphBarsStart.Length - 1; i >= 0; i--)
     {
         //Check whether it is between both the start and end
         if (x > GraphBarsStart[i] && x < GraphBarsEnd[i])
         {
             if (Stats[i].Value >= y)
                 return true;
         }
     }
     return false;
 }