Пример #1
0
        private void NetworkWatcher_NetworkConnected(object sender, EventArgs e)
        {
            var data = new NetworkStatusDataStruct()
            {
                IsConnected = true
            };

            HandleNetworkStatusEvent(data);
            //处理wifi连接事件
            var networkInterfaces             = NetworkInterface.GetAllNetworkInterfaces();
            NetworkInterface networkInterface = null;

            foreach (var item in networkInterfaces)
            {
                if (item.OperationalStatus == OperationalStatus.Up &&
                    item.Speed > 0 &&
                    item.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
                {
                    networkInterface = item;
                }
            }
            if (networkInterface != null)
            {
                HandleWIFIConnectedEvent(SystemHelper.GetCurrentWIFISSID());
            }
        }
Пример #2
0
        private void NetworkWatcher_NetworkDisconnect(object sender, EventArgs e)
        {
            var data = new NetworkStatusDataStruct()
            {
                IsConnected = false
            };

            HandleNetworkStatusEvent(data);
        }
Пример #3
0
        private void HandleNetworkStatusEvent(NetworkStatusDataStruct data)
        {
            var evs = eventService.
                      GetEvents().
                      Where(m => m.EventType == Event.Types.EventType.NetworkStatusEvent).
                      ToList();

            foreach (var ev in evs)
            {
                eventService.Invoke(ev, data);
            }
        }