} // END CoreProcessEventProcessor private void MainForm_Load(object sender, EventArgs e) { mBandwidthGraph = new BandwidthGraph(mZedGraphControl); //mBandwidthGraph.CreateGraph(); /* * // Column sorter... * ColumnHeader columnheader; // Used for creating column headers. * ListViewItem listviewitem; // Used for creating listview items. * * // Ensure that the view is set to show details. * //mListView.View = View.Details; * * // Create some listview items consisting of first and last names. * listviewitem = new ListViewItem("John"); * listviewitem.SubItems.Add("Smith"); * this.mListView.Items.Add(listviewitem); * * listviewitem = new ListViewItem("Bob"); * listviewitem.SubItems.Add("Taylor"); * this.mListView.Items.Add(listviewitem); * * listviewitem = new ListViewItem("Kim"); * listviewitem.SubItems.Add("Zimmerman"); * this.mListView.Items.Add(listviewitem); * * listviewitem = new ListViewItem("Olivia"); * listviewitem.SubItems.Add("Johnson"); * this.mListView.Items.Add(listviewitem); * * // Create some column headers for the data. * columnheader = new ColumnHeader(); * columnheader.Text = "First Name"; * this.mListView.Columns.Add(columnheader); * * columnheader = new ColumnHeader(); * columnheader.Text = "Last Name"; * this.mListView.Columns.Add(columnheader); * * // Loop through and size each column header to fit the column header text. * foreach (ColumnHeader ch in this.mListView.Columns) * { * ch.Width = -2; * } */ } // END MainForm_Load
private void RefreshGraph() { BandwidthGraph.GraphPane.CurveList.Clear(); if (Cores.Count == 0) { return; } // get all core averages float netAvg = 0; foreach (CoreItem item in CoresList.Items) { float coreAvg = 0; coreAvg += item.Core.Network.UdpControl.Bandwidth.InOutAvg(AverageSeconds); foreach (TcpConnect tcp in item.Core.Network.TcpControl.SocketList) { coreAvg += tcp.Bandwidth.InOutAvg(AverageSeconds); } item.SubItems[1].Text = AvgFormat(coreAvg); netAvg += coreAvg; } CoresLabel.Text = "Cores: " + AvgFormat(netAvg); // get selected core averages double[] inBytes = new double[RecordSeconds]; double[] outBytes = new double[RecordSeconds]; float tcpAvg = 0; float udpAvg = 0; float rudpAvg = 0; foreach (ServiceItem service in ServiceList.Items) { service.BandwidthAverage = 0; } foreach (CoreItem item in CoresList.SelectedItems) { if (item.Core.RecordBandwidthSeconds != RecordSeconds) { item.Core.ResizeBandwidthRecord(RecordSeconds); continue; } // averages summed udpAvg += item.Core.Network.UdpControl.Bandwidth.InOutAvg(AverageSeconds); foreach (TcpConnect tcp in item.Core.Network.TcpControl.SocketList) { tcpAvg += tcp.Bandwidth.InOutAvg(AverageSeconds); } foreach (RudpSession session in item.Core.Network.RudpControl.SessionMap.Values) { rudpAvg += session.Comm.Bandwidth.InOutAvg(AverageSeconds); } foreach (ServiceItem service in ServiceList.Items) { if (item.Core.ServiceBandwidth.ContainsKey(service.ID)) { service.BandwidthAverage += item.Core.ServiceBandwidth[service.ID].InOutAvg(AverageSeconds); } } // graphs if (TransportRadio.Checked) { if (UdpBox.Checked) { AddtoArrays(inBytes, outBytes, item.Core.Network.UdpControl.Bandwidth); } if (TcpBox.Checked) { foreach (TcpConnect tcp in item.Core.Network.TcpControl.SocketList) { AddtoArrays(inBytes, outBytes, tcp.Bandwidth); } } } else if (RudpRadio.Checked) { foreach (RudpSession session in item.Core.Network.RudpControl.SessionMap.Values) { AddtoArrays(inBytes, outBytes, session.Comm.Bandwidth); } } else if (ServiceRadio.Checked) { foreach (ServiceItem selected in ServiceList.SelectedItems) { if (item.Core.ServiceBandwidth.ContainsKey(selected.ID)) { AddtoArrays(inBytes, outBytes, item.Core.ServiceBandwidth[selected.ID]); } } } } float transAvg = tcpAvg + udpAvg; TransportRadio.Text = "Transport: " + AvgFormat(transAvg); TcpBox.Text = "TCP: " + AvgFormat(tcpAvg); UdpBox.Text = "UDP: " + AvgFormat(udpAvg); RudpRadio.Text = "RUDP: " + AvgFormat(rudpAvg); float serviceAvg = 0; foreach (ServiceItem service in ServiceList.Items) { service.SubItems[1].Text = AvgFormat(service.BandwidthAverage); serviceAvg += service.BandwidthAverage; } ServiceRadio.Text = "Services: " + AvgFormat(serviceAvg); // title string title = "Bandwidth of " + CoresList.SelectedItems.Count + " Cores: "; if (TransportRadio.Checked) { if (TcpBox.Checked) { title += "TCP "; } if (UdpBox.Checked) { title += "UDP "; } } if (RudpRadio.Checked) { title += "RUDP "; } if (ServiceRadio.Checked) { title += "Selected Services"; } BandwidthGraph.GraphPane.Title.Text = title; // older old to new Array.Reverse(inBytes); Array.Reverse(outBytes); double[] xAxis = new double[RecordSeconds]; for (int i = 0; i < RecordSeconds; i++) { xAxis[i] = -1 * i; } Array.Reverse(xAxis); PointPairList inPoints = new PointPairList(xAxis, inBytes); PointPairList outPoints = new PointPairList(xAxis, outBytes); BandwidthGraph.GraphPane.AddCurve("In", inPoints, Color.Blue, SymbolType.None); BandwidthGraph.GraphPane.AddCurve("Out", outPoints, Color.Red, SymbolType.None); BandwidthGraph.GraphPane.XAxis.Scale.Min = 1 - RecordSeconds; BandwidthGraph.GraphPane.XAxis.Scale.Max = 0; BandwidthGraph.GraphPane.YAxis.Scale.Min = 0; BandwidthGraph.GraphPane.YAxis.Scale.Max = Math.Max(GetMaxAxis(inBytes), GetMaxAxis(outBytes)); BandwidthGraph.AxisChange(); BandwidthGraph.Invalidate(); }