Пример #1
0
        public void Update(IEnumerable <IWirelessNetwork> networks)
        {
            Dispatcher.Invoke(() =>
            {
                NetworksStackPanel.Children.Clear();

                foreach (var network in networks)
                {
                    var button    = new ActionCenterWirelessNetworkButton(network);
                    var isCurrent = network.Status == WirelessNetworkStatus.Connected;

                    button.IsCurrent        = isCurrent;
                    button.NetworkName      = network.Name;
                    button.SignalStrength   = network.SignalStrength;
                    button.NetworkSelected += (id) => NetworkSelected?.Invoke(id);

                    if (isCurrent)
                    {
                        NetworkStatus            = network.Status;
                        SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
                    }

                    NetworksStackPanel.Children.Add(button);
                }
            });
        }
        private void UpdateNetworks()
        {
            var status = WirelessNetworkStatus.Disconnected;

            NetworksStackPanel.Children.Clear();

            foreach (var network in wirelessAdapter.GetNetworks())
            {
                var button = new ActionCenterWirelessNetworkButton(network);

                button.NetworkSelected += (o, args) => wirelessAdapter.Connect(network.Id);

                if (network.Status == WirelessNetworkStatus.Connected)
                {
                    status = WirelessNetworkStatus.Connected;
                    SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
                    UpdateText(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", network.Name));
                }

                NetworksStackPanel.Children.Add(button);
            }

            UpdateStatus(status);
        }