public MainWindow() { try { _adaptors = PingTune.NetState.getAdapterState(); _sys_state = new PingTune.GlobalSystemState(); string systemLanguage = System.Globalization.CultureInfo.CurrentCulture.ThreeLetterISOLanguageName.ToString(); _tt = getToolTipsForLanguage(systemLanguage); EventManager.RegisterClassHandler(typeof(FrameworkElement), FrameworkElement.ToolTipOpeningEvent, new ToolTipEventHandler(getToolTip)); InitializeComponent(); DataContext = this; AdapterListBox.ItemsSource = GetAdapterList(); AdapterListBox.DisplayMemberPath = "Value"; AdapterListBox.SelectedValuePath = "Key"; AdapterListBox.SelectedIndex = 0; _selectedAdaptor = _adaptors[AdapterListBox.SelectedValue.ToString()]; MtuOptValueBox.Text = optMtu.ToString(); toggleThrottling.IsChecked = _sys_state.netThrottling.isOptimized(); toggleMaxForePriority.IsChecked = _sys_state.backgroundReservedCpuPct.isOptimized(); } catch (System.IO.FileNotFoundException e) { MessageBox.Show("Could not find " + e.FileName, "Error"); this.Close(); } }
private void onSelectAdapter(object sender, SelectionChangedEventArgs e) { _selectedAdaptor = _adaptors[AdapterListBox.SelectedValue.ToString()]; MtuValueBox.Text = _selectedAdaptor.MTU.ToString(); toggleFlowControl.IsChecked = _selectedAdaptor.FlowControl.isOptimized(); toggleMaxAckFreq.IsChecked = _selectedAdaptor.TcpAckFrequency.isOptimized(); toggleMaxRxBuf.IsChecked = _selectedAdaptor.RxBuffers.isOptimized(); toggleMaxTxBuf.IsChecked = _selectedAdaptor.TxBuffers.isOptimized(); toggleNagle.IsChecked = _selectedAdaptor.Nagling.isOptimized(); toggleInterruptModeration.IsChecked = _selectedAdaptor.InterruptModeration.isOptimized(); toggleUdpOffload.IsChecked = _selectedAdaptor.UdpChecksumOffload.isOptimized(); toggleTcpOffload.IsChecked = _selectedAdaptor.TcpChecksumOffload.isOptimized(); toggleRssDisable.IsChecked = _selectedAdaptor.RSS.isOptimized(); toggleHeadDataSplit.IsChecked = _selectedAdaptor.HeaderDataSplit.isOptimized(); toggleAckDelay.IsChecked = _selectedAdaptor.TcpDelayedAckTicks.isOptimized(); toggleLargeSendOffload.IsChecked = _selectedAdaptor.LargeSendOffload.isOptimized(); }
public static Dictionary <String, EthernetAdapter> getAdapterState() { foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces()) { IPInterfaceProperties p = adapter.GetIPProperties(); var a = new EthernetAdapter(adapter.Id); a.Description = adapter.Description; a.Speed = adapter.Speed; if (adapter.OperationalStatus == OperationalStatus.Up) { a.Connected = true; } NetworkInterfaceType t = adapter.NetworkInterfaceType; foreach (UnicastIPAddressInformation ip in p.UnicastAddresses) { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { // Crassly assume the first IPv4 address is primary! a.Address = ip.Address.ToString(); break; } } if (t == NetworkInterfaceType.Ethernet) { // Keep a list of the interesting adapter IDs for later. a.MTU = adapter.GetIPProperties().GetIPv4Properties().Mtu; _ethernetAdapters.Add(adapter.Id, a); } } getRegNdisValues(); return(_ethernetAdapters); }