Esempio n. 1
0
        void InitializeButtons()
        {
            EthernetInf(out EthIP, out EthDns, out EthName);
            WifiInf(out WifiIP, out WifiDns, out WifiName);



            EthStatic.ClearValue(Button.BackgroundProperty);
            EthDHCP.ClearValue(Button.BackgroundProperty);

            WIFIStatic.ClearValue(Button.BackgroundProperty);
            WIFIDhcp.ClearValue(Button.BackgroundProperty);


            if (EthIP == "" && EthDns == "")
            {
                return;
            }

            else if (EthIP == Properties.Settings.Default.EthIPac)
            {
                EthStatic.Background = Brushes.Cyan;
            }


            else
            {
                EthDHCP.Background = Brushes.Cyan;
            }
            //................................

            if (WifiIP == "" && WifiDns == "")
            {
                return;
            }

            else if (WifiIP == Properties.Settings.Default.WifiIPac)
            {
                WIFIStatic.Background = Brushes.Cyan;
            }
            else
            {
                WIFIDhcp.Background = Brushes.Cyan;
            }
        }
Esempio n. 2
0
        private void SetIP(Button sender, string arg)  //To set IP with elevated cmd prompt
        {
            try
            {
                if (sender.Background == Brushes.Cyan)
                {
                    MessageBox.Show("Already Selected...");
                    return;
                }
                ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
                psi.UseShellExecute = true;
                psi.WindowStyle     = ProcessWindowStyle.Hidden;
                psi.Verb            = "runas";
                psi.Arguments       = arg;
                Process.Start(psi);
                if (sender == EthStatic || sender == EthDHCP)
                {
                    EthStatic.ClearValue(Button.BackgroundProperty);
                    EthDHCP.ClearValue(Button.BackgroundProperty);

                    sender.Background = Brushes.Cyan;
                }

                if (sender == WIFIStatic || sender == WIFIDhcp)
                {
                    WIFIStatic.ClearValue(Button.BackgroundProperty);
                    WIFIDhcp.ClearValue(Button.BackgroundProperty);

                    sender.Background = Brushes.Cyan;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }