using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Net.NetworkInformation;

namespace PhoneAppDeviceNetworkInformation
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            tbMO.Text = "CellularMobileOperator: " + DeviceNetworkInformation.CellularMobileOperator;
            tbData.Text = "CellularDataEnabled: " + DeviceNetworkInformation.IsCellularDataEnabled.ToString();
            tbDataRoaming.Text = "CellularDataRoamingEnabled: " + DeviceNetworkInformation.IsCellularDataRoamingEnabled.ToString();
            tbNetwork.Text = "Network available: " + DeviceNetworkInformation.IsNetworkAvailable.ToString();
            tbWIFI.Text = "WIFI Enabled: " + DeviceNetworkInformation.IsWiFiEnabled;
            DeviceNetworkInformation.NetworkAvailabilityChanged += DeviceNetworkInformation_NetworkAvailabilityChanged;
        }

        void DeviceNetworkInformation_NetworkAvailabilityChanged(object sender, NetworkNotificationEventArgs e)
        {
            MessageBox.Show(e.NetworkInterface.Description + ":" + e.NetworkInterface.InterfaceName + ":" + e.NetworkInterface.Bandwidth + ":" + e.NotificationType.ToString());
        }
    }
}