private void DrawNetRegressionLine(ctlChartBase sender, PostRenderEventArgs args)
        {
            try
            {
                if (mcheckBox_displayRegression.Checked == false)
                {
                    return;
                }

                foreach (Analysis analysis in m_displayCache.Keys)
                {
                    // Here we only draw the regression line for the selected analysis, unless it's null, which means the user wants to see all of the analysis together.
                    if (analysis == m_selectedAnalysis || m_selectedAnalysis == null)
                    {
                        if (analysis.ProcessedState == ProcessingState.Processed)
                        {
                            // IRegressionAlgorithm regressor = analysis.RegressionResults.Regressor;
                            float xFrom  = sender.ViewPort.X;
                            float xFinal = sender.ViewPort.Right;

                            clsColorIterator iterator = new clsColorIterator();
                            Color            color    = iterator.GetColor(analysis.Id);
                            color = Color.FromArgb(120, color);

                            using (Pen mpen_line = new Pen(color, 5))
                            {
                                if (!mcheckBox_useResiduals.Checked)
                                {
                                    int   numDivisions = 10;
                                    float step         = (xFinal - xFrom) / numDivisions;
                                    for (; xFrom < xFinal; xFrom += step)
                                    {
                                        //         float yFrom = Convert.ToSingle(regressor.GetTransformedNET(Convert.ToInt32(xFrom)));
                                        //       float xTo = xFrom + step;
                                        //           float yTo = Convert.ToSingle(regressor.GetTransformedNET(Convert.ToInt32(xTo)));

                                        //            args.Graphics.DrawLine(mpen_line, sender.GetScreenPixelX(xFrom), sender.GetScreenPixelY(yFrom),
                                        //              sender.GetScreenPixelX(xTo), sender.GetScreenPixelY(yTo));
                                    }
                                }
                                else
                                {
                                    args.Graphics.DrawLine(mpen_line, sender.GetScreenPixelX(xFrom), sender.GetScreenPixelY(0),
                                                           sender.GetScreenPixelX(xFinal), sender.GetScreenPixelY(0));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                // who cares!
            }
        }
        /// <summary>
        /// Displays the scan vs. NET values for a single analysis.
        /// </summary>
        /// <param name="analysis"></param>
        private void DisplayScansVsNet(Analysis analysis)
        {
            // Either the display does not have the analysis, or the display series was reset and needs to be re-rendered
            if (!m_displayCache.ContainsKey(analysis) || m_displayCache[analysis] == null)
            {
                BubbleShape      shape      = new BubbleShape(1, false);
                clsColorIterator colors     = new clsColorIterator();
                Color            plotColor  = colors.GetColor(analysis.Id);
                clsPlotParams    parameters = new clsPlotParams(shape, plotColor, false, true, true);
                parameters.Name = analysis.Name;

                float[] ordinate = new float[analysis.Targets.Count];
                float[] abscissa = new float[analysis.Targets.Count];
                int     i        = 0;
                if (!mcheckBox_useResiduals.Checked)
                {
                    foreach (Target target in analysis.Targets)
                    {
                        if (radioButtonAverageNET.Checked)
                        {
                            ordinate[i]   = Convert.ToSingle(target.ParentTarget.GaNetAverage);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                        else
                        {
                            /// Only display predicted peptides if not using average NET
                            if (!target.IsPredicted)
                            {
                                continue;
                            }

                            ordinate[i]   = Convert.ToSingle(target.NetPredicted);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                    }
                }
                else
                {
                    foreach (Target target in analysis.Targets)
                    {
                        if (radioButtonAverageNET.Checked)
                        {
                            ordinate[i]   = Convert.ToSingle(target.ParentTarget.GaNetAverage - target.NetAligned);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                        else
                        {
                            /// Only display predicted peptides if not using average NET
                            if (!target.IsPredicted)
                            {
                                continue;
                            }

                            ordinate[i]   = Convert.ToSingle(target.NetPredicted - target.NetAligned);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                    }
                }

                clsSeries newSeries = new clsSeries(new ArrayChartDataProvider(abscissa, ordinate), parameters);
                if (!m_displayCache.ContainsKey(analysis))
                {
                    m_displayCache.Add(analysis, null);
                }
                m_displayCache[analysis] = newSeries;
            }

            clsSeries series = m_displayCache[analysis];

            ctlChartScanVsNET.SeriesCollection.Add(series);
            ctlChartScanVsNET.AutoViewPort();
        }