void RefreshNetworkInterfaceDeviceChoices(bool doNetworkDeviceReload)
        {
            LogThis(LogLevel.Debug, $"Network device re-detection request received ...");

            LogThis(LogLevel.Trace, $"Re-detecting network devices ...");


            if (doNetworkDeviceReload)
            {
                NetworkInterfaceDevice.LoadAllNetworkInterfaces();
            }

            LogThis(LogLevel.Trace, $"Network device re-detection complete");
            LogThis(LogLevel.Trace, $"Resetting UI controls ...");


            EthernetComboBox.Items.Clear();
            WifiComboBox.Items.Clear();

            EthernetComboBox.Items.AddRange(NetworkInterfaceDevice.AllEthernetNetworkInterfaces.ToArray());
            WifiComboBox.Items.AddRange(NetworkInterfaceDevice.AllWifiNetworkInterfaces.ToArray());

            LogThis(LogLevel.Trace, $"Populating control values from current settings ...");

            ReloadOldSettings();

            if (EthernetComboBox.SelectedIndex == -1)
            {
                EthernetDoNotAutoDiscardCheckBox.Checked = false;
                EthernetDoNotAutoDiscardCheckBox.Enabled = false;
            }
            else if (((NetworkInterfaceDevice)EthernetComboBox.SelectedItem).CurrentState == InterfaceState.DevicePhysicallyDisconnected)
            {
                EthernetDoNotAutoDiscardCheckBox.Enabled = false;
            }

            if (WifiComboBox.SelectedIndex == -1)
            {
                WifiDoNotAutoDiscardCheckBox.Checked = false;
                WifiDoNotAutoDiscardCheckBox.Enabled = false;
            }
            else if (((NetworkInterfaceDevice)WifiComboBox.SelectedItem).CurrentState == InterfaceState.DevicePhysicallyDisconnected)
            {
                WifiDoNotAutoDiscardCheckBox.Enabled = false;
            }

            if (EthernetComboBox.SelectedIndex == -1 || WifiComboBox.SelectedIndex == -1)
            {
                this.needToInitializeSettings = true;
            }

            LogThis(LogLevel.Debug, $"Network device re-detection request complete");
        }
Example #2
0
        void ValidateNetworkDeviceChoicesAndSettings(bool doingInitialSettingsLoad = false)
        {
            LogThis(LogLevel.Debug, "-> Valid device choices and settings ...");

            NetworkInterfaceDevice.LoadAllNetworkInterfaces();

            if (doingInitialSettingsLoad &&
                (NetworkInterfaceDevice.AllEthernetNetworkInterfaces.Count == 0 ||
                 NetworkInterfaceDevice.AllWifiNetworkInterfaces.Count == 0))
            {
                MessageBox.Show("Your system doesn't have Wifi and/or Ethernet adapters. Please connect them before launching this app. Exiting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ExitImmediately();
            }

            if (!Global.AppSettings.AreAllSettingsValidAndPresent())
            {
                if (doingInitialSettingsLoad == false)
                {
                    MessageBox.Show("You need to re-choose one or both network interfaces");
                }
                Global.AppSettings.ShowSettingsForm(true);
            }
            LogThis(LogLevel.Debug, "Device choices and settings validation done");
        }