Exemplo n.º 1
0
        public NetworkStatusResult refresh()
        {
            NetworkStatusResult toReturn = new NetworkStatusResult();

            if (wlan.Interfaces.Length == 0)
            {
                toReturn.SigStrength = NetworkResultSignalStrength.ETHER;
                return(toReturn);
            }
            WlanClient.WlanInterface wlanInterface = wlan.Interfaces[0];
            if (wlanInterface.InterfaceState.Equals(Wlan.WlanInterfaceState.Connected))
            {
                Wlan.Dot11Ssid ssid        = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid;
                var            sigStrength = wlanInterface.CurrentConnection.wlanAssociationAttributes.wlanSignalQuality;
                toReturn.Ssid = new String(Encoding.ASCII.GetChars(ssid.SSID, 0, (int)ssid.SSIDLength));
                if (sigStrength > 0 && sigStrength < 25)
                {
                    toReturn.SigStrength = NetworkResultSignalStrength.ONE;
                }
                else if (sigStrength >= 25 && sigStrength < 50)
                {
                    toReturn.SigStrength = NetworkResultSignalStrength.TWO;
                }
                else if (sigStrength >= 50 && sigStrength < 75)
                {
                    toReturn.SigStrength = NetworkResultSignalStrength.THREE;
                }
                else if (sigStrength >= 75)
                {
                    toReturn.SigStrength = NetworkResultSignalStrength.FOUR;
                }
                else if (sigStrength == 0)
                {
                    toReturn.SigStrength = NetworkResultSignalStrength.ZERO;
                }
                return(toReturn);
            }
            else
            {
                toReturn.SigStrength = NetworkResultSignalStrength.ZERO;
                return(toReturn);
            }
        }
Exemplo n.º 2
0
        void timer_Tick(object sender, EventArgs e)
        {
            // Placing time & date on lock
            LockTime.Content = DateTime.Now.ToString("h" + " " + "mm");
            LockDate.Content = DateTime.Now.ToString("dddd, " + "MMMM dd" + ", " + "yyyy");

            // Getting network SSID & placing it on lock screen
            NetworkStatusResult currentStatus = networkStatuserrrrr.refresh();

            LockSSID.Content = currentStatus.Ssid;

            // Getting the current system power status.
            string strPowerLineStatus;

            strPowerLineStatus = string.Empty;
            switch (SystemParameters.PowerLineStatus)
            {
            case PowerLineStatus.Offline:
                strPowerLineStatus = "Device is running on battery";
                BitmapImage batAlert = new BitmapImage(new Uri(@"pack://*****:*****@"pack://siteoforigin:,,,/resources/symbols/ic_power_connected_50px.png", UriKind.Absolute));
                pwrStateIcon.Source = batConnected as ImageSource;
                break;

            case PowerLineStatus.Unknown:
                strPowerLineStatus = "Power Status: Unknown";
                BitmapImage batUnkown = new BitmapImage(new Uri(@"pack://*****:*****@"pack://siteoforigin:,,,/resources/symbols/ic_signal_wifi_statusbar_1_bar_50px.png", UriKind.Absolute));
                sigStrengthIcon.Source = sigOne as ImageSource;
                break;

            case NetworkResultSignalStrength.TWO:
                BitmapImage sigTwo = new BitmapImage(new Uri(@"pack://*****:*****@"pack://siteoforigin:,,,/resources/symbols/ic_signal_wifi_statusbar_3_bar_50px.png", UriKind.Absolute));
                sigStrengthIcon.Source = sigThree as ImageSource;
                break;

            case NetworkResultSignalStrength.FOUR:
                BitmapImage sigFour = new BitmapImage(new Uri(@"pack://*****:*****@"pack://siteoforigin:,,,/resources/symbols/ic_signal_wifi_statusbar_connected_no_internet_50px.png", UriKind.Absolute));
                sigStrengthIcon.Source = sigZero as ImageSource;
                break;

            case NetworkResultSignalStrength.ETHER:
                BitmapImage sigEther = new BitmapImage(new Uri(@"pack://siteoforigin:,,,/resources/symbols/ic_signal_ethernet_50px.png", UriKind.Absolute));
                sigStrengthIcon.Source = sigEther as ImageSource;
                break;
            }
        }