Esempio n. 1
0
        public PerfChart()
        {
            InitializeComponent();

            // Initialize Variables
            perfChartStyle = new PerfChartStyle();

            perfChartPenStyles    = new PerfChartPenStyle[4];
            perfChartPenStyles[0] = new PerfChartPenStyle();
            perfChartPenStyles[1] = new PerfChartPenStyle();
            perfChartPenStyles[2] = new PerfChartPenStyle();
            perfChartPenStyles[3] = new PerfChartPenStyle();

            chartSize     = 500;
            drawValues    = new List <DataSample>(chartSize);
            waitingValues = new ConcurrentQueue <DataSample>();

            // Set Optimized Double Buffer to reduce flickering
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            // Redraw when resized
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            this.Font = SystemInformation.MenuFont;
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates the vertical Position of a value in relation the chart size,
        /// Scale Mode and, if ScaleMode is Relative, to the current maximum value
        /// </summary>
        /// <param name="value">performance value</param>
        /// <returns>vertical Point position in Pixels</returns>
        private double CalcVerticalPosition(PerfChartPenStyle pt, Int32 value)
        {
            double result = 0;

            if (pt.ScaleMode == ScaleMode.Absolute)
            {
                result = (((double)value + pt.Offset) / pt.Scale) * (double)this.Height;
            }
            else if (pt.ScaleMode == ScaleMode.Relative)
            {
                result = (pt.currentMaxValue > 0) ? (value * this.Height / pt.currentMaxValue) : 0;
            }

            // Invert the graph to have Y going up
            result = this.Height - result;

            return(result);
        }