示例#1
0
        private void OnNetworkManagerEvent(object o, EventArgs args)
        {
            try {
                State new_state = nm_manager.State;
                if (new_state != current_state && (new_state == State.Connected || new_state == State.Disconnected))
                {
                    current_state = new_state;

                    NetworkStateChangedHandler handler = StateChanged;
                    if (handler != null)
                    {
                        NetworkStateChangedArgs state_changed_args = new NetworkStateChangedArgs();
                        state_changed_args.Connected = Connected;
                        handler(this, state_changed_args);
                    }

                    Device active_device = nm_manager.ActiveDevice;

                    if (Connected && active_device != null)
                    {
                        Console.WriteLine("Network Connection Established", String.Format("{0} ({1})",
                                                                                          active_device.Name, active_device.IP4Address));
                    }
                    else if (Connected)
                    {
                        Console.WriteLine("Network Connection Established", "Active Device Unknown");
                    }
                    else
                    {
                        Console.WriteLine("Network Connection Unavailable", "Disconnected");
                    }
                }
            } catch (Exception) {
            }
        }
示例#2
0
文件: Window.cs 项目: MrJoe/lat
        void OnNetworkStateChanged(object o, NetworkStateChangedArgs args)
        {
            if (args.Connected)
            {
                mainWindow.Sensitive = true;
            }
            else
            {
                HIGMessageDialog dialog = new HIGMessageDialog(
                    mainWindow,
                    0,
                    Gtk.MessageType.Info,
                    Gtk.ButtonsType.Ok,
                    "Network disconnected",
                    "The network is down. LAT will disable itself until it comes back up");

                dialog.Run();
                dialog.Destroy();

                mainWindow.Sensitive = false;
            }
        }