Example #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);
            }
        }
Example #2
0
 void OnNetworkAvailabilityChanged(object o, NetworkAvailabilityEventArgs args)
 {
     var handler = StateChange;
     if (handler != null) {
         handler (args.IsAvailable ? State.Connected : State.Disconnected);
     }
 }
 private void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         this.SendNetworkConnectedEvent();
     }
 }
Example #4
0
        private void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            // We invoke on the dispatcher because we are needing to recompose UI.
            // If we don't do this, an exception will be thrown as the composition isn't
            // guaranteed to happen on the necesary UI thread.
            Dispatcher.CurrentDispatcher.Invoke(new Action(() =>
            {
                var oldStatus = _networkStatus;
                var newStatus = (e.IsAvailable) ? "Online" : "Offline";

                var added = MatchingParts(newStatus);
                var removed = NonMatchingParts(newStatus);

                using (var atomic = new AtomicComposition())
                {
                    atomic.AddCompleteAction(() => _networkStatus = newStatus);
                    if (Changing != null)
                    {
                        Changing(this, new ComposablePartCatalogChangeEventArgs(added, removed, atomic));
                    }
                    atomic.Complete();
                }

                if (Changed != null)
                {
                    Changed(this, new ComposablePartCatalogChangeEventArgs(added, removed, null));
                }
            }));
        }
Example #5
0
 private void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (StateChanged != null)
     {
         this.StateChanged.Invoke(this, e);
     }
 }
Example #6
0
 private static void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         LogHelper.WriteLog("Network Available");
     }
     else
     {
         LogHelper.WriteLog("Network Unavailable");
     }
 }
Example #7
0
 private void LinkStatusChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         UpdateLinkStatus(Constants.LINK_CONNECTED);
     }
     else
     {
         UpdateLinkStatus(Constants.LINK_DISCONNECTED);
     }
 }
        private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (e.IsAvailable)
                {
                    this.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                    this.Visibility = System.Windows.Visibility.Visible;
            }));

        }
Example #9
0
        private async void HandleNetworkChange(object sender, NetworkAvailabilityEventArgs e)
        {
            if (!waitingForConnectivity)
            {
                return;
            }

            if (e.IsAvailable)
            {
                await SynchronizeAsync().ConfigureAwait(false);
            }
        }
 protected void NetworkChange_NetworkAvailabilityChanged(object sender,
                                                         System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
 {
     m_bNetworkAvailable = e.IsAvailable;
     if (m_bNetworkAvailable)
     {
         OnNetworkAvailable(new NetworkStatusChangedEventArgs(true));
     }
     else
     {
         OnNetworkUnavailable(new NetworkStatusChangedEventArgs(true));
     }
 }
Example #11
0
 private static void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         Console.WriteLine("Network Available");
         Debug.Write("Network Available");
     }
     else
     {
         Debug.Write("Network Unavailable");
         Console.WriteLine("Network Unavailable");
     }
 }
 void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         Program.Init();
         Trace.WriteLine("Network became available");
     }
     else
     {
         Program.KillSocket();
         Trace.WriteLine("Network went down");
     }
 }
        /// <summary>Notify listeners that the network is now reachable/unreachable.</summary>
        private void OnNetworkChange(Object sender, NetworkAvailabilityEventArgs args)
        {
            var evt = StatusChanged;
            if (evt == null)
            {
                return;
            }

            var status = args.IsAvailable
                ? NetworkReachabilityStatus.Reachable
                : NetworkReachabilityStatus.Unreachable;

            var eventArgs = new NetworkReachabilityChangeEventArgs(status);
            evt(this, eventArgs);
        }
Example #14
0
        void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            using (WaitCursor wc = new WaitCursor())
            {
                if (e.IsAvailable)
                {
                    if (NetworkServices.IsNetworkAvailable())
                    {
                        SetMessage("network found.");

                        if (_syncServices.LoginRemoteService(_configurationManager.LoggedInUser)) SetMessage("Connected to server");
                        else SetMessage("Could not connect to server.");
                    }
                }
            }
        }
        private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Context.GetPlugin<SpeechPlugin>()?.Say(e.IsAvailable ? "Сетевое соединение восстановлено" : "Потеряно сетевое соединение");

            if (!e.IsAvailable)
            {
                ProcessStartInfo pInfo = new ProcessStartInfo();
                pInfo.FileName = @"C:\WINDOWS\System32\ipconfig.exe";

                pInfo.Arguments = "/release";
                Process.Start(pInfo).WaitForExit();

                pInfo.Arguments = "/renew";
                Process.Start(pInfo).WaitForExit();
            }
        }
            private static void ChangedAddress(object?sender, EventArgs eventArgs)
            {
                Dictionary <NetworkAvailabilityChangedEventHandler, ExecutionContext?>?availabilityChangedSubscribers = null;

                lock (s_globalLock)
                {
                    bool isAvailableNow = SystemNetworkInterface.InternalGetIsNetworkAvailable();

                    // If there is an Availability Change, need to execute user callbacks.
                    if (isAvailableNow != s_isAvailable)
                    {
                        s_isAvailable = isAvailableNow;

                        if (s_availabilityChangedSubscribers.Count > 0)
                        {
                            availabilityChangedSubscribers = new Dictionary <NetworkAvailabilityChangedEventHandler, ExecutionContext?>(s_availabilityChangedSubscribers);
                        }
                    }
                }

                // Executing user callbacks if Availability Change event occured.
                if (availabilityChangedSubscribers != null)
                {
                    bool isAvailable = s_isAvailable;
                    NetworkAvailabilityEventArgs args = isAvailable ? s_availableEventArgs : s_notAvailableEventArgs;
                    ContextCallback callbackContext   = isAvailable ? s_runHandlerAvailable : s_runHandlerNotAvailable;

                    foreach (KeyValuePair <NetworkAvailabilityChangedEventHandler, ExecutionContext?>
                             subscriber in availabilityChangedSubscribers)
                    {
                        NetworkAvailabilityChangedEventHandler handler = subscriber.Key;
                        ExecutionContext?ec = subscriber.Value;

                        if (ec == null) // Flow supressed
                        {
                            handler(null, args);
                        }
                        else
                        {
                            ExecutionContext.Run(ec, callbackContext, handler);
                        }
                    }
                }
            }
        private static void networkChange_NetworkAvailabilityChanged(object i_Sender, NetworkAvailabilityEventArgs i_Args)
        {
            List<ICommand> commandsFinishedSuccessfuly = new List<ICommand>();
            foreach (ICommand command in sr_ScheduledCommands)
            {
                if (!NetworkInterface.GetIsNetworkAvailable())
                {
                    break;
                }

                command.Execute();
                commandsFinishedSuccessfuly.Add(command);
            }

            foreach (ICommand command in commandsFinishedSuccessfuly)
            {
                sr_ScheduledCommands.Remove(command);
            }
        }
 static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     Trace.WriteLine("Got Network Change Event");
     if (e.IsAvailable)
     {
         try
         {
             Init();
         }
         catch { }
     }
     else
     {
         try
         {
             KillSocket();
         }
         catch {}
     }
 }
        private static void OnAvailabilityTimerFired(object state)
        {
            Dictionary <NetworkAvailabilityChangedEventHandler, ExecutionContext> availabilityChangedSubscribers = null;

            lock (s_gate)
            {
                if (s_availabilityHasChanged)
                {
                    s_availabilityHasChanged = false;
                    if (s_availabilityChangedSubscribers.Count > 0)
                    {
                        availabilityChangedSubscribers =
                            new Dictionary <NetworkAvailabilityChangedEventHandler, ExecutionContext>(
                                s_availabilityChangedSubscribers);
                    }
                }
            }

            if (availabilityChangedSubscribers != null)
            {
                bool isAvailable = NetworkInterface.GetIsNetworkAvailable();
                NetworkAvailabilityEventArgs args = isAvailable ? s_availableEventArgs : s_notAvailableEventArgs;
                ContextCallback callbackContext   = isAvailable ? s_runHandlerAvailable : s_runHandlerNotAvailable;

                foreach (KeyValuePair <NetworkAvailabilityChangedEventHandler, ExecutionContext>
                         subscriber in availabilityChangedSubscribers)
                {
                    NetworkAvailabilityChangedEventHandler handler = subscriber.Key;
                    ExecutionContext ec = subscriber.Value;

                    if (ec == null) // Flow supressed
                    {
                        handler(null, args);
                    }
                    else
                    {
                        ExecutionContext.Run(ec, callbackContext, handler);
                    }
                }
            }
        }
 /// <summary>Notify listeners that the network is now reachable/unreachable.</summary>
 internal void OnNetworkChange(Object sender, NetworkAvailabilityEventArgs args)
 {
     var status = args.IsAvailable
         ? NetworkReachabilityStatus.Reachable
         : NetworkReachabilityStatus.Unreachable;
     
     InvokeNetworkChangeEvent(status);
 }
Example #21
0
 private static void DoNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     SignalAvailabilityChange(sender);
 }
 private void OnAvailabilityChanged(object ignored, NetworkAvailabilityEventArgs e)
 {
     Context.GetJavaScriptModule<RCTDeviceEventEmitter>()
         .emit("networkStatusDidChange", CreateConnectivityEventMap());
 }
Example #23
0
 void NetworkChange_NetworkAvailabilityChanged(object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
 {
     bNetworkAvailable = IsNetworkAvailable();
 }
Example #24
0
 /// <summary>
 /// Networks the status_ availability changed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e argument.</param>
 private void NetworkStatus_AvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     DIContainer.Instance.Resolve<Workstation>().IsNetworkAvailable = e.IsAvailable;
 }
Example #25
0
 private void NetworkChange_NetworkAvailabilityChanged(object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
 {
     this.OnNetworkAdaptersChanged();
 }
 private void NetworkChangeNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e) {
     UpdateNetworkConnectionStatus();
 }
Example #27
0
 void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     Trace.TraceInformation("Network availability changed");
 }
Example #28
0
 void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     InvalidateDnsServers();
 }
Example #29
0
		private static void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
		{
			Application.Current.Dispatcher.InvokeAsync(Nic.Reload);
		}
Example #30
0
        /// <summary>
        /// Network status has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            if (e.IsAvailable)
            {
                WifiRemote.LogMessage("Network connected, starting server", LogType.Debug);

                // Restart the socket server
                InitAndStartSocket();

                // Restart bonjour service
                if (!disableBonjour)
                {
                    WifiRemote.LogMessage("Restarting bonjour service", LogType.Debug);
                    PublishBonjourService();
                }
            }
            else
            {
                WifiRemote.LogMessage("Network lost, stopping server", LogType.Debug);

                // Stop bonjour service
                if (!disableBonjour)
                {
                    publishService.Stop();
                }

                // Stop socket server
                if (socketServer != null)
                {
                    socketServer.Stop();
                }
            }
        }
Example #31
0
        private void OnNetworkStateChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            //string heading;
            //string message;

            if (e.IsAvailable)
            {
                //Log.Info("TvHome: Network connected!");
                //heading = Utility.GetLocalizedText(TextId.Information);
                //message = "Network connected!";
                PluginMain.NetworkAvailable = true;
            }
            else
            {
                //Log.Error("TvHome: Network disconnected!");
                //heading = Utility.GetLocalizedText(TextId.Error);
                //message = "Network disconnected!";
                PluginMain.NetworkAvailable = false;

                //if (!PluginMain.IsSingleSeat)
                //{
                /*if (g_Player.Playing && (g_Player.IsRadio || g_Player.IsTV || g_Player.IsTVRecording))
                {
                    //g_Player.Stop();
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORDER_VIEW_CHANNEL, 0, 0, 0, 0, 0, null);
                    msg.Param1 = 1111;
                    //msg.Object = recording;
                    GUIGraphicsContext.SendMessage(msg);
                    msg = null;
                }*/

                /*using (Settings xmlreader = new MPSettings())
                {
                    bool _startWithBasicHome = xmlreader.GetValueAsBool("gui", "startbasichome", false);
                    if (_startWithBasicHome && System.IO.File.Exists(GUIGraphicsContext.Skin + @"\basichome.xml"))
                    {
                        GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_SECOND_HOME);
                    }
                    else
                    {
                        GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_HOME);
                    }
                }*/
                //}



                /*GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (pDlgNotify != null)
                {
                    pDlgNotify.Reset();
                    pDlgNotify.ClearAll();
                    pDlgNotify.SetHeading(heading);
                    pDlgNotify.SetText(message);
                    pDlgNotify.TimeOut = 5;
                    //Utils.PlaySound("notify.wav", false, true);
                    pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                }*/
            }

            /*GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
            if (pDlgNotify != null)
            {
                pDlgNotify.Reset();
                pDlgNotify.ClearAll();
                pDlgNotify.SetHeading(heading);
                pDlgNotify.SetText(message);
                pDlgNotify.TimeOut = 5;
                Utils.PlaySound("notify.wav", false, true);
                pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
            }*/
        }
        /// <summary>
        /// Checks if an internet connection is available every time the network connection changes
        /// </summary>
        private static void NetworkAvailabilityChange(object sender, NetworkAvailabilityEventArgs e)
        {
            string warning = "ATTENTION:  Active Authentication has detected the loss of your internet connection.\n\n";
            warning = warning + "If possible, we STRONGLY recommend that you IMMEDIATELY RECONNECT TO THE INTERNET and then PAUSE Active Authentication before continuing to work offline.\n\n";
            warning = warning + "Do NOT attempt to PAUSE Active Authentication without a working internet connection or you will be locked out of your machine until internet can be reestablished.\n\n";
            warning = warning + "While you may be able to continue to use your machine offline normally for the time being, without internet if you attempt to perform an action that requires secondary authentication (or if you are inadvertently marked as a potential imposter) Active Authentication will be unable to send you a verification code and you will be locked out of your machine until you can reestablish an internet connection and receive a verification code.";
            if (e.IsAvailable)
            {
                Ping p = new Ping();
                try
                {
                    PingReply reply = p.Send("www.google.com", 3000);
                    if (reply.Status == IPStatus.Success)
                    {
                        internetAvailable = true;
                    }
                    else
                    {
                        MessageBox.Show(warning, "Internet Lost:");
                        internetAvailable = false;
                    }
                }
                catch { }

            }
            else
            {
                MessageBox.Show(warning, "Internet Lost:");
                internetAvailable = false;
            }
        }
Example #33
0
 private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     this.SetProxy();
     Messenger.Default.Send<TimerMessage>(new TimerMessage(), (object)TimerMessages.RestRefresh);
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)ViewModelMessages.RebootTHEStream);
 }
Example #34
0
        /// <summary>
        /// When the networks connection is opened or closed, we notify the subscribers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            lock (s_syncLock)
            {
                s_networkAvailable = e.IsAvailable;

                if (s_subscribers == null)
                    return;

                // Scroll through the monitors and remove them when they're no longer available
                int index = 0;
                while (index < s_subscribers.Count)
                {
                    INetworkChangeSubscriber target;
                    if (s_subscribers[index].TryGetTarget(out target))
                    {
                        target.SetNetworkStatus = e.IsAvailable;
                        index++;
                    }
                    else
                        s_subscribers.RemoveAt(index);
                }
            }
        }
Example #35
0
 async void NetworkChange_NetworkAvailabilityChanged(object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
 {
     await DoUpdateAdaptersListAsync();
 }
Example #36
0
 // Update network availability.
 private void NetworkChange_NetworkAvailabilityChanged(
     object sender, NetworkAvailabilityEventArgs e)
 {
     this.Invoke(
         new NetworkAvailabilityCallback(UpdateNetworkAvailability),
         new object[1] { e.IsAvailable });
 }
Example #37
0
 private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     Console.WriteLine("Network connection change detected!!!!!");
     try
     {
         // Get all connection profiles
         string connectionProfileList = string.Empty;
         try
         {
             if (e.IsAvailable)
             {
                 var ConnectionProfiles = NetworkInformation.GetConnectionProfiles();
                 foreach (var connectionProfile in ConnectionProfiles)
                 {
                     switch (connectionProfile.GetNetworkConnectivityLevel())
                     {
                         case NetworkConnectivityLevel.None : continue;
                         case NetworkConnectivityLevel.LocalAccess:
                             {
                                 Console.WriteLine(connectionProfile.ProfileName + " : local access");
                                 atNetworkChange(connectionProfile.ProfileName , "local");
                                 return;
                             }
                         case NetworkConnectivityLevel.ConstrainedInternetAccess:
                             {
                                 Console.WriteLine(connectionProfile.ProfileName + " : ConstrainedInternetAccess");
                                 atNetworkChange(connectionProfile.ProfileName, "ConstrainedInternet");
                                 return;
                             }
                         case NetworkConnectivityLevel.InternetAccess:
                             {
                                 Console.WriteLine(connectionProfile.ProfileName + " : InternetAccess");
                                 atNetworkChange(connectionProfile.ProfileName, "Internet");
                                 return;
                             }
                     }
                 }
             }
             else
             {
                 Console.WriteLine("Not Connected to a network");
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Unexpected exception occurred: " + ex.ToString());
         }
     }
     catch (NetworkInformationException ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
     }
 }