Esempio n. 1
0
 private void Load()
 {
     NetworkInterface = NetworkInterfaces.Fetch(settings.LastNic);
     NicSpeeds        = settings.NicSpeeds;
     Bounds           = settings.Bounds;
     Topmost          = settings.Topmost;
     Transparent      = settings.Transparent;
     Docking          = settings.Docking;
     LoadHidden       = settings.LoadHidden;
     Tooltips         = settings.Tooltips;
 }
Esempio n. 2
0
        private void LoadNetworkInterfaces()
        {
            IEnumerable <NetworkInterface> interfaces = showDisabledAdapters.Checked ? NetworkInterfaces.FetchAll() : NetworkInterfaces.FetchOperational();

            nics.Items.Clear();
            nics.Items.AddRange(
                interfaces.Select(
                    nic =>
            {
                IPInterfaceStatistics stats = nic.GetIPStatistics();

                ListViewItem item = new ListViewItem(new[] {
                    nic.Description,
                    nic.NetworkInterfaceType.ToString(),
                    nic.Speed.ToString(),
                    stats.BytesReceived.ToString(),
                    stats.BytesSent.ToString(),
                });

                // Store NetworkInterface because querying NICs is an expensive operation.
                item.Tag = nic;

                if (nic.OperationalStatus != OperationalStatus.Up)
                {
                    item.ForeColor = SystemColors.GrayText;
                }

                return(item);
            }
                    )
                .ToArray()
                );

            // HeaderSize includes column content but ColumnContent excludes header size.
            nics.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            SelectCurrentNetworkInterface();
        }