Esempio n. 1
0
        private void NetworkChange_NetworkAvailabilityChanged(
            object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
        {
            //Invokeが必要か確認し、必要であればInvokeを呼び出す
            if (this.InvokeRequired)
            {
                System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler dlgt =
                    new System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler(
                        NetworkChange_NetworkAvailabilityChanged);

                this.Invoke(dlgt, new object[] { sender, e });
                return;
            }

            if (e.IsAvailable)
            {
                this.Text = "ネットワーク接続が有効";

                String[] SSIDs = NativeWifi.GetConnectedNetworkSsids().ToArray();
                Debug.WriteLine("Connected Network SSID:" + SSIDs[0]);
                if (!ApplyProxySettingsToSystem(SSIDs[0]))
                {
                    Debug.WriteLine("Failed Apply Proxy Setting to System.");
                }
            }

            else
            {
                this.Text = "ネットワーク接続が無効";
                Debug.WriteLine("Disabled Network");
                SetReg_ProxyEnable(false);
            }
        }
Esempio n. 2
0
        public AutoProxySetting()
        {
            InitializeComponent();
            InTasktray();

            NetworkChange.NetworkAddressChanged      += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;

            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));

            String[] SSIDs = NativeWifi.GetConnectedNetworkSsids().ToArray();
            if (SSIDs.Length != 0)
            {
                Debug.WriteLine("[Connected Network SSID]" + SSIDs[0]);
                ApplyProxySettingsToSystem(SSIDs[0]);
            }
            else
            {
                Debug.WriteLine("No connection");
                SetReg_ProxyEnable(false);
            }

            InitStartupCheckBox();
            SetSettingInfoToDGV();
        }
Esempio n. 3
0
        private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
            String[] SSIDs = NativeWifi.GetConnectedNetworkSsids().ToArray();
            Debug.WriteLine("Network Status Changed");

            if (SSIDs.Length != 0)
            {
                ApplyProxySettingsToSystem(SSIDs[0]);
            }
        }
Esempio n. 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            String[] SSIDs = NativeWifi.GetConnectedNetworkSsids().ToArray();
            Debug.WriteLine("OK clicked. Apply Settings.");
            if (SSIDs.Length != 0)
            {
                ApplyProxySettingsToSystem(SSIDs[0]);
            }

            InTasktray();
        }