/// <summary> /// Handler for selecting a different network interface to focus on /// </summary> private void CobAutoInterfaceSelectionChanged(object sender, RoutedEventArgs e) { var selected = (string)cobAutoInterface.SelectedItem; foreach (WrapNetworkInterface wni in _networkInterface) { if (wni.Name.Equals(selected)) { _selectedNetworkInterface = wni; break; } } Info(); }
/// <summary> /// Fetches network interfaces, prepares graph, etc /// </summary> public void InitializeData() { foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { var w = new WrapNetworkInterface(ni); // not a real interface, skip it if (!w.PhysicalAdapter) continue; // try and default to the first wifi interface, any interface will do though if (_selectedNetworkInterface == null || w.Name.Equals("Wireless Network Connection")) _selectedNetworkInterface = w; cobAutoInterface.Items.Add(w.Name); _networkInterface.Add(w); } cobAutoInterface.SelectedItem = _selectedNetworkInterface.Name; // prepop traffic graph with zeros, it looks wonky if it has to grow from no data points RestartGraph(); chInfoTraffic.DataContext = _infoTrafficData; // trayicon _notifyIcon = new System.Windows.Forms.NotifyIcon {Text = "", Icon = _iconAutoDisabled}; _notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(NotifyIconMouseClick); _notifyIcon.Visible = true; _internetAccess.ProgressMaxLines = 10; _internetAccess.AddProgress("Waiting for something to do (alt-c to force a check)"); txLoginConsole.DataContext = _internetAccess; // delayed OnTextChanged for the mb/minutes textboxes, try to avoid accidental interface // restarts when all they were doing was changing one of the auto thresholds _textChangedTimer = new DispatcherTimer(DispatcherPriority.Background) {Interval = new TimeSpan(0, 0, 0, 1, 500)}; _textChangedTimer.Tick += (o, e) => { _textChangedTimer.Stop(); Info(); }; tbAutoMegabytes.TextChanged += (o, e) => _textChangedTimer.Start(); tbAutoMinutes.TextChanged += (o, e) => _textChangedTimer.Start(); Info(); }