Ejemplo n.º 1
0
        private void  CalcChartVariables()
        {
            chartFirstCol = rulers[0].FirstCol();
            chartLastCol  = rulers[0].LastCol();

            chartWidth = chartLastCol - chartFirstCol + 1;
            rowFirst   = 10;
            rowLast    = chartPanel.Height - 10;

            int totalPixelRows = 1 + rowLast - rowFirst;

            if ((minValues == null) || (maxValues == null))
            {
                history.CalcMinMaxValues(timeBot, timeTop);
                minValues = history.MinValues();
                maxValues = history.MaxValues();
            }

            colFactors = new float[minValues.Length];

            for (int x = 0; x < minValues.Length; x++)
            {
                float range = maxValues[x] - minValues[x];
                if (range == 0.0f)
                {
                    colFactors[x] = 1.0f;
                }
                else
                {
                    colFactors[x] = chartWidth / range;
                }
            }

            TimeSpan timeRange     = timeTop - timeBot;
            int      timeRangeSecs = (int)timeRange.TotalSeconds;

            secsPerPixelRow   = (float)timeRangeSecs / (float)totalPixelRows;
            metersPerPixelRow = (float)(depthBot - depthTop) / (float)totalPixelRows;


            if (plotBuffer != null)
            {
                plotBuffer.Dispose();
                plotBuffer = null;
            }

            plotDC       = chartPanel.CreateGraphics();
            plotBuffer   = new Bitmap(chartPanel.Width, chartPanel.Height);
            plotBufferDC = Graphics.FromImage(plotBuffer);
        } /*  CalcChartVariables */