示例#1
0
        public NetShufflerForm()
        {
            InitializeComponent();

            // Check whether start-on-login is set
            startWithWindowsToolStripMenuItem.Checked = StartAtLoginConfig.CheckStartupConfig();

            // Bind data grid data source
            ConfigBindingSource.DataSource = config;
            dgProfiles.DataSource          = config.Profiles;
            cbxProfiles_CheckedChanged(this, null);

            // Open a Win32 handle to the WiFi subsystem.
            uint wifi_ver;

            if (Win32API.WlanOpenHandle((uint)2, IntPtr.Zero, out wifi_ver, out wifi_handle) != 0)
            {
                Win32API.ThrowException();
            }

            // Set up detection of network stauts changes using .NET.

            // Method #1: NetworkListManager
            nlm = new NetworkListManager();
            try
            {
                nlm.NetworkAdded += new INetworkEvents_NetworkAddedEventHandler(OnNetworkAdded);
                nlm.NetworkConnectivityChanged += new INetworkEvents_NetworkConnectivityChangedEventHandler(OnNetworkConnectivityChanged);
                nlm.NetworkDeleted             += new INetworkEvents_NetworkDeletedEventHandler(OnNetworkDeleted);
                nlm.NetworkPropertyChanged     += new INetworkEvents_NetworkPropertyChangedEventHandler(OnNetworkPropertyChanged);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // Method #2: System.Net.NetworkInformation.NetworkChange
            NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(OnNetworkChange);

            // Initially populate the active network list.
            UpdateNetworkList();
        }
示例#2
0
 // Turn on or off automatic startup at login.
 private void startWithWindowsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     startWithWindowsToolStripMenuItem.Checked = !startWithWindowsToolStripMenuItem.Checked;
     StartAtLoginConfig.SetStartupConfig(startWithWindowsToolStripMenuItem.Checked);
 }