public void UpdateAdapterList() { if (flowLayoutPanel1.InvokeRequired) { ThreadStart ts = new ThreadStart(UpdateAdapterList); flowLayoutPanel1.Invoke(ts); } else { if (flowLayoutPanel1.Controls.Count == 0) { foreach (NetworkAdapter na in NetworkAdapter.GetAllAdapters()) { AdapterDisplay ad = new AdapterDisplay(new AdapterInfo(na.Pointer, na.Name, na.InterfaceInformation, na.InBandwidth, na.OutBandwidth, na)); ad.Width = flowLayoutPanel1.Width - 5; flowLayoutPanel1.Controls.Add(ad); } } else { foreach (AdapterDisplay ad in flowLayoutPanel1.Controls) { ad.Update(); } foreach (NetworkAdapter na in NetworkAdapter.GetNewAdapters()) { AdapterDisplay ad = new AdapterDisplay(new AdapterInfo(na.Pointer, na.Name, na.InterfaceInformation, na.InBandwidth, na.OutBandwidth, na)); ad.Width = flowLayoutPanel1.Width - 5; flowLayoutPanel1.Controls.Add(ad); } } } }
static void Main(string[] args) { //tray = new TrayIcon(); MoveOldConfig(); ColorScheme.LoadThemes(); mainWindow = new MainWindow(); foreach (NetworkAdapter ni in NetworkAdapter.GetAllAdapters()) { ni.StartProcessing(); } Application.Run(mainWindow); while (Running) { Thread.Sleep(100); } }
/// <summary> /// Load the modules from the first adapter into the Help GUI /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Help_Load(object sender, EventArgs e) { try { // grab the first adapter NetworkAdapter first_adapter = NetworkAdapter.GetAllAdapters()[0]; // get it's module list list = first_adapter.modules; // add it to the box for (int i = 0; i < list.Count; ++i) { modBox.Items.Insert(i, list.GetModule(i).MetaData.Name); } // if there's a set idx, set it if (selectedItem != null) { modBox_SelectedIndexChanged(this, null); } } catch { } }