Universe.Framework.Utilities.ProfilerValueManager.GetMaxValue C# (CSharp) Method

GetMaxValue() public method

public GetMaxValue ( ) : double
return double
        public double GetMaxValue()
        {
            double MaxVal = 0;
            lock (infos)
            {
                for (int i = 0; i < lastSet; i++)
                {
                    if (infos[i] > MaxVal)
                        MaxVal = infos[i];
                }
            }

            return MaxVal;
        }
    }

Usage Example

Example #1
0
        public FastBitmap DrawGraph(string StatName)
        {
            Bitmap     bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb);
            FastBitmap bmp    = new FastBitmap(bitmap);

            bmp.LockBitmap();

            ProfilerValueManager statManager = GetStat(StatName);
            double MaxVal = 0;

            if (statManager != null)
            {
                MaxVal = statManager.GetMaxValue();
            }

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

            double[] Stats2 = new double[0];
            if (statManager != null)
            {
                Stats2 = statManager.GetInfos();
            }

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

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

            return(bmp);
        }