Exemplo n.º 1
0
        public void PopulateComboBox(IXenConnection connection, Func <NetworkComboBoxItem, bool> matchSelectionCriteria)
        {
            Items.Clear();
            UnRegisterEvents();

            _pifArray = new List <PIF>(connection.Cache.PIFs);
            RegisterEvents();

            foreach (var pif in _pifArray)
            {
                var curPif = pif;
                if (!CanShowItem(curPif, out _))
                {
                    continue;
                }

                var item = new NetworkComboBoxItem(curPif, ShowPoolName);
                Items.Add(item);

                if (SelectedItem == null && matchSelectionCriteria(item))
                {
                    SelectedItem = item;
                }
            }
        }
Exemplo n.º 2
0
        private void AddItemToComboBox(NetworkComboBoxItem item)
        {
            if (IncludeOnlyEnabledNetworksInComboBox && !item.NetworkIsConnected)
            {
                return;
            }

            if (IncludeOnlyNetworksWithIPAddresses && !item.HasIPAddress)
            {
                return;
            }

            Items.Add(item);
        }
Exemplo n.º 3
0
        private bool CanShowItem(PIF pif, out NetworkComboBoxItem existingItem)
        {
            existingItem = Items.Cast <NetworkComboBoxItem>().FirstOrDefault(i => i.Network.opaque_ref == pif.network.opaque_ref);

            if (existingItem != null)
            {
                return(false);
            }

            if (ExcludeDisconnectedNetworks && pif.LinkStatus() != PIF.LinkState.Connected)
            {
                return(false);
            }

            if (ExcludeNetworksWithoutIpAddresses && !pif.IsManagementInterface(false))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private void AddItemToComboBox(NetworkComboBoxItem item)
        {                
            if( IncludeOnlyEnabledNetworksInComboBox && !item.NetworkIsConnected )
            {
                return;
            }

            if (IncludeOnlyNetworksWithIPAddresses && !item.HasIPAddress)
            {
                return;
            }

            Items.Add(item);
        }