public ConnectionStatisticsForm(ConnectionHistoryEntry entry, LogPacket[] packets)
        {
            InitializeComponent();

            if (entry != null)
            {
                foreach (KeyValuePair<string, object> pair in entry.Properties)
                {
                    ListViewItem item = listViewProperties.Items.Add(pair.Key);
                    item.SubItems.Add(pair.Value.ToString());
                    item.Tag = pair.Value;
                }
            }
            else
            {
                tabControl.TabPages.Remove(tabPageProperties);
            }

            if (packets != null && packets.Length > 0)
            {
                packetLogControl.SetPackets(packets);
                tagStatisticsChartControl.SetPackets(packets);
                histogramChartControl.SetPackets(packets);
                networkTrafficChartControl.SetPackets(packets);
            }
            else
            {
                tabControl.TabPages.Remove(tabPageHistogram);
                tabControl.TabPages.Remove(tabPagePackets);
                tabControl.TabPages.Remove(tabPageTagStatistics);
                tabControl.TabPages.Remove(tabPageNetworkTraffic);
            }
        }
        private void CloseConnection(ConnectionEntry entry)
        {
            NetGraph graph = entry.Graph;

            lock (entry)
            {
                if (!graph.IsDisposed)
                {
                    ConnectionHistoryEntry history = new ConnectionHistoryEntry(graph.NetworkDescription, graph.Uuid, graph.Created, DateTime.Now);
                    bool noConnections = false;

                    foreach (KeyValuePair<string, object> pair in graph.ConnectionProperties)
                    {
                        if (pair.Value.GetType().IsSerializable)
                        {
                            history.Properties[pair.Key] = pair.Value;
                        }
                    }

                    try
                    {
                        entry.Dispose();
                    }
                    catch
                    {
                        // Shouldn't throw but just in case
                    }

                    lock (_history)
                    {
                        _history.Add(history);
                    }

                    lock (_connections)
                    {
                        _connections.Remove(entry);
                        if (_connections.Count == 0)
                        {
                            noConnections = true;
                        }
                    }

                    if (CloseConnectionEvent != null)
                    {
                        CloseConnectionEvent(this, new ConnectionEventArgs(graph));
                    }

                    if (_logger != null)
                    {
                        _logger.LogVerbose(CANAPE.Net.Properties.Resources.NetworkServiceBase_ConnectionClosed, graph.NetworkDescription);
                    }

                    if ((_state == (int)ServiceState.StopPending) && noConnections)
                    {
                        CompleteStop();
                    }
                }
            }
        }