Ejemplo n.º 1
0
        //private void InitializeAnalysisMetricsGroupBox()
        //{
        //    // Set the font size for the GroupBox (but not for the controls it contains)
        //    Font analysisMetricsFont = new Font("Microsoft Sans Serif", 8);
        //    AnalysisMetricsGroupBox.Font = analysisMetricsFont;
        //}
        private void RefreshSingleDataChart()
        {
            // Get the last marked and unmarked batches and add them to the graph
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

            InitializeSingleDataChart();
            //// Format the chart
            ////standardSeries.ChartType = SeriesChartType.RangeColumn;
            ////standardSeries.BorderWidth = 1;
            ////standardSeries.BorderDashStyle = ChartDashStyle.Solid;
            ////standardSeries.BorderColor = Color.Black;
            ////standardSeries.Color = Color.Blue;
            //SingleChart.Series.Clear();
            //SingleChart.Titles.Clear();
            //SingleChart.Titles.Add("Current Capture Packet Probability Distribution");
            ////SingleChart.Legends[0].Position.Auto = true; //ElementPosition
            //SingleChart.Legends[0].IsDockedInsideChartArea = true;
            //SingleChart.Legends[0].Docking = Docking.Bottom;
            //SingleChart.Legends[0].Alignment = StringAlignment.Center;
            //SingleChart.ChartAreas[0].AxisX.Title = "Packets per Interval";
            //SingleChart.ChartAreas[0].AxisX.Minimum = 0;
            ////SingleChart.ChartAreas[0].AxisX.Maximum =

            //// Get the type of chart to display
            //string chartType = ChartTypeComboBox.Items[ChartTypeComboBox.SelectedIndex].ToString();

            //// Marked probabilities series
            //SingleChart.Series.Add("MarkedProbabilities");
            ////SingleChart.Series["MarkedProbabilities"].ChartType = SeriesChartType.Line;
            //SingleChart.Series["MarkedProbabilities"].ChartType = chartType == "Bar" ? SeriesChartType.Column : SeriesChartType.Line;
            //SingleChart.Series["MarkedProbabilities"].IsVisibleInLegend = true;
            //SingleChart.Series["MarkedProbabilities"].LegendText = "Marked";

            //// Unmarked probabilities series
            //SingleChart.Series.Add("UnmarkedProbabilities");
            ////SingleChart.Series["UnmarkedProbabilities"].ChartType = SeriesChartType.Line;
            //SingleChart.Series["UnmarkedProbabilities"].ChartType = chartType == "Bar" ? SeriesChartType.Column : SeriesChartType.Line;
            //SingleChart.Series["UnmarkedProbabilities"].IsVisibleInLegend = true;
            //SingleChart.Series["UnmarkedProbabilities"].LegendText = "Unmarked";

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                if (file != null)
                {
                    //BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

                    // Retrieve the probability data from the database
                    BindingList<SingleHistogram> histogramProbabilityList = new BindingList<SingleHistogram>();
                    histogramProbabilityList = pcp.GetSingleHistogramProbabilityData(file.CaptureBatchId);

                    // Convert the histogram probability data
                    SortedDictionary<int, decimal> probabilities = new SortedDictionary<int, decimal>();
                    //SortedDictionary<int, decimal> markedProbabilities = new SortedDictionary<int, decimal>();
                    //SortedDictionary<int, decimal> unmarkedProbabilities = new SortedDictionary<int, decimal>();

                    foreach (SingleHistogram hist in histogramProbabilityList)
                    {
                        probabilities.Add(hist.Interval, hist.Probability);
                    }

                    //// Calculate probabilities
                    //batchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                    //int histogramBinSize = Convert.ToInt32(HistogramBinSize);
                    ////SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);
                    //SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_trimZeroPacketIntervals, histogramBinSize);

                    // Update the chart
                    if (file.CaptureState == CaptureState.Marked)
                    {
                        SingleChart.Series["MarkedProbabilities"].Color = Color.CornflowerBlue;

                        foreach (KeyValuePair<int, decimal> pair in probabilities)
                        {
                            SingleChart.Series["MarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
                        }
                    }
                    else
                    {
                        SingleChart.Series["UnmarkedProbabilities"].Color = Color.Red;

                        foreach (KeyValuePair<int, decimal> pair in probabilities)
                        {
                            SingleChart.Series["UnmarkedProbabilities"].Points.AddXY(Convert.ToDouble(pair.Key), Convert.ToDouble(pair.Value));
                        }
                    }
                }
            }
        }