private void FillGrid() { _listCentralConnGroups = ConnectionGroups.GetAll(); //Get all conn group attaches because we will be using all of them in order to show counts. List <ConnGroupAttach> listConnGroupAttaches = ConnGroupAttaches.GetAll(); //always fills combo, too, since it's the same list long defaultConnGroupNum = PrefC.GetLong(PrefName.ConnGroupCEMT); comboConnectionGroup.Items.Clear(); comboConnectionGroup.Items.Add(Lan.g(this, "All")); comboConnectionGroup.SelectedIndex = 0; //Select all by default. //Fill in the list of conn groups and update the selected index of the combo box if needed. for (int i = 0; i < _listCentralConnGroups.Count; i++) { comboConnectionGroup.Items.Add(_listCentralConnGroups[i].Description); if (_listCentralConnGroups[i].ConnectionGroupNum == defaultConnGroupNum) { comboConnectionGroup.SelectedIndex = i + 1; } } //grid----------------------------------------------------------------------------------------------------- gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col = new GridColumn(Lans.g(this, "Group Name"), 280); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lans.g(this, "Conns"), 0); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; for (int i = 0; i < _listCentralConnGroups.Count; i++) { row = new GridRow(); row.Cells.Add(_listCentralConnGroups[i].Description); row.Cells.Add(listConnGroupAttaches.FindAll(x => x.ConnectionGroupNum == _listCentralConnGroups[i].ConnectionGroupNum).Count.ToString()); //row.Tag=connGroup;//Not really used currently, but we may want to add filtering later. gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); }
private void FormCentralConnections_Load(object sender, EventArgs e) { checkIsAutoLogon.Checked = PrefC.GetBool(PrefName.CentralManagerIsAutoLogon); checkUseDynamicMode.Checked = PrefC.GetBool(PrefName.CentralManagerUseDynamicMode); _listConnectionGroups = ConnectionGroups.GetAll(); comboConnectionGroups.Items.Add("All"); comboConnectionGroups.Items.AddRange(_listConnectionGroups.Select(x => x.Description).ToArray()); comboConnectionGroups.SelectedIndex = 0; //Default to all. if (IsSelectionMode) { groupPrefs.Visible = false; butAdd.Visible = false; groupOrdering.Visible = false; } else { butOK.Visible = false; butCancel.Text = "Close"; } _listConnsAll = CentralConnections.GetConnections(); //fix any bad item orders bool foundBad = false; for (int i = 0; i < _listConnsAll.Count; i++) { if (_listConnsAll[i].ItemOrder != i) { foundBad = true; _listConnsAll[i].ItemOrder = i; CentralConnections.Update(_listConnsAll[i]); } } if (foundBad) { _listConnsAll = CentralConnections.GetConnections(); } FillGrid(); }