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; } } }
private void AddItemToComboBox(NetworkComboBoxItem item) { if (IncludeOnlyEnabledNetworksInComboBox && !item.NetworkIsConnected) { return; } if (IncludeOnlyNetworksWithIPAddresses && !item.HasIPAddress) { return; } Items.Add(item); }
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); }
private void AddItemToComboBox(NetworkComboBoxItem item) { if( IncludeOnlyEnabledNetworksInComboBox && !item.NetworkIsConnected ) { return; } if (IncludeOnlyNetworksWithIPAddresses && !item.HasIPAddress) { return; } Items.Add(item); }