Ejemplo n.º 1
0
        /**
         * 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();
            }
        }
Ejemplo n.º 2
0
        /**
         * Refresh ethernet adapter list
         * */
        private void refreshEthernetAdapterList()
        {
            var prevSelect = list_eth.SelectedValue;

            NetUtil.RetrieveEthernetAdapterList((List <EthernetAdapter> ethList) => {
                if (!this.Dispatcher.CheckAccess())
                {
                    // refresh ethernet adapter list
                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        updateEthernetAdapterList(ethList, prevSelect);
                        setMtuInfo(list_eth.SelectedItem, true);
                    }));
                }
                else
                {
                    updateEthernetAdapterList(ethList, prevSelect);
                    setMtuInfo(list_eth.SelectedItem, true);
                }
            });
        }