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; }
private void LoadNetworkInterfaces() { var interfaces = showDisabledAdapters.Checked ? NetworkInterfaces.FetchAll() : NetworkInterfaces.FetchOperational(); nics.Items.Clear(); nics.Items.AddRange( interfaces.Select( nic => { var stats = nic.GetIPStatistics(); var 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(); }