private void setMtuInfo(object item, Boolean forceRefresh = false) { EthernetAdapter eth = item as EthernetAdapter; if (eth == null) { currentAdapterIndex = -1; border_mtu_status.Visibility = Visibility.Hidden; } else if (forceRefresh || currentAdapterIndex != eth.Index) { currentAdapterIndex = eth.Index; border_mtu_status.Visibility = Visibility.Visible; lbl_mtu_value.Content = String.Format(@"Current MTU : {0}", eth.MTU); if (eth.MTU == 1500) { border_mtu_status.BorderBrush = new SolidColorBrush(Colors.Gray); lbl_mtu_value.Foreground = Brushes.Gray; lbl_mtu_status.Foreground = Brushes.Gray; lbl_mtu_status.Content = "Default"; } else { border_mtu_status.BorderBrush = new SolidColorBrush(Colors.Red); lbl_mtu_value.Foreground = Brushes.Red; lbl_mtu_status.Foreground = Brushes.Red; lbl_mtu_status.Content = "Adapted"; } } }
/** * Toggle MTU click * */ private void mtu_change_Click(object sender, System.Windows.Input.MouseButtonEventArgs e) { Debug.Print("index : {0}", (list_eth.SelectedItem as EthernetAdapter)?.Index); EthernetAdapter eth = list_eth.SelectedItem as EthernetAdapter; if (eth != null) { if (eth.MTU == 1500) { NetUtil.ChangeMTU(eth.Index, MTU_CUTDOWN, null); } else { NetUtil.ChangeMTU(eth.Index, MTU_DEFAULT, null); } refreshEthernetAdapterList(); } }