예제 #1
0
        private void RefreshPage()
        {
            _view.PnlNetworks.Children.Clear();
            var networkList = new List <Network>();

            foreach (var nb in ApplicationContext.AllNeighborhoodWatch)
            {
                if (!networkList.Select(r => r.Name).Contains(nb.SubnetMask))
                {
                    //The Networks-Grid should count only unmanaged devices. This means no managed (this works) and no confirmed ones
                    var totalEndps = ApplicationContext.AllNeighborhoodWatch.Count(c => c.SubnetMask == nb.SubnetMask &&
                                                                                   !c.Managed & !c.Confirmed);
                    var nw = new Network
                    {
                        Name          = nb.SubnetMask,
                        TotalEndpoint = totalEndps
                    };
                    networkList.Add(nw);
                }
            }
            if (networkList != null)
            {
                var flag = false;
                foreach (var net in networkList)
                {
                    var networkButton = new NetworkButtonElement();
                    networkButton.Model.SubnetMark    = net.Name;
                    networkButton.Model.TotalEndpoint = net.TotalEndpoint;
                    networkButton.BtnNetwork.Click   += BtnNetwork_Click;
                    _view.PnlNetworks.Children.Add(networkButton);
                    if (_subnetMask == net.Name)
                    {
                        networkButton.SetActived();
                        OnTabSelected();
                        flag = true;
                    }
                }
                if (!flag)
                {
                    var networkBtns = _view.PnlNetworks.Children.Cast <NetworkButtonElement>().ToList();
                    if (networkBtns.Count > 0)
                    {
                        networkBtns[0].SetActived();
                        _subnetMask = networkBtns[0].Model.SubnetMark;
                        OnTabSelected();
                    }
                    else
                    {
                        _subnetMask = string.Empty;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        ///     Build network buttons
        /// </summary>
        private void CreateNetworks()
        {
            _view.PnlNetworks.Children.Clear();
            var networkList = new List <Network>();

            ApplicationContext.AllNeighborhoodWatch = GetNeighborhoods(string.Empty);
            foreach (var nb in ApplicationContext.AllNeighborhoodWatch)
            {
                if (!networkList.Select(r => r.Name).Contains(nb.SubnetMask))
                {
                    //The Networks-Grid should count only unmanaged devices. This means no managed (this works) and no confirmed ones
                    var totalEndps = ApplicationContext.AllNeighborhoodWatch.Count(c => c.SubnetMask == nb.SubnetMask &&
                                                                                   !c.Managed && !c.Confirmed);
                    var nw = new Network
                    {
                        Name          = nb.SubnetMask,
                        TotalEndpoint = totalEndps
                    };
                    networkList.Add(nw);
                }
            }
            if (networkList != null)
            {
                int count = 0;
                foreach (var net in networkList)
                {
                    var networkButton = new NetworkButtonElement();
                    networkButton.Model.SubnetMark    = net.Name;
                    networkButton.Model.TotalEndpoint = net.TotalEndpoint;
                    networkButton.BtnNetwork.Click   += BtnNetwork_Click;
                    _view.PnlNetworks.Children.Add(networkButton);
                    if (count == 0)
                    {
                        networkButton.SetActived();
                        _subnetMask = net.Name;
                        OnTabSelected();
                    }
                    count++;
                }
            }
        }